Home Explore Blog CI



man-pages

25th chunk of `ld.man`
39fd3a97552e3dcc286c7a1c3716e415e5e728b70479b45c0000000100000fa6
 --print-gc-sections
       --no-print-gc-sections
           List  all  sections removed by garbage collection.  The listing is printed on stderr.  This option is only effective if garbage collection has been enabled via the --gc-sections) option.  The default behaviour (of
           not listing the sections that are removed) can be restored by specifying --no-print-gc-sections on the command line.

       --gc-keep-exported
           When --gc-sections is enabled, this option prevents garbage collection of unused input sections that contain global symbols having default or  protected  visibility.   This  option  is  intended  to  be  used  for
           executables where unreferenced sections would otherwise be garbage collected regardless of the external visibility of contained symbols.  Note that this option has no effect when linking shared objects since it is
           already the default behaviour.  This option is only supported for ELF format targets.

       --print-output-format
           Print the name of the default output format (perhaps influenced by other command‐line options).  This is the string that would appear in an "OUTPUT_FORMAT" linker script command.

       --print-memory-usage
           Print  used  size,  total  size and used size of memory regions created with the MEMORY command.  This is useful on embedded targets to have a quick view of amount of free memory.  The format of the output has one
           headline and one line per region.  It is both human readable and easily parsable by tools.  Here is an example of an output:

                   Memory region         Used Size  Region Size  %age Used
                                ROM:        256 KB         1 MB     25.00%
                                RAM:          32 B         2 GB      0.00%

       --help
           Print a summary of the command‐line options on the standard output and exit.

       --target-help
           Print a summary of all target‐specific options on the standard output and exit.

       -Map=mapfile
           Print a link map to the file mapfile.  See the description of the -M option, above.  If mapfile is just the character "-" then the map will be written to stdout.

           Specifying a directory as mapfile causes the linker map to be written as a file inside the directory.  Normally name of the file inside the directory is computed as the basename of  the  output  file  with  ".map"
           appended.    If  however the special character "%" is used then this will be replaced by the full path of the output file.  Additionally if there are any characters after the % symbol then ".map" will no longer be
           appended.

                    -o foo.exe -Map=bar                  [Creates ./bar]
                    -o ../dir/foo.exe -Map=bar           [Creates ./bar]
                    -o foo.exe -Map=../dir               [Creates ../dir/foo.exe.map]
                    -o ../dir2/foo.exe -Map=../dir       [Creates ../dir/foo.exe.map]
                    -o foo.exe -Map=%                    [Creates ./foo.exe.map]
                    -o ../dir/foo.exe -Map=%             [Creates ../dir/foo.exe.map]
                    -o foo.exe -Map=%.bar                [Creates ./foo.exe.bar]
                    -o ../dir/foo.exe -Map=%.bar         [Creates ../dir/foo.exe.bar]
                    -o ../dir2/foo.exe -Map=../dir/%     [Creates ../dir/../dir2/foo.exe.map]
                    -o ../dir2/foo.exe -Map=../dir/%.bar [Creates ../dir/../dir2/foo.exe.bar]

           It is an error to specify more than one "%" character.

           If the map file already exists then it will be overwritten by this operation.

       --no-keep-memory
           ld normally optimizes for speed over memory usage by caching the symbol tables of input files in memory.  This option tells ld to instead optimize for memory usage, by rereading the  symbol  tables  as  necessary.
           This may be required if ld runs out of memory

Title: LD (GNU Linker) - Options: Garbage Collection Listing, Exported Symbols, Output Format, Memory Usage, Help, Map File, and Memory Optimization
Summary
This section of the GNU linker documentation covers options for listing sections removed by garbage collection (--print-gc-sections, --no-print-gc-sections), preventing garbage collection of exported symbols (--gc-keep-exported), printing the default output format (--print-output-format), printing memory usage statistics (--print-memory-usage), displaying help messages (--help, --target-help), creating a link map file (-Map=mapfile), and optimizing for memory usage instead of speed (--no-keep-memory).