Support platforms that don't have environ in any header (e.g. FreeBSD)
Use /bin/sh rather than /bin/bash for more portability.  The scripts
aren't using anything other than POSIX shell syntax anyway.
Set the open flags correctly for the output:
- We only write so O_WRONLY is more appropriate.
- We should set O_TRUNC because otherwise you end up producing a
  corrupted file if the new output is shorter.
Add execvP to the ExportedSymbolsList so it works on FreeBSD.
Improve the handling of the linker options.
- You can use GCC on the Mac and the current detection will be wrong,
  the issue is the the Mac isn't using a GNU ld, which CMake doesn't
  have a way to detect.
- For our purposes we can do the equivalent of what we were doing with
  -exported_sybmols_list, which should avoid symbol conflicts.