Home Explore Blog CI



man-pages

9th chunk of `ld.man`
f01fdb0a6fcea09c0421731d1f9c79229332edad5446b0650000000100000fac
 --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 is position dependent and only affects filenames that come after it on the command line.  Thus:

                     ld foo.o --remap-inputs=foo.o=bar.o

           Will have no effect, whereas:

                     ld --remap-inputs=foo.o=bar.o foo.o

           Will rename the input file foo.o to bar.o.

           Note - these options also affect files referenced by INPUT statements in linker scripts.  But since linker scripts are processed after the entire command line is read, the position of  the  remap  options  on  the
           command line is not significant.

           If the verbose option is enabled then any mappings that match will be reported, although again the verbose option needs to be enabled on the command line before the remaped filenames appear.

           If the -Map or --print-map options are enabled then the remapping list will be included in the map output.

       -M
       --print-map
           Print a link map to the standard output.  A link map provides information about the link, including the following:

           •   Where object files are mapped into memory.

           •   How common symbols are allocated.

           •   All archive members included in the link, with a mention of the symbol which caused the archive member to be brought in.

           •   The values assigned to symbols.

               Note  -  symbols  whose values are computed by an expression which involves a reference to a previous value of the same symbol may not have correct result displayed in the link map.  This is because the linker
               discards intermediate results and only retains the final value of an expression.  Under such circumstances the linker will display the final value enclosed by square brackets.  Thus for example a linker script
               containing:

                          foo = 1
                          foo = foo * 4
                          foo = foo + 8

               will produce the following output in the link map if the -M option is used:

                          0x00000001                foo = 0x1
                          [0x0000000c]                foo = (foo * 0x4)
                          [0x0000000c]                foo = (foo + 0x8)

               See Expressions for more information about expressions in linker scripts.

           •   How GNU properties are merged.

               When the linker merges input .note.gnu.property sections into one output .note.gnu.property section, some properties are removed or updated.  These actions are reported in the link map.  For example:

                       Removed property 0xc0000002 to merge foo.o (0x1) and bar.o (not found)

               This indicates that property 0xc0000002 is removed from output when merging properties in  foo.o, whose property 0xc0000002 value is 0x1, and bar.o, which doesn’t have property 0xc0000002.

                       Updated property 0xc0010001 (0x1) to merge foo.o (0x1) and bar.o (0x1)

     

Title: LD (GNU Linker) - Input Remapping Details and Link Maps
Summary
This section elaborates on the `--remap-inputs` and `--remap-inputs-file` options, highlighting their command-line position dependence and effects on linker scripts. It also describes the `-M` and `--print-map` options, which generate a link map to standard output. The link map contains information about memory mapping, symbol allocation, archive members, symbol values, and GNU property merging.