Home Explore Blog CI



man-pages

24th chunk of `ld.man`
732fc952e7519e64bd76989668a18f8fb769bd5d1820912b0000000100000fac
 linker to be used at load‐time.  This is only meaningful for ELF executables that contain dynamic relocations, and usually requires entry point
           code that is capable of processing these relocations.

       --embedded-relocs
           This option is similar to the --emit-relocs option except that the relocs are stored in a target‐specific section.  This option is only supported by the BFIN, CR16 and M68K targets.

       --disable-multiple-abs-defs
           Do not allow multiple definitions with symbols included in filename invoked by -R or --just-symbols

       --fatal-warnings
       --no-fatal-warnings
           Treat all warnings as errors.  The default behaviour can be restored with the option --no-fatal-warnings.

       -w
       --no-warnings
           Do not display any warning or error messages.  This overrides --fatal-warnings if it has been enabled.  This option can be used when it is known that the output binary will not work, but there is still a  need  to
           create it.

       --force-exe-suffix
           Make sure that an output file has a .exe suffix.

           If  a  successfully built fully linked output file does not have a ".exe" or ".dll" suffix, this option forces the linker to copy the output file to one of the same name with a ".exe" suffix. This option is useful
           when using unmodified Unix makefiles on a Microsoft Windows host, since some versions of Windows won’t run an image unless it ends in a ".exe" suffix.

       --gc-sections
       --no-gc-sections
           Enable garbage collection of unused input sections.  It is ignored on targets that do not support this option.  The default behaviour (of not performing this garbage  collection)  can  be  restored  by  specifying
           --no-gc-sections on the command line.  Note that garbage collection for COFF and PE format targets is supported, but the implementation is currently considered to be experimental.

           --gc-sections decides which input sections are used by examining symbols and relocations.  The section containing the entry symbol and all sections containing symbols undefined on the command‐line will be kept, as
           will  sections containing symbols referenced by dynamic objects.  Note that when building shared libraries, the linker must assume that any visible symbol is referenced.  Once this initial set of sections has been
           determined, the linker recursively marks as used any section referenced by their relocations.  See --entry, --undefined, and --gc-keep-exported.

           This option can be set when doing a partial link (enabled with option -r).  In this case the  root  of  symbols  kept  must  be  explicitly  specified  either  by  one  of  the  options  --entry,  --undefined,  or
           --gc-keep-exported or by a "ENTRY" command in the linker script.

           As a GNU extension, ELF input sections marked with the "SHF_GNU_RETAIN" flag will not be garbage collected.

       --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

Title: LD (GNU Linker) - Options: Dynamic Linker, Relocations, Warnings, Executable Suffix, Garbage Collection, and Output Format
Summary
This section details linker options including omitting the dynamic linker (--no-dynamic-linker), specifying the storage of relocations (--embedded-relocs), disabling multiple absolute definitions (--disable-multiple-abs-defs), managing warnings (--fatal-warnings, --no-fatal-warnings, -w, --no-warnings), forcing an executable suffix (--force-exe-suffix), enabling garbage collection of unused sections (--gc-sections, --no-gc-sections, --print-gc-sections, --no-print-gc-sections, --gc-keep-exported), and printing the output format (--print-output-format).