Home Explore Blog CI



man-pages

28th chunk of `ld.man`
9028373de8bfb47b39977d0f95a4fcfe27ce278e3008fc570000000100000fa8
 usual format on each machine.  output‐format is a
           text  string,  the  name of a particular format supported by the BFD libraries.  (You can list the available binary formats with objdump -i.)  The script command "OUTPUT_FORMAT" can also specify the output format,
           but this option overrides it.

       --out-implib file
           Create an import library in file corresponding to the executable the linker is generating (eg. a DLL or ELF program).  This import library (which should be called "*.dll.a" or "*.a" for DLLs) may be used  to  link
           clients against the generated executable; this behaviour makes it possible to skip a separate import library creation step (eg. "dlltool" for DLLs).  This option is only available for the i386 PE and ELF targetted
           ports of the linker.

       -pie
       --pic-executable
           Create  a  position independent executable.  This is currently only supported on ELF platforms.  Position independent executables are similar to shared libraries in that they are relocated by the dynamic linker to
           the virtual address the OS chooses for them (which can vary between invocations).  Like normal dynamically linked executables they can be executed and symbols defined in the  executable  cannot  be  overridden  by
           shared libraries.

       -no-pie
           Create a position dependent executable.  This is the default.

       -qmagic
           This option is ignored for Linux compatibility.

       -Qy This option is ignored for SVR4 compatibility.

       --relax
       --no-relax
           An option with machine dependent effects.  This option is only supported on a few targets.

           On  some  platforms  the  --relax  option  performs  target  specific, global optimizations that become possible when the linker resolves addressing in the program, such as relaxing address modes, synthesizing new
           instructions, selecting shorter version of current instructions, and combining constant values.

           On some platforms these link time global optimizations may make symbolic debugging of the resulting executable impossible.  This is known to be the case for the Matsushita MN10200 and MN10300 family of processors.

           On platforms where the feature is supported, the option --no-relax will disable it.

           On platforms where the feature is not supported, both --relax and --no-relax are accepted, but ignored.

       --retain-symbols-file=filename
           Retain only the symbols listed in the file filename, discarding all others.  filename is simply a flat file, with one symbol name per line.  This option is especially useful in environments (such as VxWorks) where
           a large global symbol table is accumulated gradually, to conserve run‐time memory.

           --retain-symbols-file does not discard undefined symbols, or symbols needed for relocations.

           You may only specify --retain-symbols-file once in the command line.  It overrides -s and -S.

       -rpath=dir
           Add a directory to the runtime library search path.  This is used when linking an ELF executable with shared objects.  All -rpath arguments are concatenated and passed to the runtime linker,  which  uses  them  to
           locate shared objects at runtime.

           The  -rpath option is also used when locating shared objects which are needed by shared objects explicitly included in the link; see the description of the -rpath-link option.  Searching -rpath in this way is only
           supported by native linkers and cross linkers which have been configured with the --with-sysroot option.

           If -rpath is not used when linking an ELF executable, the contents of the environment variable "LD_RUN_PATH" will be used if it is defined.

           The -rpath option may also be used on SunOS.  By default, on SunOS, the linker will form a runtime search path out of all the -L options it is given.  If a -rpath option

Title: LD (GNU Linker) Options: Position Independent Executables, Relaxation, Symbol Retention, and Runtime Library Search Path
Summary
This section of the LD documentation details several more options, including creating position independent or dependent executables (-pie, --pic-executable, -no-pie), machine-dependent relaxation optimizations (--relax, --no-relax), retaining only specified symbols (--retain-symbols-file), and adding directories to the runtime library search path (-rpath). It also mentions options that are ignored for compatibility reasons (-qmagic, -Qy).