LD(1) LD(1) ld - GNU ld [options] objfile ... ld . ld. ld (Linker Command Language) AT&T's . ld "info" GNU. ld BFD . ld --- COFF "a.out". . GNU . ld ( ). (GNU linker) ld . . . 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. (linker script). ( -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 (recursively). -a _ 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 _ --format=- ld . ld -b . ld ld . input-format BFD. ( objdump -i.) . -b ( ) -b input-format . "GNUTARGET". "TARGET" -c __MRI --mri-script=--MRI MRI ld MRI GNU ld. MRI -c -T ld . MRI-cmdfile ld -L. -d -dc -dp . ( -r). "FORCE_COMMON_ALLOCATION" . --depaudit _ -P _ 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 } : .data.1: size 8 .data.2: size 0x10 .data.3: size 4 .data.1 mem1 .data.2 .data.3 mem2 .data.3 mem3. INSERT . --enable-non-contiguous-regions-warnings "--enable-non-contiguous-regions" . -e --entry= entry . entry entry ( 10 0x 16 0 8). i386 PE entry ( / stdcall @number ). --exclude-libs ,,... . . "--exclude-libs ALL" . i386 PE ELF. i386 PE .def . ELF . --exclude-modules-for-implib ,,... . 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 . --export-dynamic-symbol= glob . glob . -Bsymbolic --dynamic-list. ELF . --export-dynamic-symbol-list= --export-dynamic-symbol . . VERSION . -EB big-endian. . -EL little-endian. . -f --auxiliary= ELF DT_AUXILIARY . name. DT_AUXILIARY. name. . name . . DT_AUXILIARY . -F --filter= ELF DT_FILTER . name. DT_FILTER. name. name. -F . GNU : -b --format --oformat "TARGET" "GNUTARGET". GNU -F ELF . -fini= ELF NAME DT_FINI . "_fini" . -g . . -G --gpsize= GP size. MIPS ELF . . -h -soname= ELF DT_SONAME . DT_SONAME DT_SONAME . -i ( -r). -init= ELF NAME DT_INIT . "_init" . -l namespec --library=- namespec . . namespec :filename ld filename libnamespec.a. ld libnamespec.a. ELF SunOS ld libnamespec.so libnamespec.a. ( ".so" ). :filename filename. . ( ) . . -( . . Unix. ld AIX AIX. -L _ --library-path=- searchdir ld ld. . . . -L -l . -L ld -T. searchdir "=" $SYSROOT sysroot prefix --sysroot . ( -L) ld . "SEARCH_DIR". . -m emulation. --verbose -V. -m "LDEMULATION" . . --remap-inputs==_ --remap-inputs-file= . --remap-inputs=foo.o=bar.o foo.o bar.o. --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 . (remap) . verbose verbose . -Map --print-map . -M --print-map . : o . o . o . o . - . . . : foo = 1 foo = foo * 4 foo = foo + 8 -M: 0x00000001 foo = 0x1 [0x0000000c] foo = (foo * 0x4) [0x0000000c] foo = (foo + 0x8) Expressions (linker). o GNU. note.gnu.property. note.gnu.property. . . : 0xc0000002 foo.o (0x1) bar.o ( ) 0xc0000002 foo.o 0xc0000002 0x1 bar.o 0xc0000002. 0xc0010001 (0x1) foo.o (0x1) bar.o (0x1) 0xc0010001 0x1 foo.o 0xc0010001 0x1 bar.o 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 ( ) . . --print-map-locals --no-print-map-locals ( ) . (local) . ( .L) . . -n --nmagic . "NMAGIC". -N --omagic . . "OMAGIC". : PE-COFF . --no-omagic -N. . - . -Bdynamic . -o --output= output ld a.out . "OUTPUT" . - . . - . . -o . : ld -o $(EXE) $(OBJS) ld $(OBJS) -o $(EXE) EXE ( OBJS) . --dependency-file=_ dependency file depfile. "make" . -M -MP. -MM "system files" ( "system headers" ). --dependency-file makefile . -O level ld . . ELF . . . . -plugin (plugin) . name . (compiler) (link time optimization) . 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 -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 . . . ELF . --force-dynamic . VxWorks. -r --relocatable --- ld. partial linking. "OMAGIC". . ++C (constructors) -Ur. . "a.out" . (LTO) .gnu_object_only -r LTO. .gnu_object_only .gnu_object_only . -r . -i. -R _ --just-symbols=- 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 _ --script=_ scriptfile . ld ( ) "INSERT" commandfile . scriptfile "ld" -L . -T . -T -T . . -dT _ --default-script=_ scriptfile . --script . --default-script ( gcc). -u --undefined= . . -u . "EXTERN". --require-defined . --require-defined= symbol . --undefined symbol . "EXTERN" "ASSERT" "DEFINED" . . -Ur ELF -r: ld. -Ur -r . -r -Ur -Ur -Ur . -Ur -r . --orphan-handling= . . MODE : "place" (Orphan sections) Orphan Sections. --unique . "discard" (orphan sections) /DISCARD/. "warn" "place" . "error" . --orphan-handling "place". --unique[=] SECTION SECTION . . . -v --version -V ld. -V . --enable-linker-version . -x --discard-all . -X --discard-locals . ( .L ELF L a.out .) -y --trace-symbol= symbol. . . . -Y path . . -z _ : call-nop=prefix-addr call-nop=suffix-nop call-nop=prefix-byte call-nop=suffix-byte "NOP" 1 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 . STT_OBJECT nocommon. 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 Intel Indirect Branch Tracking (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 ( ) . . loadfltr . max-page-size= 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". noexecstack . noextern-protected-data . . . . i386 x86-64. noreloc-overflow . . x86_64. _ nomemory-seal (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 GLIBC_ABI_DT_RELR C . i386 x86-64. relro norelro ELF "PT_GNU_RELRO" . . common-page-size . ELF "PT_GNU_RELRO" norelro. report-relative-reloc . Linux/i386 Linux/x86_64. sectionheader nosectionheader . nosectionheader. sectionheader . separate-code noseparate-code "PT_LOAD" . . "PT_LOAD" noseparate-code. shstk GNU_PROPERTY_X86_FEATURE_1_SHSTK .note.gnu.property Intel Shadow Stack. Linux/i386 Linux/x86_64. stack-size= (stack size) ELF "PT_GNU_STACK". "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" . --= 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 . "."number"" unique-symbol. nounique-symbol. x86-64-baseline x86-64-v2 x86-64-v3 x86-64-v4 x86-64 ISA .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 x86-64 ISA . isa-level-report=none x86-64 ISA . isa-level-report=all x86-64 ISA . isa-level-report=needed x86-64 ISA . isa-level-report=used x86-64 ISA . 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 "GLIBC_ABI_GNU_TLS" "___tls_get_addr" libc.so "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 "GLIBC_ABI_GNU2_TLS" "R_386_TLS_DESC_CALL" "R_X86_64_TLSDESC_CALL" libc.so "GLIBC_ABI_GNU2_TLS". Linux/i386 Linux/x86_64. -( archives -) --start-group --end-group . -l. . . . . . . --accept-unknown-input-arch --no-accept-unknown-input-arch . . 2.14. 2.14 --accept-unknown-input-arch . --as-needed --no-as-needed ELF DT_NEEDED --as-needed. DT_NEEDED . --as-needed DT_NEEDED 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 _ 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=-- . . ELF . . VERSION . --dynamic-list-data . --dynamic-list-cpp-new C++ (new) (delete). libstdc++ . --dynamic-list-cpp-typeinfo C++. --check-sections --no-check-sections . . . --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 . . . . . . . . . --ctf-variables --no-ctf-variables CTF . : . --ctf-variables . --no-ctf-variables. --ctf-share-types= CTF. share-unconflicted . . share-duplicated : . . CTF CTF . CTF CTF . --no-define-common . "INHIBIT_COMMON_ALLOCATION" . --no-define-common . --no-define-common . . --force-group-allocation . (-r). "FORCE_GROUP_ALLOCATION" . --defsym== expression. . expression : "+" "-" . . : symbol ("=") expression. --defsym -T --defsym -T -T --defsym -T . --defsym . --demangle[=style] --no-demangle . : C++ . . . COLLECT_NO_DEMANGLE. . -I --dynamic-linker= . ELF. . --no-dynamic-linker . ELF . --embedded-relocs --emit-relocs (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 Microsoft Windows Windows ".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 . . . ELF. --print-output-format ( ). "OUTPUT_FORMAT". --print-memory-usage MEMORY. . . . : ROM: 256 KB 1 MB 25.00% RAM: 32 B 2 GB 0.00% : --stats . --help . --target-help . -Map=_ mapfile. -M . mapfile "-" . mapfile . output ".map" . "%" . % ".map" . -o foo.exe -Map=bar [ ./bar] -o ../dir/foo.exe -Map=bar [ ./bar] -o foo.exe -Map=../dir [ ../dir/foo.exe.map] -o ../dir2/foo.exe -Map=../dir [ ../dir/foo.exe.map] -o foo.exe -Map=% [ ./foo.exe.map] -o ../dir/foo.exe -Map=% [ ../dir/foo.exe.map] -o foo.exe -Map=%.bar [ ./foo.exe.bar] -o ../dir/foo.exe -Map=%.bar [ ../dir/foo.exe.bar] -o ../dir2/foo.exe -Map=../dir/% [ ../dir/../dir2/foo.exe.map] -o ../dir2/foo.exe -Map=../dir/%.bar [ ../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 . o BeOS HPPA . BeOS . memset . --error-handling-script=- scriptname . : . : "undefined-symbol" "missing-lib" name . . . . --no-undefined-version . . --default-symver (soname) . --default-imported-symver (soname) . --no-warn-mismatch ld (endiannesses) . ld . . --no-warn-search-mismatch ld . . --no-whole-archive --whole-archive . --noinhibit-exec . . -nostdlib . ( ). --oformat=- ld . ld --oformat . ld ld . output-format BFD. ( objdump -i.) "OUTPUT_FORMAT" . --out-implib file ( DLL ELF). ( "*.dll.a" "*.a" DLL) ( "dlltool" DLL). i386 PE ELF. -pie --pic-executable . ELF. . ET_DYN ELF . PIE . -no-pie . . -qmagic . -Qy SVR4. --relax --no-relax . . --relax . . Matsushita MN10200 MN10300. --no-relax . --relax --no-relax . --retain-symbols-file=_ filename . filename . ( VxWorks) . --retain-symbols-file . --retain-symbols-file . -s -S. -rpath= . ELF . -rpath . -rpath -rpath-link. -rpath (cross linkers) --with-sysroot. -rpath ELF "LD_RUN_PATH" . -rpath SunOS. SunOS -L . -rpath -rpath -L. gcc -L NFS. ELF -R -rpath. -rpath-link= ELF SunOS . "ld -shared" . . . -rpath-link . . $ORIGIN $LIB . $ORIGIN lib - 32 - lib64 - 64 - $LIB. - ${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_RPATH" "DT_RUNPATH". 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 . (linker) . --section-ordering-file= . "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 . . . . --sort-section=name "SORT_BY_NAME" . --sort-section=alignment "SORT_BY_ALIGNMENT" . --spare-dynamic-tags= .dynamic ELF . prelinker. 5. --split-by-file[=] --split-by-reloc size. size 1 . --split-by-reloc[=] count . COFF COFF 65535 . . count . count 32768. --stats[=_] . filename . filename . filename - . filename + . -Map . : --stats -Map filename . "LD_STATS" --stats. . . . : --stats --stats . (CPU time) getrusage() . mallinfo mallinfo2 phases (). . ALL . . . : : : (GNU Binutils) 2.44.50.20250401 : : 2 09:36:41 2025 : : ld -z norelro -z nomemory-seal -z no-separate-code -o a.out [...] : cpu time rss user time system time memory : (microsec) (KiB) (seconds) (seconds) (KiB) : ALL 390082 217740 0 0 25219440 : ctf processing 12 0 0 0 0 : string merge 1324 0 0 0 406544 : parsing 349 288 0 0 119792 : plugins 1 0 0 0 0 : processing files 259616 214524 0 0 31569120 : write 116493 0 0 0 48096 --no-stats --stats LD_STATS. --sysroot= directory sysroot . --with-sysroot. --task-link COFF/PE . --traditional-format ld . ld . SunOS ld . 30 . "dbx" SunOS ( "gdb" ). --traditional-format ld . --section-start=_=org org. . org 0x . : sectionname ("=") org. --image-base=org ELF -Ttext-segment ELF . PE value dll. dll. dll dll . 0x400000 0x10000000 dll. -Tbss= -Tdata= -Ttext= --section-start ".bss" ".data" ".text" sectionname. -Ttext-segment= ELF . -pie -Ttext-segment=org ET_EXEC org . -Trodata-segment= ELF . -Tldata-segment= ELF x86-64 ldata. --unresolved-symbols= . method: ignore-all . report-all . . ignore-in-object-files . ignore-in-shared-libs . . --[no-]allow-shlib-undefined. --warn-unresolved-symbols . --dll-verbose --verbose[=] ld . . . NUMBER 1 . --version-script=__ . . ELF VERSION. PE : local . --warn-common . . . C . C: int i = 1; . extern int i; . . int i; . ( ) . . . . --warn-common . : . . 1. . (
): warning: common of `' (
): warning: 2. . . (
): warning: definition of `' (
): warning: 3. . (
): warning: `' (
): warning: 4. . (
): warning: common of `' (
): warning: 5. . . (
): warning: common of `' (
): warning: --warn-constructors . . COFF ELF . --warn-execstack --warn-execstack-objects --no-warn-execstack ELF . : 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 (stack) --error-execstack . - execstack . --warn-execstack --warn-execstack-objects . --no-error-execstack . --warn-multiple-gp . Alpha. . ( ) . ( 16 ) . . . --warn-once . --warn-rwx-segments --no-warn-rwx-segments . . (TLS) . . --no-warn-rwx-segments --warn-rwx-segments. --error-rwx-segments --no-error-rwx-segments (segment) 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 . . . gcc: gcc -Wl,-whole-archive. -Wl,-no-whole-archive gcc . --wrap= 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. . --discard-sframe ".sframe" . SFrame PLT. . --enable-new-dtags --disable-new-dtags ELF . ELF . --enable-new-dtags . --disable-new-dtags . . ELF. --hash-size= (hash tables) number. . . 4051 1021 --reduce-memory-overheads. --hash-style= () . style "sysv" ELF ".hash" "gnu" GNU ".gnu.hash" "both" ELF GNU . "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 .zdebug .debug. --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) 40% . 1021 . --hash-size. --reduce-memory-overheads (linker). --max-cache-size= ld . size. - --no-keep-memory 0 - . --build-id --build-id= ELF ".note.gnu.build-id" COFF ".buildid". . style "uuid" 128 "sha1" SHA1 160 "md5" MD5 128 "xx" XXHASH 128 "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 %[string] ( string HTML): %[comma] , %[lbrace] { %[quot] " %[rbrace] } %[space] . JSON --package-metadata. libjansson JSON. i386 PE -shared (DLL) . "*.dll" . "*.def" ( ). i386 PE i386 PE. . --add-stdcall-alias stdcall (@nn) . [ i386 PE] --base-file file DLLs dlltool. [ i386 PE] --dll DLL . -shared "LIBRARY" ".def" . [ i386 PE] --enable-long-section-names --disable-long-section-names PE COFF COFF. COFF . ( !) . PE . GDB PE Dwarf-2 ld . [ PE ] --enable-stdcall-fixup --disable-stdcall-fixup " " (cdecl stdcall) . "_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" . DLLs DLL "_head_" "_iname". "libgcc" "libstd++" "libmingw32" "crtX.o". "__rtti_" "__builtin_" DLL ++C. cygwin ( DLLs 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 ,,... . . [ i386 PE] --exclude-all-symbols . [ i386 PE] --file-alignment . . 512. [ i386 PE] --heap --heap , ( ) (heap) . 1 4 . [ i386 PE] --kill-at stdcall (@nn) . [ i386 PE] --large-address-aware "Characteristics" COFF 2 . /3GB /USERVA=value "[operating systems]" BOOT.INI. . [ PE] --disable-large-address-aware --large-address-aware . --large-address-aware ( Cygwin gcc) 2 . [ PE] --major-image-version " ". 1. [ i386 PE] --major-os-version " ". 4. [ i386 PE] --major-subsystem-version " ". 4. [ i386 PE] --minor-image-version " ". 0. [ i386 PE] --minor-os-version " ". 0. [ i386 PE] --minor-subsystem-version " ". 0. [ i386 PE] --output-def file DEF DLL . DEF ( "*.def") "dlltool" . [ i386 PE] --enable-auto-image-base --enable-auto-image-base= DLL value "--image-base". dll DLL . [ i386 PE ] --disable-auto-image-base . ("--image-base") . [ i386 PE ] --dll-search-prefix 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 . [ i386 PE ] Cygwin MinGW. : 'auto-import' (text) . PE-COFF Microsoft. - 'auto-import' .rdata .data . (consts) : http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html 'auto-import' -- : " '' . "--enable-auto-import" ld ." () ( Win32 ). DLL DLL. ( 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] } ( ) ( 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)". #defines DLL DLL / . " " : : --foo.h extern int arr[]; --foo.c #include "foo.h" void main(int argc, char **argv){ printf("%d\n",arr[1]); } 1: --foo.h extern int arr[]; --foo.c #include "foo.h" void main(int argc, char **argv){ /* win32 cygwin "" */ volatile int *parr = arr; printf("%d\n",parr[1]); } 2: --foo.h /* : (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 DLL. [ i386 PE ] --enable-extra-pe-debug thunking . [ i386 PE] --section-alignment . . 0x1000. [ i386 PE] --stack --stack , ( ) (stack) . 2 4 . [ i386 PE] --subsystem --subsystem : --subsystem :. . which "native" "windows" "console" "posix" "xbox". . which. [ i386 PE] "DllCharacteristics" PE: [ PE] --high-entropy-va --disable-high-entropy-va (ASLR) 64 . PE 64 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 (DEP). MS Windows XP SP2 i386 PE. MinGW. --no-isolation --disable-no-isolation . . --no-seh --disable-no-seh SEH. SE . . --no-bind --disable-no-bind . . --wdmdriver --disable-wdmdriver MS Windows. . --tsaware --disable-tsaware Terminal Server. . --insert-timestamp --no-insert-timestamp . (proprietary). . --no-insert-timestamp . --insert-timestamp "SOURCE_DATE_EPOCH" . --enable-reloc-section --disable-reloc-section PE. . C6X uClinux DSBT . 0. --dsbt-size DSBT size. 64 . --dsbt-index DSBT index. 0 . DSBT 0 "R_C6000_DSBT_INDEX" . --no-merge-exidx-entries exidx (frame unwind info). --branch-stub . C-SKY . --stub-group-size=N (stubs). . N . 1 -1 . 68HC11 68HC12 trampoline. --no-trampoline trampoline. trampoline "jsr" ( ). --bank-window MEMORY . . GOT 68K. --got= GOT . type single negative multigot target. Info ld. microMIPS ISA MIPS. --insn32 --no-insn32 microMIPS PLT . --insn32 32 . --no-insn32 16 . --ignore-branch-isa --no-ignore-branch-isa ISA . --ignore-branch-isa ISA "BAL" "JALX" . --no-ignore-branch-isa ISA . --compact-branches --no-compact-branches PLT MIPS R6. pdp11-aout . pdp11-aout --omagic --nmagic . --imagic pdp11-aout pdp11-aout. -N --omagic "OMAGIC" (0407) a.out . . PDP11 ld PDP11 Unix 2.11BSD. -n --nmagic "NMAGIC" (0410) a.out . 8 . pure executable. -z --imagic "IMAGIC" (0411) a.out PDP11. . . 0. -z 2.11BSD. separate executable. --no-omagic --nmagic pdp11-aout. 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. --insert-timestamp PE/COFF SOURCE_DATE_EPOCH COFF . "LD_STATS" --stats. "LD_STATS" . . ar(1) nm(1) objcopy(1) objdump(1) readelf(1) Info binutils ld. (c) 1991-2026 . / (GNU Free Documentation License) 1.3 . "GNU Free Documentation License". 3 . . : . binutils-2.46 9 2026 LD(1)