LD(1) GNU Development Tools LD(1) (NAME) ld - (SYNOPSIS) ld [] objfile ... (DESCRIPTION) ld (object) (relocate) . ld . ld (Linker Command Language) << AT&T>> . ld "info" . ld BFD . ld --- COFF "a.out". . . ld ( ). ld . ..SH " (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 GNU : @file file . @file . file . file . . ( ) . file @file . -a keyword HP/UX . keyword archive shared default . -aarchive -Bstatic -Bdynamic . . --audit AUDITLIB AUDITLIB "DT_AUDIT" (dynamic section) . AUDITLIB DT_SONAME . "DT_AUDIT" . 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 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 ( / @number stdcall). --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) . --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 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 ..IP -fini=name 4 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 . . . (#) . (whitespace) (=) . . . . . /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) . -M --print-map . : . o (common symbols). o . o . - (link map) . . () . : 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 (trampoline) . --print-map-discarded --no-print-map-discarded ( ) (garbage collection) . . --print-map-locals --no-print-map-locals ( ) . (local) . ( .L ) . . -n --nmagic (page alignment) . Unix "NMAGIC" . -N --omagic text data . data . Unix "OMAGIC" . : text PE-COFF . --no-omagic -N . text data . - -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 . . . -plugin name (plugin) . name . (LTO) . ar nm ranlib . ${libdir}/bfd-plugins . gcc (backward compatible) ..IP --push-state 4 --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 --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) ..IP "-u symbol" 4 --undefined=symbol symbol (undefined) . . -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 (wildcard) SECTION . . (override) . -v --version -V ld . -V . --enable-linker-version Options,,Command-line Options . -x --discard-all (local symbols) . -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 (dynamic relocation) (cache) . nocombreloc . common nocommon (common symbols) STT_COMMON . nocommon STT_OBJECT . common-page-size=value value . ..IP defs 4 . . -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 . 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 ( 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 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 ..IP nodlopen 4 "dlopen" . nodump "dldump" . noexecstack . noextern-protected-data (protected) . . . . i386 x86-64 . noreloc-overflow . . x86_64 . memory-seal nomemory-seal PT_LOAD (seal) ( ) . . 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 GLIBC_ABI_DT_RELR C . i386 x86-64 . relro norelro "PT_GNU_RELRO" ELF . . common-page-size . norelro "PT_GNU_RELRO" ELF . 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 (garbage collect) . -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 (export) . 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 . --no-gnu-tls-tag "GLIBC_ABI_GNU_TLS" glibc (relocatable) "___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 . : --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" (dynamic section). . --unresolved-symbols=report-all . ELF . -Bstatic -dn -non_shared -static . . . : -l . --unresolved-symbols=report-all . -shared . . -Bsymbolic ( ) (bind) . (override) . ELF . -Bsymbolic-functions ( ) . ELF . -Bno-symbolic -Bsymbolic -Bsymbolic-functions . --dynamic-list=dynamic-list-file (dynamic list) . . ELF . (version node) (scope) . VERSION . --dynamic-list-data . --dynamic-list-cpp-new new delete C++. libstdc++ ..IP --dynamic-list-cpp-typeinfo 4 ++C ( RTTI) . --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 (cross reference) . (linker map) . . . . . . (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 symbols) . "INHIBIT_COMMON_ALLOCATION" . --no-define-common (non- relocatable) . --no-define-common . . --force-group-allocation . (-r) . "FORCE_GROUP_ALLOCATION" . --defsym=symbol=expression expression . . expression : "+" "-" . . : symbol (<<=>>) expression . --defsym -T --defsym -T -T --defsym -T . --defsym . --demangle[=style] --no-demangle (demangle) . : (leading underscores) (mangled) ++C . . . 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 ..IP -w 4 --no-warnings . --fatal-warnings . . --force-exe-suffix .exe . ".exe" ".dll" ".exe" . makefile Microsoft Windows ".exe" . --gc-sections --no-gc-sections . . ( ) --no-gc-sections . COFF PE . --gc-sections . (entry symbol) . . . --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 . . . 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 ../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 . . --[no-]allow-shlib-undefined . "-z undefs" . --allow-multiple-definition -z muldefs . . --allow-shlib-undefined --no-allow-shlib-undefined . --no-undefined . . . : . o BeOS HPPA . BeOS (patch) . memset . --error-handling-script=scriptname scriptname . : . : "undefined-symbol" `missing-lib" name . . . . --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 . --noinhibit-exec . . -nostdlib . ( ) . --oformat=output-format ld (object file) . 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 . . ELF ET_DYN . PIE . -no-pie . . -qmagic Linux . -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 --with-sysroot . ELF -rpath "LD_RUN_PATH" . -rpath SunOS . SunOS -L . -rpath -rpath -L . gcc -L NFS . ELF -R -rpath ..IP -rpath-link=dir 4 ELF SunOS . "ld -shared" . (non-relocatable) . . -rpath-link . (:) . $ORIGIN $LIB . $ORIGIN (shared object) $LIB lib - - - lib64 - - - . - ${ORIGIN} ${LIB} . $PLATFORM . --rpath-link . . . . -l . -l -L . 1. -rpath-link. 2. -rpath. -rpath -rpath-link -rpath -rpath-link . -rpath (native) (cross) --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 . 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" . --spare-dynamic-tags=count (empty slots) .dynamic ELF . (prelinker) . ..IP --split-by-file[=size] 4 --split-by-reloc size . size 1 . --split-by-reloc[=count] count . COFF COFF . . count . count . --stats[=filename] . filename . filename . filename - . filename + . -Map map . : --stats -Map filename . "LD_STATS" --stats . . . . : --stats --stats . cpu 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 (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 . --verbose[=NUMBER] ld . . . NUMBER (> 1) . --version-script=version-scriptfile . . ELF VERSION . PE auto-export : local (export) . --warn-common (common symbol) . Unix . . C . C : int i = 1; . extern int i; . . int i; . ( ) . . . . --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 . . 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 . . . --error-execstack --no-error-execstack --error-execstack . - execstack . --warn-execstack --warn-execstack-objects . --no-error-execstack . --warn-multiple-gp (global pointer) . Alpha . . ( ) . ( ) (constant pool) . . . --warn-once ..IP --warn-rwx-segments 4 --no-warn-rwx-segments (segment) . . (thread local storage 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 (section) (alignment) . . "SECTIONS" . --warn-textrel DT_TEXTREL (shared object) . --warn-alternate-em ELF . --warn-unresolved-symbols ( --unresolved-symbols ) . . --error-unresolved-symbols . --whole-archive --whole-archive (object file) . . . gcc: gcc -Wl,-whole-archive . -Wl,-no-whole-archive gcc . --wrap=symbol (wrapper function) 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" . . (translation unit) 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 info) ".eh_frame" PLT. . ".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" ".hash" ELF "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 ..IP --reduce-memory-overheads 4 ld . O(n^2) (link map) O(n) . (hash table) 1021 . --hash-size . --reduce-memory-overheads . --max-cache-size=size ld (relocation) . (cache) size . --build-id --build-id=style ELF ".note.gnu.build-id" COFF ".buildid". . style "uuid" "sha1" SHA1 "md5" MD5 "xx" XXHASH (normative) "0xhexstring" ( "-" ":" ). style "sha1" . "md5" "sha1" "xx" . (checksum) . (build ID) . "none" style "--build-id" . --package-metadata=JSON ELF ".note.package". JSON . : https://systemd.io/ELF_PACKAGE_METADATA JSON (percent-encoding) %[string] ( string 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 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 . [ PE ] --enable-stdcall-fixup --disable-stdcall-fixup (cdecl stdcall) << >> (fuzzy linking) . "_foo" "_foo@12" "_bar@16" "_bar" . dll . --enable-stdcall-fixup . --disable-stdcall-fixup . [ i386 PE ] --leading-underscore --no-leading-underscore (_) . / . --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". [ i386 PE ] --exclude-symbols symbol,symbol,... . . [ i386 PE ] --exclude-all-symbols . [ i386 PE ] --file-alignment . . 512 . [ i386 PE ].IP "--heap reserve" 4 --heap reserve,commit ( ) (heap) . (committed) . [ 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 (major) "image version" . 1 . [ i386 PE ] --major-os-version value (major) "os version" . 4 . [ i386 PE ] --major-subsystem-version value (major) "subsystem version" . 4 . [ i386 PE ] --minor-image-version value (minor) "image version" . 0 . [ i386 PE ] --minor-os-version value (minor) "os version" . 0 . [ i386 PE ] --minor-subsystem-version value (minor) "subsystem version" . 0 . [ i386 PE ] --output-def file file DEF DLL . DEF ( "*.def" ) (import library) "dlltool" . [ i386 PE ] --enable-auto-image-base --enable-auto-image-base=value (image base) DLL value "--image-base" . dllname DLL (relocations) . [ i386 PE ] --disable-auto-image-base . ("--image-base") . [ i386 PE ] --dll-search-prefix string dll ".dll" "lib.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 (writable) . PE-COFF Microsoft . - 'auto-import' .rdata .data . (consts) : 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 . . <<>> -- . : ) ( ) ) <<>>. : 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 . [ i386 PE ] --enable-extra-pe-debug auto-import (thunking) . [ i386 PE ] --section-alignment (section alignment) . . 0x1000 . [ i386 PE ] --stack reserve --stack reserve,commit ( commit) . 2MB 4K . [ i386 PE ] --subsystem which --subsystem which:major --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) . MS Windows Vista i386 PE . MinGW --disable-dynamicbase . --enable-reloc-section . --forceinteg --disable-forceinteg . . --nxcompat --disable-nxcompat << >> (Data Execution Prevention) . 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 aware). . --insert-timestamp --no-insert-timestamp . . . --no-insert-timestamp . --insert-timestamp "SOURCE_DATE_EPOCH" (Unix epoch) ..IP --enable-reloc-section 4 --disable-reloc-section (base relocation table) 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 relaxation) (branch stub sections) . C-SKY branch call . --stub-group-size=N . . N . 1 -1 . 68HC11 68HC12 (memory bank switching) (trampoline) . --no-trampoline . (far function) "jsr" ( ). --bank-window name MEMORY (memory bank window) . (paging) . 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" "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) (write- protected) . . PDP11 2.11BSD ld PDP11 . -n --nmagic a.out "NMAGIC" (0410) (read-only) . . pure executable . -z --imagic a.out "IMAGIC" (0411) (MMU) PDP11 . . (pure) . (magic number) 0 . -z 2.11BSD . separate executable . --no-omagic pdp11-aout --nmagic ..SH " (ENVIRONMENT)" ld "GNUTARGET" "LDEMULATION" "COLLECT_NO_DEMANGLE" . -b ( --format) "GNUTARGET" . BFD . "GNUTARGET" ld . "GNUTARGET" "default" BFD . BFD . -m "LDEMULATION" . . --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-2025 Free Software Foundation, Inc. / (GNU Free Documentation License) 1.3 . "GNU Free Documentation License" . binutils-2.45.1 2025-11-10 LD(1)