title: How can I install a DYLD loader command that is not explicitly supported by ld?
body: <p>On Mac OS X, binary executables in the DYLD format contain "loader commands" that instruct the library loading system how to handle the contents of the file. In particular, the loader command instruct the system where dependent libraries should be searched for, etc.</p>
  
  <p>You can see the complete list of loader commands for any binary on your system by running "otool -l /path/to/your/app".</p>
  
  <p>Generally speaking these loader commands are set by the "ld" tool during the link phase of a project's compilation.</p>
  
  <p>My question is, what do I need to do to add loader commands for publicized types that are not supported (apparently) by ld? </p>
  
  <p>In particular, I would like to take advantage of the LC_DYLD_ENVIRONMENT loader commmand, which can be used to specify a string in the loader commands table of a binary that should be loaded and evaluated as environment variable settings in the context of the executable.</p>
  
  <p>I don't see any argument to ld that would facilitate this. Something like "-sectcreate" but for specifically adding to the content of the loader commands, is what I'm after.</p>
  
  <p>I know this is possible because at least one standard app on Mac OS X uses it: Safari. But I don't know whether they achieve this by some kind of post-link massage of the binary, if they're using a custom version of ld that knows how to build and chain the custom loader command in, or if they are exploiting a general-purpopse feature of the ld command that I haven't been able to figure out.</p>