GNU ld automatically exports all symbols if no symbols have been chosen to export via either def files or dllexport attributes. The same behaviour can also be enabled via the GNU ld option --export-all-symbols, in case some symbols are marked for export via a def file or dllexport attribute.
The list of excluded symbols is from GNU ld, minus the cygwin specific symbols.
Also add support for outputting the actual list of exported symbols in a def file, as in the GNU ld option --output-def.
This currently exports all symbols from object files pulled in from libmingwex.
These options in GNU ld are documented in https://sourceware.org/binutils/docs/ld/WIN32.html.
Since what this function constructs is a set containing predetermined elements, it is probably better to construct it directly, as it is more obvious what we are doing.