LD(1) GNU Development Tools LD(1) (NAME) ld - (SYNOPSIS) ld [options] objfile ... (DESCRIPTION) ld (object) (relocate) . ld . ld (Linker Command Language) << AT&T>> . ld "info" . ld BFD . ld COFF "a.out". . . ld ( ). ld . . (OPTIONS) . ld Unix Unix . "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 ..IP "-a keyword" 4 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 input-format ( ). "GNUTARGET" . "TARGET" -c MRI-commandfile --mri-script=MRI-commandfile MRI ld <> GNU ld . MRI -c ld -T . 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" . i386 PE ELF . i386 PE .def . ELF (hidden) . --exclude-modules-for-implib module,module,... (import library) . ld . i386 PE . .def . -E --export-dynamic --no-export-dynamic -E --export-dynamic . . ( --no-export-dynamic ) . "dlopen" . . --dynamic-list . ELF . PE DLL EXE --export-all-symbols ..IP --export-dynamic-symbol=glob 4 glob . glob . -Bsymbolic --dynamic-list (no-op). ELF . --export-dynamic-symbol-list=file --export-dynamic-symbol . (version node) (scope) . 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 ( -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 (map output) ..IP -M 4 --print-map (link map) . : o (object files) . 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 (GNU properties). .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 ( 0x1 0xc0010001) bar.o ( 0x1 0xc0010001) 0x1 . o ELF (fixups) --relax. foo.o: Adjusting branch at 0x00000008 towards "far" in section .text 0x00000008 foo.o "far" .text (trampoline) . --print-map-discarded --no-print-map-discarded ( ) (garbage collected) . . --print-map-locals --no-print-map-locals ( ) . (local) . ( .L ) . . -n --nmagic (page alignment) . "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 depfile. "make" . -M -MP . -MM << >> ( << >> ). --dependency-file makefile . -O level level ld . . ELF . . . . -plugin name . name . . ar nm ranlib . ${libdir}/bfd-plugins . gcc (backward compatible) . --push-state --push-state --pop-state . : -Bdynamic -Bstatic -dn -dy -call_shared -non_shared -static -N -n --whole-archive --no-whole-archive -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 --push-state . -q --emit-relocs (relocation) . . . ELF . --force-dynamic (dynamic sections) . VxWorks . -r --relocatable --- ld . (partial linking) . (magic numbers) Unix "OMAGIC" . . 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 (undefined) . . -u . "EXTERN" . --require-defined . --require-defined=symbol symbol . --undefined symbol . "EXTERN" "ASSERT" "DEFINED" . . -Ur (constructors) (destructors) ELF -r : --- ld . -Ur -r . -r -Ur -Ur -Ur . -Ur -r ..IP --orphan-handling=MODE 4 (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 foo GOT (padding) "NOP" . 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 (relocation) (caching) . nocombreloc . common nocommon (common symbols) 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 (canonical) (copy relocation) . noextern-protected-data nocopyreloc . i386 x86-64 . noindirect-extern-access GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS .note.gnu.property ..IP initfirst 4 (shared object) . . . interpose . unique nounique ELF ( ) ( "dlmopen") . libc libpthread . "dlmopen" ( audit) . 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 (lazy binding) . (lazy binding) . 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 r_addend R_X86_64_JUMP_SLOT ( glibc r_addend R_X86_64_GLOB_DAT R_X86_64_JUMP_SLOT ) . x86_64 . muldefs . nocopyreloc .dynbss . . nodefaultlib . nodelete . nodlopen "dlopen" . nodump "dldump" . 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 . GNU C Library GLIBC_ABI_DT_RELR C . i386 x86-64 . relro norelro ELF "PT_GNU_RELRO" . . common-page-size . norelro ELF "PT_GNU_RELRO" . report-relative-reloc . Linux/i386 Linux/x86_64 . sectionheader nosectionheader . nosectionheader . sectionheader ..IP separate-code 4 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 (stack) "PT_GNU_STACK" ELF. "PT_GNU_STACK" (override) . start-stop-gc nostart-stop-gc --gc-sections "__start_SECNAME" "__stop_SECNAME" "SECNAME" "SECNAME" C "__start_SECNAME" "__stop_SECNAME" . -z start-stop-gc (garbage collect) . -z start-stop-gc "__start_SECNAME" "__stop_SECNAME" . "__start_SECNAME" "__stop_SECNAME" . start-stop-visibility=value (visibility) 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 . . . . . . . --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 . : Linux --as-needed --rpath --rpath-link . --rpath-link ..IP --add-needed 4 --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 . . --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 (cross reference). . . . . . . (common) . . --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 . --no-define-common . . --force-group-allocation (section group) . (-r) . "FORCE_GROUP_ALLOCATION" ..IP --defsym=symbol=expression 4 (global symbol) expression . . expression : "+" "-" . . : symbol ("=") expression . --defsym -T --defsym -T -T --defsym -T . --defsym . --demangle[=style] --no-demangle (demangle) . : (underscores) (mangled) C++ . . . COLLECT_NO_DEMANGLE . . -Ifile --dynamic-linker=file (dynamic linker) . ELF . . --no-dynamic-linker (load-time) . ELF (dynamic relocations) (entry point) . --embedded-relocs --emit-relocs (target-specific section) . 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 (garbage collection) . . ( ) --no-gc-sections . COFF PE . --gc-sections . (entry symbol) . . . --entry --undefined --gc-keep-exported . ( -r) . --entry --undefined --gc-keep-exported "ENTRY" . (GNU extension) ELF "SHF_GNU_RETAIN" . --print-gc-sections --no-print-gc-sections . (stderr) . --gc-sections . ( ) --no-print-gc-sections . --gc-keep-exported --gc-sections (default or protected 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 . -Map=mapfile (link map) 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 ./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] "%" . ..IP --no-keep-memory 4 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 . . . . --no-undefined-version . . --default-symver (soname) . --default-imported-symver (soname) . --no-warn-mismatch ( ) ld . ld . . --no-warn-search-mismatch ld . . --no-whole-archive --whole-archive . --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) . i386 PE ELF . -pie --pic-executable (PIE) . ELF . (relocate) . ELF ET_DYN . PIE . -no-pie . . -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 ..IP -rpath=dir 4 (runtime). ELF (shared objects) . -rpath . -rpath -rpath-link . -rpath (native) (cross linkers) --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" . (non-relocatable) . . -rpath-link . (:) . $ORIGIN $LIB . $ORIGIN $LIB lib - - lib64 - - . - ${ORIGIN} ${LIB} - . $PLATFORM . --rpath-link (hard compiled) . . . . -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. Linux /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" . Linux : --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) ..IP --spare-dynamic-tags=count 4 () .dynamic ELF . (prelinker) . . --split-by-file[=size] --split-by-reloc size . size . --split-by-reloc[=count] count (relocation) . 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() . (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 memory user time system time Stats: name (microsec) (KiB) (seconds) (seconds) Stats: ALL 390082 217740 0 0 Stats: ctf processing 12 0 0 0 Stats: string merge 1324 0 0 0 Stats: parsing 349 288 0 0 Stats: plugins 1 0 0 0 Stats: processing files 259616 214524 0 0 Stats: write 116493 0 0 0 --no-stats --stats LD_STATS . --sysroot=directory directory sysroot . --with-sysroot . --task-link COFF/PE task-linked (global) (static) . --traditional-format ld . ld . SunOS ld . . "dbx" SunOS ( "gdb" ). --traditional-format ld . --section-start=sectionname=org org . . org 0x . : 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 (NUMBER > 1) ..IP --version-script=version-scriptfile 4 . . ELF VERSION. PE (auto-export) : local . --warn-common (common symbol) . Unix . . 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 constructor) . . 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 . execstack . --warn-execstack --warn-execstack-objects . --no-error-execstack . --warn-multiple-gp (global pointer) . Alpha. . ( global pointer) . ( ) (constant pool) . . . --warn-once . --warn-rwx-segments --no-warn-rwx-segments (segment) . . (TLS thread local storage) / . . --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 ..IP --warn-section-align 4 . . "SECTIONS" . --warn-textrel DT_TEXTREL . --warn-alternate-em ELF . --warn-unresolved-symbols ( --unresolved-symbols ) . . --error-unresolved-symbols . --whole-archive --whole-archive . . . gcc: gcc -Wl,-whole-archive . -Wl,-no-whole-archive gcc . --wrap=symbol (wrapper) 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" ELF "PT_GNU_EH_FRAME". --no-ld-generated-unwind-info unwind ".eh_frame" PLT. unwind . ".sframe" PLT . --enable-new-dtags --disable-new-dtags ELF ELF . --enable-new-dtags . --disable-new-dtags . . ELF . --hash-size=number number . . . --hash-style=style () . style "sysv" ELF ".hash" "gnu" ".gnu.hash" "both" ELF ".hash" ".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 . size . --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" ..IP --package-metadata=JSON 4 ELF ".note.package". (package metadata specification) JSON . : https://systemd.io/ELF_PACKAGE_METADATA JSON percent-encoding %[string] ( string Named Character References HTML ) : %[comma] , %[lbrace] { %[quot] " %[rbrace] } %[space] . JSON --package-metadata . libjansson JSON . i386 PE -shared (DLL) . "*.dll" . "*.def" (object file) ( ). i386 PE i386 PE . . --add-stdcall-alias stdcall (@nn) . [ i386 PE ] --base-file file file (relocations) DLL dlltool . [ i386 PE ] --dll DLL . -shared "LIBRARY" ".def" . [ i386 PE ] --enable-long-section-names --disable-long-section-names PE COFF ( COFF) . COFF . ( !) . -GNU PE . GDB Dwarf-2 PE ld (not stripping symbols) . [ PE ] --enable-stdcall-fixup --disable-stdcall-fixup (resolve) (cdecl stdcall) << >> (fuzzy linking) . "_foo" "_foo@12" "_bar@16" "_bar" . (import libraries) DLL . --enable-stdcall-fixup . --disable-stdcall-fixup . [ i386 PE ] --leading-underscore --no-leading-underscore (underscore) . / . --export-all-symbols DLL DLL . . DEF (function attributes) . "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". [ i386 PE ] --exclude-symbols symbol,symbol,... . . [ i386 PE ] --exclude-all-symbols . [ i386 PE ] --file-alignment . . 512 . [ i386 PE ] --heap reserve --heap reserve,commit ( commit ) (heap) . . [ i386 PE ] --kill-at stdcall (@nn) . [ i386 PE ] --large-address-aware "Characteristics" COFF . /3GB /USERVA=value "[operating systems]" BOOT.INI . [ PE ] --disable-large-address-aware --large-address-aware . --large-address-aware ( Cygwin gcc) . [ PE ] --major-image-version value "image version" . 1 . [ i386 PE ] --major-os-version value "os version" . 4 . [ i386 PE ] --major-subsystem-version value "subsystem version" . 4 . [ i386 PE ] --minor-image-version value "image version" . 0 . [ i386 PE ] --minor-os-version value "os version" . 0 . [ i386 PE ] --minor-subsystem-version value "subsystem version" . 0 . [ i386 PE ] --output-def file file DEF DLL . DEF ( "*.def" ) "dlltool" . [ i386 PE ].IP --enable-auto-image-base 4 --enable-auto-image-base=value (image base) DLL value "--image-base" . () DLL DLL (relocations) . [ i386 PE ] --disable-auto-image-base . ("--image-base") . [ i386 PE ] --dll-search-prefix string DLL (import library) "lib.dll" ".dll" . DLL <<>> : native cygwin uwin pw . DLL cygwin "--dll-search-prefix=cyg" . [ i386 PE ] --enable-auto-import "_symbol" "__imp__symbol" (DATA) DLL dllimport (unmangled) . [ i386 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 (index) DLL . ( struct long long ) . ld . : --enable-runtime-pseudo-reloc . . <<>> -- . : ) ) <<>>. : 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 . [ i386 PE ] --enable-runtime-pseudo-reloc --enable-auto-import DATA DLL << >> ('runtime pseudo relocations') . [ i386 PE ] --disable-runtime-pseudo-reloc DATA DLL (pseudo relocations) . [ i386 PE ] --enable-extra-pe-debug thunking auto-import . [ i386 PE ] --section-alignment (section alignment) . . 0x1000 . [ i386 PE ] --stack reserve --stack reserve,commit ( /commit) (stack) . (committed) . [ i386 PE ] --subsystem which --subsystem which:major.minor . which "native" "windows" "console" "posix" "xbox". . which . [ i386 PE ] "DllCharacteristics" PE : [ PE ] --high-entropy-va --disable-high-entropy-va (ASLR) . PE MinGW . --dynamicbase --enable-reloc-section . --dynamicbase --disable-dynamicbase (ASLR) (relocate) . MS Windows Vista i386 PE . MinGW --disable-dynamicbase . --enable-reloc-section . --forceinteg --disable-forceinteg . . --nxcompat --disable-nxcompat << >> (Data Execution Prevention DEP) . MS Windows XP SP2 i386 PE . MinGW . --no-isolation --disable-no-isolation (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) . C-SKY . --stub-group-size=N . . N . 1 -1 . 68HC11 68HC12 . --no-trampoline . (far function) "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) . --insn32 . --no-insn32 . --ignore-branch-isa --no-ignore-branch-isa ISA . --ignore-branch-isa ISA "BAL" "JALX" . --no-ignore-branch-isa ISA ..IP --compact-branches 4 --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 Unix PDP11 ld . -n --nmagic a.out "NMAGIC" (0410) . . 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" . (demangle) . "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-2025 Free Software Foundation, Inc. / << >> (GNU Free Documentation License) . . <> . binutils-2.45.1 2025-11-10 LD(1)