LD(1) GNU Development Tools LD(1) (NAME) ld - (The GNU linker) (SYNOPSIS) ld [options] objfile ... (DESCRIPTION) ld . ld . ld << >> (Linker Command Language) << AT&T>> . ld "info" . ld BFD . ld --- COFF "a.out". . . ld ( ). ld . . (OPTIONS) . ld . "hello.o": ld -o /lib/crt0.o hello.o -lc ld output "/lib/crt0.o" "hello.o" "libc.a" ( ) . ( -l .) ld . -l -T . ( ) . . . . -l -R . No input files . . ( -T ) . "INPUT" "GROUP" . -T "INSERT" . . -trace-symbol --trace-symbol . --- . 'o' . -o . -omagic magic --omagic NMAGIC . . --trace-symbol foo --trace-symbol=foo . . --- ( gcc) -Wl, ( ) : gcc -Wl,--start-group foo.o bar.o -Wl,--end-group . . : gcc foo.o bar.o -Wl,-eENTRY -Wl,-Map=a.map : @file file . @file . file . file (whitespace) . . ( ) . file @file . -a keyword HP/UX . keyword archive shared default . -aarchive -Bstatic -Bdynamic . . --audit AUDITLIB AUDITLIB "DT_AUDIT" . AUDITLIB DT_SONAME . "DT_AUDIT" . "DT_DEPAUDIT" . ELF rtld-audit . -b input-format --format=input-format ld . ld -b . ld ld . input-format BFD . ( objdump -i .) . -b ( ) -b input-format . "GNUTARGET" . "TARGET" -c MRI-commandfile --mri-script=MRI-commandfile MRI ld << MRI (MRI Compatible Script Files)>> GNU ld . MRI -c -T ld . MRI-cmdfile ld -L . -d -dc -dp . ( -r) . "FORCE_COMMON_ALLOCATION" . --depaudit AUDITLIB -P AUDITLIB AUDITLIB "DT_DEPAUDIT" . AUDITLIB DT_SONAME . "DT_DEPAUDIT" . ELF rtld-audit . -P Solaris . --enable-linker-version "LINKER_VERSION" (Output Section Data) . . - . . --disable-linker-version "LINKER_VERSION" . . --enable-non-contiguous-regions . . . : MEMORY { MEM1 (rwx) : ORIGIN = 0x1000, LENGTH = 0x14 MEM2 (rwx) : ORIGIN = 0x1000, LENGTH = 0x40 MEM3 (rwx) : ORIGIN = 0x2000, LENGTH = 0x40 } SECTIONS { mem1 : { *(.data.*); } > MEM1 mem2 : { *(.data.*); } > MEM2 mem3 : { *(.data.*); } > MEM3 } with input sections: .data.1: size 8 .data.2: size 0x10 .data.3: size 4 results in .data.1 affected to mem1, and .data.2 and .data.3 affected to mem2, even though .data.3 would fit in mem3. INSERT . --enable-non-contiguous-regions-warnings "--enable-non-contiguous-regions" . -e entry --entry=entry entry . entry entry ( 0x 0 ). i386 PE entry ( / stdcall @number ). --exclude-libs lib,lib,... . . "--exclude-libs ALL" . ELF PE . PE .def . ELF (hidden) . --exclude-modules-for-implib module,module,... . ld . .def . [ PE ] -E --export-dynamic --no-export-dynamic -E --export-dynamic . . ( --no-export-dynamic ) . "dlopen" . . --dynamic-list . ELF . PE DLL EXE --export-all-symbols . --export-dynamic-symbol=glob glob . glob . -Bsymbolic --dynamic-list . ELF . --export-dynamic-symbol-list=file --export-dynamic-symbol . . VERSION . -EB (big-endian). . -EL (little-endian). . -f name --auxiliary=name ELF DT_AUXILIARY . name . DT_AUXILIARY . name . . name name . . DT_AUXILIARY . -F name --filter=name ELF DT_FILTER . name . DT_FILTER . name . name . -F . GNU : -b --format --oformat "TARGET" "GNUTARGET". GNU ELF -F . -fini=name ELF DT_FINI NAME . "_fini" . -g . . -G value --gpsize=value GP size . MIPS ELF . . -h name -soname=name ELF DT_SONAME . DT_SONAME DT_SONAME . -i (incremental link) ( -r). -init=name ELF DT_INIT NAME . "_init" . -l namespec --library=namespec namespec . . namespec :filename ld filename libnamespec.a . ld libnamespec.a . ELF SunOS ld libnamespec.a libnamespec.so ( ".so" ). :filename filename . . () . . -( . . Unix . ld AIX AIX . -L searchdir --library-path=searchdir searchdir ld ld . . . . -L -l . -L ld -T . searchdir "=" $SYSROOT sysroot prefix --sysroot . ( -L) ld . "SEARCH_DIR" . . -m emulation emulation . --verbose -V . -m "LDEMULATION" . . --remap-inputs=pattern=filename --remap-inputs-file=file . --remap-inputs=foo.o=bar.o foo.o bar.o . (wildcard) --remap-inputs=foo*.o=bar.o foo*.o bar.o . --remap-inputs-file=filename . . . (#) . (=) . . . . . /dev/null NUL . . . : ld foo.o --remap-inputs=foo.o=bar.o : ld --remap-inputs=foo.o=bar.o foo.o foo.o bar.o . - INPUT . . verbose verbose . -Map --print-map . -M --print-map (link map) . : o . o (common symbols). o . o . - . . . : foo = 1 foo = foo * 4 foo = foo + 8 -M : 0x00000001 foo = 0x1 [0x0000000c] foo = (foo * 0x4) [0x0000000c] foo = (foo + 0x8) Expressions . o GNU. .note.gnu.property .note.gnu.property . . : Removed property 0xc0000002 to merge foo.o (0x1) and bar.o (not found) 0xc0000002 foo.o 0xc0000002 0x1 bar.o 0xc0000002 . Updated property 0xc0010001 (0x1) to merge foo.o (0x1) and bar.o (0x1) 0xc0010001 foo.o 0xc0010001 0x1 bar.o 0xc0010001 0x1 0x1 . o ELF (fixups) --relax foo.o: Adjusting branch at 0x00000008 towards "far" in section .text 0x00000008 foo.o "far" .text . --print-map-discarded --no-print-map-discarded ( ) . . --print-map-locals --no-print-map-locals ( ) . (local) . ( .L ) . . -n --nmagic . "NMAGIC" . -N --omagic text data . . "OMAGIC" . : text PE-COFF . --no-omagic -N . text . - . -Bdynamic . -o output --output=output output ld a.out . "OUTPUT" . - . . - . . -o . : ld -o $(EXE) $(OBJS) ld $(OBJS) -o $(EXE) EXE ( OBJS) . --dependency-file=depfile dependency file ( ) depfile. "make" . -M -MP . -MM << >> ( << >> ) . --dependency-file makefile . -O level level ld . . ELF . . . . level fast ld . . level default - . -plugin name . name . . ar nm ranlib . ${libdir}/bfd-plugins . gcc . --push-state --push-state --pop-state . : -Bdynamic -Bstatic -dn -dy -call_shared -non_shared -static -N -n --whole-archive --no-whole-archive --link-mapless --no-link-mapless -r -Ur --copy-dt-needed-entries --no-copy-dt-needed-entries --as-needed --no-as-needed -a. pkg-config . --libs . : -Wl,--push-state,--as-needed -libone -libtwo -Wl,--pop-state --pop-state --push-state . -q --emit-relocs (relocation) . . . ELF . --force-dynamic (dynamic sections) . VxWorks . -r --relocatable --- ld . (partial linking) . "OMAGIC" . (absolute) . C++ (constructors) -Ur . . "a.out" . (LTO) LTO .gnu_object_only -r LTO . .gnu_object_only .gnu_object_only . -r (locality) . -i . -R filename --just-symbols=filename filename . . . ELF -R -rpath . --rosegment --no-rosegment . -z separate-code . -z separate-code . --no-rosegment -z separate-code . LLD GOLD . ELF . -s --strip-all . -S --strip-debug ( ) . --strip-discarded --no-strip-discarded ( ) . . -plugin-save-temps "" . -t --trace ld. -t . -t . -T scriptfile --script=scriptfile scriptfile . ld ( ) "INSERT" commandfile . scriptfile "ld" -L . -T . -T -T . . -dT scriptfile --default-script=scriptfile scriptfile . --script . --default-script ( gcc) . -u symbol --undefined=symbol symbol . . -u . "EXTERN" . --require-defined . --require-defined=symbol symbol . --undefined symbol . "EXTERN" "ASSERT" "DEFINED" . . -Ur (constructors) (destructors) ELF -r : (relocatable) --- ld . -Ur -r . -r -Ur -Ur -Ur . -Ur -r . --orphan-handling=MODE (orphan sections). . MODE : "place" (Orphan Sections) . --unique . "discard" /DISCARD/ . "warn" "place" . "error" . --orphan-handling "place" . --unique[=SECTION] SECTION SECTION . . . -v --version -V ld . -V . --enable-linker-version Options,,Command-line Options . -x --discard-all . -X --discard-locals . ( .L ELF L a.out.) -y symbol --trace-symbol=symbol symbol . . (underscore) . . -Y path path . Solaris . -z keyword : call-nop=prefix-addr call-nop=suffix-nop call-nop=prefix-byte call-nop=suffix-byte (padding) - "NOP" foo GOT . call-nop=prefix-addr "0x67 call foo" . call-nop=suffix-nop "call foo 0x90" . call-nop=prefix-byte "byte call foo" . call-nop=suffix-byte "call foo byte" . i386 x86_64 . cet-report=none cet-report=warning cet-report=error GNU_PROPERTY_X86_FEATURE_1_IBT GNU_PROPERTY_X86_FEATURE_1_SHSTK .note.gnu.property . cet-report=none . cet-report=warning . cet-report=error . ibt GNU_PROPERTY_X86_FEATURE_1_IBT shstk GNU_PROPERTY_X86_FEATURE_1_SHSTK . Linux/i386 Linux/x86_64 . combreloc nocombreloc . nocombreloc . common nocommon STT_COMMON . nocommon STT_OBJECT . common-page-size=value value. . defs . . -z undefs . dynamic-undefined-weak nodynamic-undefined-weak . nodynamic-undefined-weak . . . execstack . global . . globalaudit . "DF_1_GLOBAUDIT" "DT_FLAGS_1" . --depaudit -P . ibtplt PLT (IBT) . Linux/i386 Linux/x86_64 . ibt GNU_PROPERTY_X86_FEATURE_1_IBT .note.gnu.property IBT. ibtplt . Linux/i386 Linux/x86_64 . indirect-extern-access noindirect-extern-access GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS .note.gnu.property . noextern-protected-data nocopyreloc . i386 x86-64 . noindirect-extern-access GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS .note.gnu.property . initfirst . . . interpose (interpose) . unique nounique ELF ( ) ( "dlmopen") . libc libpthread . "dlmopen" ( ) . lam-u48 GNU_PROPERTY_X86_FEATURE_1_LAM_U48 .note.gnu.property Intel LAM_U48. Linux/x86_64 . lam-u57 GNU_PROPERTY_X86_FEATURE_1_LAM_U57 .note.gnu.property Intel LAM_U57. Linux/x86_64 . lam-u48-report=none lam-u48-report=warning lam-u48-report=error GNU_PROPERTY_X86_FEATURE_1_LAM_U48 .note.gnu.property. lam-u48-report=none . lam-u48-report=warning . lam-u48-report=error . Linux/x86_64 . lam-u57-report=none lam-u57-report=warning lam-u57-report=error GNU_PROPERTY_X86_FEATURE_1_LAM_U57 .note.gnu.property. lam-u57-report=none . lam-u57-report=warning . lam-u57-report=error . Linux/x86_64 . lam-report=none lam-report=warning lam-report=error GNU_PROPERTY_X86_FEATURE_1_LAM_U48 GNU_PROPERTY_X86_FEATURE_1_LAM_U57 .note.gnu.property. lam-report=none . lam-report=warning . lam-report=error . Linux/x86_64 . lazy ( ) . . loadfltr . max-page-size=value value. mark-plt nomark-plt PLT DT_X86_64_PLT DT_X86_64_PLTSZ DT_X86_64_PLTENT. r_addend R_X86_64_JUMP_SLOT glibc r_addend R_X86_64_GLOB_DAT R_X86_64_JUMP_SLOT r_addend R_X86_64_JUMP_SLOT . x86_64 . muldefs . nocopyreloc .dynbss . . nodefaultlib . nodelete . nodlopen "dlopen" . nodump "dldump" (dump) . noexecstack . noextern-protected-data . . . . i386 x86-64 . noreloc-overflow . . x86_64 . memory-seal nomemory-seal PT_LOAD ( ) . . GNU_PROPERTY_MEMORY_SEAL .note.gnu.property now dlopen . origin $ORIGIN . pack-relative-relocs nopack-relative-relocs . "DT_RELR" "DT_RELRSZ" "DT_RELRENT" . . nopack-relative-relocs . C GLIBC_ABI_DT_RELR C . i386 x86-64 . relro norelro "PT_GNU_RELRO" ELF . . common-page-size . norelro "PT_GNU_RELRO" . report-relative-reloc . Linux/i386 Linux/x86_64 . sectionheader nosectionheader . nosectionheader . sectionheader . separate-code noseparate-code "PT_LOAD" . . noseparate-code "PT_LOAD" . shstk GNU_PROPERTY_X86_FEATURE_1_SHSTK .note.gnu.property (Intel Shadow Stack). Linux/i386 Linux/x86_64 . stack-size=value "PT_GNU_STACK" ELF. "PT_GNU_STACK" . start-stop-gc nostart-stop-gc --gc-sections "__start_SECNAME" "__stop_SECNAME" "SECNAME" "SECNAME" C "__start_SECNAME" "__stop_SECNAME" . -z start-stop-gc () . -z start-stop-gc "__start_SECNAME" "__stop_SECNAME" . "__start_SECNAME" "__stop_SECNAME" . start-stop-visibility=value ELF "__start_SECNAME" "__stop_SECNAME". value default internal hidden protected . -z start-stop-visibility protected . -z start-stop-visibility=hidden . text notext textoff DT_TEXTREL . notext textoff . undefs . -z defs . unique-symbol nounique-symbol . unique-symbol "."number"" . nounique-symbol . x86-64-baseline x86-64-v2 x86-64-v3 x86-64-v4 ISA x86-64 .note.gnu.property. x86-64-baseline "GNU_PROPERTY_X86_ISA_1_BASELINE" . x86-64-v2 "GNU_PROPERTY_X86_ISA_1_V2" . x86-64-v3 "GNU_PROPERTY_X86_ISA_1_V3" . x86-64-v4 "GNU_PROPERTY_X86_ISA_1_V4" . Linux/i386 Linux/x86_64 . isa-level-report=none isa-level-report=all isa-level-report=needed isa-level-report=used ISA x86-64 . isa-level-report=none ISA x86-64 . isa-level-report=all ISA x86-64 . isa-level-report=needed ISA x86-64 . isa-level-report=used ISA x86-64 . Linux/i386 Linux/x86_64 . Solaris . --gnu-tls-tag --no-gnu-tls-tag "GLIBC_ABI_GNU_TLS" glibc "___tls_get_addr" . glibc "GLIBC_ABI_GNU_TLS" . --disable-gnu-tls-tag "___tls_get_addr" libc.so "GLIBC_ABI_GNU_TLS" "GLIBC_ABI_GNU_TLS" . Linux/i386 . --gnu2-tls-tag --no-gnu2-tls-tag "GLIBC_ABI_GNU2_TLS" glibc "R_386_TLS_DESC_CALL" "R_X86_64_TLSDESC_CALL" . glibc "GLIBC_ABI_GNU2_TLS" . --disable-gnu2-tls-tag "R_386_TLS_DESC_CALL" "R_X86_64_TLSDESC_CALL" libc.so "GLIBC_ABI_GNU2_TLS" "GLIBC_ABI_GNU2_TLS" . Linux/i386 Linux/x86_64 . -( archives -) --start-group archives --end-group archives . -l . . . . . --start-lib/--end-lib . . . --start-lib objects --end-lib objects . --start-lib . . . . --start-lib --end-lib . : -(/--start-group -)/--end-group --whole-archive --no-whole-archive --pop-state --whole-archive . --accept-unknown-input-arch --no-accept-unknown-input-arch . . 2.14 . 2.14 --accept-unknown-input-arch . --as-needed --no-as-needed DT_NEEDED ELF --as-needed . DT_NEEDED . --as-needed DT_NEEDED (non-weak) DT_NEEDED . . . --no-as-needed . : --as-needed --rpath --rpath-link . --rpath-link . --add-needed --no-add-needed --as-needed --no-as-needed . --copy-dt-needed-entries --no-copy-dt-needed-entries . -assert keyword SunOS . -Bdynamic -dy -call_shared . . . . : -l . -Bgroup "DF_1_GROUP" "DT_FLAGS_1" . . --unresolved-symbols=report-all . ELF . -Bstatic -dn -non_shared -static . . . : -l . --unresolved-symbols=report-all . -shared . . -Bsymbolic . . ELF . -Bsymbolic-functions . ELF . -Bno-symbolic -Bsymbolic -Bsymbolic-functions . --dynamic-list=dynamic-list-file . . ELF . . VERSION . --dynamic-list-data . --dynamic-list-cpp-new new delete ++C. libstdc++ . --dynamic-list-cpp-typeinfo ++C. --check-sections --no-check-sections . . (overlays) . --check-sections . (relocatable) . --check-sections . --copy-dt-needed-entries --no-copy-dt-needed-entries DT_NEEDED ELF . DT_NEEDED DT_NEEDED . --copy-dt-needed-entries DT_NEEDED . --no-copy-dt-needed-entries . . --copy-dt-needed-entries DT_NEEDED . . DT_NEEDED . --cref . (map file) . . . . . . (common value) . . --ctf-variables --no-ctf-variables CTF . : . --ctf-variables . --no-ctf-variables . --ctf-share-types=method CTF. share-unconflicted . . share-duplicated : . . CTF CTF . CTF CTF . --no-define-common (Common) . "INHIBIT_COMMON_ALLOCATION" . --no-define-common Common (non-Relocatable) Common . --no-define-common Common . . --force-group-allocation (section group) . (-r) . "FORCE_GROUP_ALLOCATION" . --defsym=symbol=expression expression . . expression : "+" "-" . . : symbol ("=") expression . --defsym -T --defsym -T -T --defsym -T . --defsym . --demangle[=style] --no-demangle (demangle) . : C++ (mangled) . (mangling) . . COLLECT_NO_DEMANGLE . . -Ifile --dynamic-linker=file . ELF . . --no-dynamic-linker . ELF . --embedded-relocs --emit-relocs . BFIN CR16 M68K . --disable-multiple-abs-defs -R --just-symbols . --fatal-warnings --no-fatal-warnings . --no-fatal-warnings . -w --no-warnings . --fatal-warnings . . --force-exe-suffix .exe . ".exe" ".dll" ".exe" . makefile ".exe" . --gc-sections --no-gc-sections () . . ( ) --no-gc-sections . COFF PE . --gc-sections . . . . --entry --undefined --gc-keep-exported . ( -r) . --entry --undefined --gc-keep-exported "ENTRY" . GNU ELF "SHF_GNU_RETAIN" . --print-gc-sections --no-print-gc-sections . stderr . --gc-sections . ( ) --no-print-gc-sections . --gc-keep-exported --gc-sections (visibility) . . . ELF . --print-output-format ( ). "OUTPUT_FORMAT" . --print-memory-usage MEMORY. . . . : Memory region Used Size Region Size %age Used ROM: 256 KB 1 MB 25.00% RAM: 32 B 2 GB 0.00% : --stats . --help . --target-help (target-specific) . -Map=mapfile mapfile. -M . mapfile "-" stdout . mapfile . (basename) output ".map" . "%" . % ".map" . -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] "%" . . --no-keep-memory ld . ld . ld . --no-undefined -z defs . (non-symbolic) . --[no-]allow-shlib-undefined . "-z undefs" . --allow-multiple-definition -z muldefs . . --allow-shlib-undefined --no-allow-shlib-undefined . --no-undefined . . . : o . o BeOS HPPA . BeOS . memset . --error-handling-script=scriptname scriptname . : . : "undefined-symbol" `missing-lib" name . . . (configure time switch) . --no-undefined-version . . --default-symver ( soname) . --default-imported-symver ( soname) . --no-warn-mismatch ( (endianness) ) ld . ld . . --no-warn-search-mismatch ld . . --no-whole-archive --whole-archive . --start-lib/--end-lib . --no-link-mapless . . . --noinhibit-exec . . -nostdlib . ( ) . --oformat=output-format ld . ld --oformat . ld ld . output-format BFD . ( objdump -i .) "OUTPUT_FORMAT" . --out-implib file (import library) file ( DLL ELF). ( DLL "*.dll.a" "*.a" ) ( "dlltool" DLL) . PE ELF . -pie --pic-executable (position independent executable). ELF . (relocate) . ELF ET_DYN . PIE (override) . -no-pie (position dependent executable). . -qmagic . -Qy SVR4 . --relax --no-relax . . --relax . . Matsushita MN10200 MN10300 . --no-relax . --relax --no-relax . --retain-symbols-file=filename filename . filename . ( VxWorks) . --retain-symbols-file . --retain-symbols-file . -s -S . -rpath=dir . ELF . -rpath . -rpath -rpath-link . -rpath (native) (cross) --with-sysroot . ELF -rpath "LD_RUN_PATH" . -rpath SunOS . SunOS -L . -rpath -rpath -L . gcc -L NFS . ELF -R -rpath . -rpath-link=dir ELF SunOS . "ld -shared" . . . -rpath-link . . $ORIGIN $LIB . $ORIGIN $LIB lib - - lib64 - - . - ${ORIGIN} ${LIB} . $PLATFORM . --rpath-link . . . . -l . -l -L . 1. -rpath-link. 2. -rpath. -rpath -rpath-link -rpath -rpath-link . -rpath --with-sysroot . 3. ELF -rpath -rpath-link "LD_RUN_PATH" . 4. SunOS -rpath -L . 5. "LD_LIBRARY_PATH" . 6. ELF "DT_RUNPATH" "DT_RPATH" . "DT_RUNPATH" "DT_RPATH" . 7. /etc/ld.so.conf . : "sysroot" ( ) "prefix" --prefix= . 8. FreeBSD "_PATH_ELF_HINTS" elf-hints.h . 9. "SEARCH_DIR" -T ( -dT). 10. /lib /usr/lib. 11. LDPT_SET_EXTRA_LIBRARY_PATH. 12. "SEARCH_DIR" . : --as-needed DT_NEEDED libc.so DT_NEEDED libc.so . . --section-ordering-file=script . "SECTIONS" . @pxref{SECTIONS} . ( ). . : SECTIONS { .text : { *(.text.hot) ; *(.text .text.*) } .data : { *(.data.big) ; *(.data .data.*) } } : .text : { *(.text.first) ; *(.text.z*) } .data : { foo.o(.data.first) ; *(.data.small) } : SECTIONS { .text : { *(.text.first) ; *(.text.z*) ; *(.text.hot) ; *(.text .text.*) } .data : { foo.o(.data.first) ; *(.data.small) ; *(.data.big) ; *(.data .data.*) } } . -shared -Bshareable (shared library) . ELF XCOFF SunOS . SunOS -e . --sort-common --sort-common=ascending --sort-common=descending ld (common symbols) (alignment) . . . . --sort-section=name "SORT_BY_NAME" (wildcard) . --sort-section=alignment "SORT_BY_ALIGNMENT" (wildcard) . --spare-dynamic-tags=count (slots) .dynamic ELF . (prelinker) . . --split-by-file[=size] --split-by-reloc size . size . --split-by-reloc[=count] count (relocation) . (real time) COFF COFF . . count . count . --stats[=filename] . filename . filename . filename - . filename + (append mode) . -Map (map file) . : --stats -Map filename . "LD_STATS" --stats . . . . : --stats --stats . (cpu time) getrusage() (resident set size) . mallinfo mallinfo2 . (phases) . . ALL . . . : Stats: linker version: (GNU Binutils) 2.44.50.20250401 Stats: linker started: Wed Apr 2 09:36:41 2025 Stats: args: ld -z norelro -z nomemory-seal -z no-separate-code -o a.out [...] Stats: phase cpu time rss user time system time memory Stats: name (microsec) (KiB) (seconds) (seconds) (KiB) Stats: ALL 390082 217740 0 0 25219440 Stats: ctf processing 12 0 0 0 0 Stats: string merge 1324 0 0 0 406544 Stats: parsing 349 288 0 0 119792 Stats: plugins 1 0 0 0 0 Stats: processing files 259616 214524 0 0 31569120 Stats: write 116493 0 0 0 48096 --no-stats --stats LD_STATS . --sysroot=directory directory sysroot (configure-time) . --with-sysroot . --task-link COFF/PE task-linked (static) . --traditional-format ld . ld (traditional format) . SunOS ld . . "dbx" SunOS ( "gdb" ). --traditional-format ld . --section-start=sectionname=org org . . org 0x . : (white space) sectionname ("=") org . --image-base=org ELF -Ttext-segment ELF . PE value dll . dll . dll dll . 0x400000 dll 0x10000000 . -Tbss=org -Tdata=org -Ttext=org --section-start ".bss" ".data" ".text" sectionname. -Ttext-segment=org ELF . -pie -Ttext-segment=org ET_EXEC org . -Trodata-segment=org ELF . -Tldata-segment=org ELF x86-64 ldata . --unresolved-symbols=method . method : ignore-all . report-all . . ignore-in-object-files . ignore-in-shared-libs . . --[no-]allow-shlib-undefined . --warn-unresolved-symbols . --dll-verbose --verbose[=NUMBER] ld . . . NUMBER (plugin) . --version-script=version-scriptfile (version script) . . ELF (VERSION) . PE (auto-export) : local . --warn-common (common symbol) . . . C . C : int i = 1; (initialized data) . extern int i; . . int i; . ( ) (uninitialized data) . . . . --warn-common . : . . 1. . (
): warning: common of `' overridden by definition (
): warning: defined here 2. . . (
): warning: definition of `' overriding common (
): warning: common is here 3. . (
): warning: multiple common of `' (
): warning: previous common is here 4. . (
): warning: common of `' overridden by larger common (
): warning: larger common is here 5. . . (
): warning: common of `' overriding smaller common (
): warning: smaller common is here --warn-constructors (global constructors) . . COFF ELF . --warn-execstack --warn-execstack-objects --no-warn-execstack ELF (executable stack) . : 1. . 2. -z execstack . 3. -z execstack . . --no-warn-execstack . --warn-execstack . --warn-execstack-objects . : ELF .note.GNU-stack . . .note.GNU-stack (target) . . . --error-execstack --no-error-execstack --error-execstack . . --warn-execstack --warn-execstack-objects . --no-error-execstack . --warn-multiple-gp (global pointer) . Alpha . . ( global pointer) (base-register relative) . ( ) (constant pool) . . . --warn-once . --warn-rwx-segments --no-warn-rwx-segments . . (TLS) . . --no-warn-rwx-segments --warn-rwx-segments . --error-rwx-segments --no-error-rwx-segments TLS --error-rwx-segments . --no-error-rwx-segments . - --error-rwx-segments . --warn-rwx-segments . --warn-section-align . . "SECTIONS" . --warn-textrel DT_TEXTREL . --warn-alternate-em ELF . --warn-unresolved-symbols ( --unresolved-symbols ) . . --error-unresolved-symbols . --whole-archive --whole-archive . . . --start-lib/--end-lib . gcc: gcc -Wl,-whole-archive . -Wl,-no-whole-archive gcc . --link-mapless ( ) . . . --wrap=symbol symbol. symbol "__wrap_symbol" . "__real_symbol" symbol . . "__wrap_symbol" . "__real_symbol" . : void * __wrap_malloc (size_t c) { printf ("malloc called with %zu\n", c); return __real_malloc (c); } --wrap malloc "malloc" "__wrap_malloc" . "__real_malloc" "__wrap_malloc" "malloc" . "__real_malloc" --wrap . "__real_malloc" "__wrap_malloc" "malloc" . . symbol "__wrap_symbol" . "f" "g" "__wrap_f" . int f (void) { return 123; } int g (void) { return f(); } --eh-frame-hdr --no-eh-frame-hdr (--eh-frame-hdr) (--no-eh-frame-hdr) ".eh_frame_hdr" "PT_GNU_EH_FRAME" ELF. --no-ld-generated-unwind-info ".eh_frame" PLT. . --discard-sframe ".sframe" . SFrame PLT . . --enable-new-dtags --disable-new-dtags ELF . ELF . --enable-new-dtags . --disable-new-dtags . . ELF . --hash-size=number number. . . 4051 --reduce-memory-overheads 1021 . --hash-style=style () . style "sysv" ".hash" ELF "gnu" GNU ".gnu.hash" "both" ELF ".hash" GNU ".gnu.hash" . "both" . --compress-debug-sections=none --compress-debug-sections=zlib --compress-debug-sections=zlib-gnu --compress-debug-sections=zlib-gabi --compress-debug-sections=zstd ELF DWARF zlib . --compress-debug-sections=none DWARF . --compress-debug-sections=zlib-gnu DWARF .debug .zdebug . --compress-debug-sections=zlib-gabi DWARF SHF_COMPRESSED . --compress-debug-sections=zlib --compress-debug-sections=zlib-gabi . --compress-debug-sections=zstd DWARF zstd . --compress-debug-sections=none . . --help . --reduce-memory-overheads ld . O(n^2) O(n) . 1021 . --hash-size . --reduce-memory-overheads . --max-cache-size=size ld (cache) . size . - --no-keep-memory 0 - . --build-id --build-id=style ELF ".note.gnu.build-id" COFF ".buildid". . style "uuid" "sha1" SHA1 "md5" MD5 "xx" XXHASH "0xhexstring" ( "-" ":" ). style "sha1" . "md5" "sha1" "xx" . . . "none" style "--build-id" . --package-metadata=JSON ELF ".note.package". JSON . : https://systemd.io/ELF_PACKAGE_METADATA/ JSON %[string] ( string HTML ) : %[comma] , %[lbrace] { %[quot] " %[rbrace] } %[space] . JSON --package-metadata . libjansson JSON . PE -shared (DLL) . "*.dll" . "*.def" ( ). PE PE . . --add-stdcall-alias stdcall (@nn) . [ PE ] --base-file file file DLL dlltool . [ PE ] --dll DLL . -shared "LIBRARY" ".def" . [ PE ] --enable-long-section-names --disable-long-section-names PE COFF ( COFF) . COFF . ( !) . PE (dumpers) . GDB Dwarf-2 PE ld . [ PE ] --enable-stdcall-fixup --disable-stdcall-fixup (cdecl stdcall) << >> (fuzzy linking) . "_foo" "_foo@12" "_bar@16" "_bar" . dll . --enable-stdcall-fixup . --disable-stdcall-fixup . [ PE ] --leading-underscore --no-leading-underscore (_) . / . [ PE ] --export-all-symbols DLL DLL . . DEF . "DllMain@12" "DllEntryPoint@0" "DllMainCRTStartup@12" "impure_ptr" . DLL DLL "_head_" "_iname" . "libgcc" "libstd++" "libmingw32" "crtX.o" . "__rtti_" "__builtin_" DLL ++C . cygwin ( DLL cygwin ). cygwin : "_cygwin_dll_entry@12" "_cygwin_crt0_common@8" "_cygwin_noncygwin_dll_entry@12" "_fmode" "_impure_ptr" "cygwin_attach_dll" "cygwin_premain0" "cygwin_premain1" "cygwin_premain2" "cygwin_premain3" "environ". [ PE ] --exclude-symbols symbol,symbol,... . . [ PE ] --exclude-all-symbols . [ PE ] --file-alignment . . . [ PE ] --heap reserve --heap reserve,commit ( / commit) . 1MB 4K () . [ PE ] --kill-at stdcall (@nn) . [ PE ] --large-address-aware <> COFF . /3GB /USERVA=value <<[operating systems]>> BOOT.INI . . [ i386 PE ] --disable-large-address-aware --large-address-aware . --large-address-aware ( Cygwin gcc) . [ i386 PE ] --major-image-version value <> . . [ PE ] --major-os-version value <> . . [ PE ] --major-subsystem-version value <> . . [ PE ] --minor-image-version value <> . . [ PE ] --minor-os-version value <> . . [ PE ] --minor-subsystem-version value <> . . [ PE ] --output-def file file DEF DLL . DEF ( "*.def" ) "dlltool" . [ PE ] --enable-auto-image-base --enable-auto-image-base=value DLL value "--image-base" . () dllname DLL . [ PE ] --disable-auto-image-base . ("--image-base") . [ PE ] --dll-search-prefix string dll "lib.dll" ".dll" . DLL <<>> : native cygwin uwin pw . DLL cygwin "--dll-search-prefix=cyg" . [ PE ] --enable-auto-import "_symbol" "__imp__symbol" DATA DLL dllimport (unmangled) . [ PE ] Cygwin MinGW . : 'auto-import' text . PE-COFF . - 'auto-import' .rdata .data . const : http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html 'auto-import' -- : "variable '' can't be auto-imported. Please read the documentation for ld's "--enable-auto-import" for details." () ( Win32 ). struct DLL DLL . ( struct long long ) . ld . : --enable-runtime-pseudo-reloc . . <<>> -- . : ) (indexee) ) <<>>. : extern type extern_array[]; extern_array[1] --> { volatile type *t=extern_array; t[1] } extern type extern_array[]; extern_array[1] --> { volatile int t=1; extern_array[t] } struct ( ) struct ( long long ...) : extern struct s extern_struct; extern_struct.field --> { volatile struct s *t=&extern_struct; t->field } extern long long extern_ll; extern_ll --> { volatile long long * local_ll=&extern_ll; *local_ll } 'auto-import' "__declspec(dllimport)" . #define DLL DLL / . << >> : : --foo.h extern int arr[]; --foo.c #include "foo.h" void main(int argc, char **argv){ printf("%d\n",arr[1]); } : --foo.h extern int arr[]; --foo.c #include "foo.h" void main(int argc, char **argv){ /* This workaround is for win32 and cygwin; do not "optimize" */ volatile int *parr = arr; printf("%d\n",parr[1]); } : --foo.h /* Note: auto-export is assumed (no __declspec(dllexport)) */ #if (defined(_WIN32) || defined(__CYGWIN__)) && \ !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC)) #define FOO_IMPORT __declspec(dllimport) #else #define FOO_IMPORT #endif extern FOO_IMPORT int arr[]; --foo.c #include "foo.h" void main(int argc, char **argv){ printf("%d\n",arr[1]); } ( set_foo() get_foo()). --disable-auto-import "_symbol" "__imp__symbol" (DATA) DLL . [ PE ] --enable-runtime-pseudo-reloc --enable-auto-import (DATA) DLL ' ' (runtime pseudo relocations) . [ PE ] --disable-runtime-pseudo-reloc (DATA) DLL . [ PE ] --enable-extra-pe-debug (auto-import symbol thunking) . [ PE ] --section-alignment . . 0x1000 . [ PE ] --stack reserve --stack reserve,commit ( commit) (stack) . . [ PE ] --subsystem which --subsystem which:major --subsystem which:major.minor . which "native" "windows" "console" "posix" "xbox". . which . [ PE ] "DllCharacteristics" PE : [ PE ] --high-entropy-va --disable-high-entropy-va (ASLR) . PE MinGW . --dynamicbase --enable-reloc-section . [ PE ] --dynamicbase --disable-dynamicbase (ASLR) . MS Windows Vista . MinGW --disable-dynamicbase . --enable-reloc-section . --forceinteg --disable-forceinteg . . --nxcompat --disable-nxcompat (Data Execution Prevention) . MS Windows XP SP2 . MinGW . --no-isolation --disable-no-isolation . . --no-seh --disable-no-seh SEH . SE . . --no-bind --disable-no-bind (bind) . . --wdmdriver --disable-wdmdriver MS Windows Driver Model . . --tsaware --disable-tsaware (Terminal Server) . . --insert-timestamp --no-insert-timestamp . . . --no-insert-timestamp . --insert-timestamp "SOURCE_DATE_EPOCH" (Unix epoch) . --enable-reloc-section --disable-reloc-section PE . . C6X uClinux DSBT . 0 . --dsbt-size size DSBT size . . --dsbt-index index DSBT index . 0 . DSBT 0 "R_C6000_DSBT_INDEX" . --no-merge-exidx-entries exidx (frame unwind info) . --branch-stub (branch stub) (branch relaxation) . C-SKY . --stub-group-size=N . . N . 1 -1 . 68HC11 68HC12 (trampoline) . --no-trampoline . "jsr" ( ) . --bank-window name MEMORY . . GOT 68K . --got=type GOT . type single negative multigot target . Info ld . microMIPS ISA MIPS . --insn32 --no-insn32 microMIPS PLT (lazy binding stubs) (relaxation) . --insn32 - . --no-insn32 - . --ignore-branch-isa --no-ignore-branch-isa ISA . --ignore-branch-isa ISA "BAL" (relaxation) "JALX" . --no-ignore-branch-isa ISA . --compact-branches --no-compact-branches (compact instructions) PLT MIPS R6 . pdp11-aout . pdp11-aout --omagic --nmagic . --imagic pdp11-aout pdp11-aout . -N --omagic a.out "OMAGIC" (0407) (text segment) . . PDP11 2.11BSD ld PDP11 . -n --nmagic a.out "NMAGIC" (0410) (shareable) . . (pure executable) . -z --imagic a.out "IMAGIC" (0411) (MMU) PDP11 . . . (magic number) . -z 2.11BSD . (separate executable) . --no-omagic --nmagic pdp11-aout. (ENVIRONMENT) ld "GNUTARGET" "LDEMULATION" "COLLECT_NO_DEMANGLE" . "GNUTARGET" -b ( --format) . BFD . "GNUTARGET" ld . "GNUTARGET" "default" BFD . BFD . "LDEMULATION" -m . . --verbose -V . -m "LDEMULATION" . (demangling) . "COLLECT_NO_DEMANGLE" . "gcc" . --demangle --no-demangle . PE/COFF --insert-timestamp SOURCE_DATE_EPOCH COFF . "LD_STATS" --stats . "LD_STATS" . . (SEE ALSO) ar(1) nm(1) objcopy(1) objdump(1) readelf(1) Info binutils ld. (COPYRIGHT) Copyright (c) 1991-2026 Free Software Foundation, Inc. / << >> (GNU Free Documentation License) . . <> . binutils-2.47 2026-07-26 LD(1)