Home Explore Blog CI



man-pages

37th chunk of `ld.man`
6e05eb0999befb15ccc01e2f78a5cb0bce9e0dd80c316e580000000100000faf
 options control how DWARF debug sections are compressed using zlib.

           --compress-debug-sections=none  doesn’t  compress  DWARF  debug  sections.   --compress-debug-sections=zlib-gnu  compresses  DWARF  debug  sections  and  renames  them  to  begin  with  .zdebug  instead of .debug.
           --compress-debug-sections=zlib-gabi also compresses DWARF debug sections, but rather than renaming them it sets the SHF_COMPRESSED flag in the sections’ headers.

           The --compress-debug-sections=zlib option is an alias for --compress-debug-sections=zlib-gabi.

           --compress-debug-sections=zstd compresses DWARF debug sections using zstd.

           Note that this option overrides any compression in input debug sections, so if a binary is linked with --compress-debug-sections=none for example, then  any  compressed  debug  sections  in  input  files  will  be
           uncompressed before they are copied into the output binary.

           The  default  compression  behaviour varies depending upon the target involved and the configure options used to build the toolchain.  The default can be determined by examining the output from the linker’s --help
           option.

       --reduce-memory-overheads
           This option reduces memory requirements at ld runtime, at the expense of linking speed.  This was introduced to select the old O(n^2) algorithm for link map file generation, rather  than  the  new  O(n)  algorithm
           which uses about 40% more memory for symbol storage.

           Another  effect  of the switch is to set the default hash table size to 1021, which again saves memory at the cost of lengthening the linker’s run time.  This is not done however if the --hash-size switch has been
           used.

           The --reduce-memory-overheads switch may be also be used to enable other tradeoffs in future versions of the linker.

       --max-cache-size=size
           ld normally caches the relocation information and symbol tables of input files in memory with the unlimited size.  This option sets the maximum cache size to size.

       --build-id
       --build-id=style
           Request the creation of a ".note.gnu.build-id" ELF note section or a ".buildid" COFF section.  The contents of the note are unique bits identifying this linked file.  style can be "uuid" to use  128  random  bits,
           "sha1" to use a 160-bit SHA1 hash on the normative parts of the output contents, "md5" to use a 128-bit MD5 hash on the normative parts of the output contents, or "0xhexstring" to use a chosen bit string specified
           as an even number of hexadecimal digits ("-" and ":" characters between digit pairs are ignored).  If style is omitted, "sha1" is used.

           The  "md5" and "sha1" styles produces an identifier that is always the same in an identical output file, but will be unique among all nonidentical output files.  It is not intended to be compared as a checksum for
           the file’s contents.  A linked file may be changed later by other tools, but the build ID bit string identifying the original linked file does not change.

           Passing "none" for style disables the setting from any "--build-id" options earlier on the command line.

       --package-metadata=JSON
           Request  the  creation  of  a  ".note.package"  ELF  note  section.   The  contents  of  the  note  are  in  JSON   format,   as   per   the   package   metadata   specification.    For   more   information   see:
           https://systemd.io/ELF_PACKAGE_METADATA/  If  the  JSON argument is missing/empty then this will disable the creation of the metadata note, if one had been enabled by an earlier occurrence of the --package-metdata
           option.  If the linker has been built with libjansson, then the JSON string will be validated.

       The i386 PE linker supports the -shared option, which causes the output to be a dynamically linked library (DLL) instead of a normal executable.  You should

Title: LD (GNU Linker) Options: Debug Compression, Memory Overhead, Build IDs, and Package Metadata
Summary
This section details options for the GNU linker (ld), including: fine-grained control over compression of DWARF debug sections (--compress-debug-sections), reducing memory overhead during linking at the expense of speed (--reduce-memory-overheads), creating build ID notes for identifying linked files (--build-id), and creating package metadata notes in JSON format (--package-metadata).