Home Explore Blog CI



man-pages

8th chunk of `ld.man`
b66572104ee84bc94354ed83eef8cc2bf15c8180e4efaf2c0000000100000fa1
 a ".so" extension indicates a shared library.)  Note that this behavior does not apply to :filename, which always specifies a file called filename.

           The  linker will search an archive only once, at the location where it is specified on the command line.  If the archive defines a symbol which was undefined in some object which appeared before the archive on the
           command line, the linker will include the appropriate file(s) from the archive.  However, an undefined symbol in an object appearing later on the command line will not cause the linker to search the archive again.

           See the -( option for a way to force the linker to search archives multiple times.

           You may list the same archive multiple times on the command line.

           This type of archive searching is standard for Unix linkers.  However, if you are using ld on AIX, note that it is different from the behaviour of the AIX linker.

       -L searchdir
       --library-path=searchdir
           Add path searchdir to the list of paths that ld will search for archive libraries and ld control scripts.  You may use this option any number of times.  The directories are searched in the order in which they  are
           specified  on the command line.  Directories specified on the command line are searched before the default directories.  All -L options apply to all -l options, regardless of the order in which the options appear.
           -L options do not affect how ld searches for a linker script unless -T option is specified.

           If searchdir begins with "=" or $SYSROOT, then this prefix will be replaced by the sysroot prefix, controlled by the --sysroot option, or specified when the linker is configured.

           The default set of paths searched (without being specified with -L) depends on which emulation mode ld is using, and in some cases also on how it was configured.

           The paths can also be specified in a link script with the "SEARCH_DIR" command.  Directories specified this way are searched at the point in which the linker script appears in the command line.

       -m emulation
           Emulate the emulation linker.  You can list the available emulations with the --verbose or -V options.

           If the -m option is not used, the emulation is taken from the "LDEMULATION" environment variable, if that is defined.

           Otherwise, the default emulation depends upon how the linker was configured.

       --remap-inputs=pattern=filename
       --remap-inputs-file=file
           These options allow the names of input files to be changed before the linker attempts to open them.  The option --remap-inputs=foo.o=bar.o will cause any attempt to load a file called foo.o to instead try to  load
           a file called bar.o.  Wildcard patterns are permitted in the first filename, so --remap-inputs=foo*.o=bar.o will rename any input file that matches foo*.o to bar.o.

           An  alternative  form of the option --remap-inputs-file=filename allows the remappings to be read from a file.  Each line in the file can contain a single remapping.  Blank lines are ignored.  Anything from a hash
           character (#) to the end of a line is considered to be a comment and is also ignored.  The mapping pattern can be separated from the filename by whitespace or an equals (=) character.

           The options can be specified multiple times.  Their contents accumulate.  The remappings will be processed in the order in which they occur on the command line, and if they come from a file, in the order in  which
           they occur in the file.  If a match is made, no further checking for that filename will be performed.

           If  the  replacement  filename is /dev/null or just NUL then the remapping will actually cause the input file to be ignored.  This can be a convenient way to experiment with removing input files from a complicated
           build environment.

           Note that this option

Title: LD (GNU Linker) - Library Paths, Emulation, and Input Remapping
Summary
This section describes the `-L` (library path), `-m` (emulation), `--remap-inputs` and `--remap-inputs-file` options for the GNU linker (ld). `-L` adds directories to the library search path. `-m` sets the linker emulation. `--remap-inputs` remaps input file names, allowing for file substitutions or ignoring files via /dev/null.