ldのヘルプ・マニュアル
日本語 英語
ld --help
Usage: ld [options] file...
Options:
-a KEYWORD Shared library control for HP/UX compatibility
-A ARCH, --architecture ARCH
Set architecture
-b TARGET, --format TARGET Specify target for following input files
-c FILE, --mri-script FILE Read MRI format linker script
-d, -dc, -dp Force common symbols to be defined
-e ADDRESS, --entry ADDRESS Set start address
-E, --export-dynamic Export all dynamic symbols
--no-export-dynamic Undo the effect of --export-dynamic
-EB Link big-endian objects
-EL Link little-endian objects
-f SHLIB, --auxiliary SHLIB Auxiliary filter for shared object symbol table
-F SHLIB, --filter SHLIB Filter for shared object symbol table
-g Ignored
-G SIZE, --gpsize SIZE Small data size (if no size, same as --shared)
-h FILENAME, -soname FILENAME
Set internal name of shared library
-I PROGRAM, --dynamic-linker PROGRAM
Set PROGRAM as the dynamic linker to use
-l LIBNAME, --library LIBNAME
Search for library LIBNAME
-L DIRECTORY, --library-path DIRECTORY
Add DIRECTORY to library search path
--sysroot= Override the default sysroot location
-m EMULATION Set emulation
-M, --print-map Print map file on standard output
-n, --nmagic Do not page align data
-N, --omagic Do not page align data, do not make text readonly
--no-omagic Page align data, make text readonly
-o FILE, --output FILE Set output file name
-O Optimize output file
-Qy Ignored for SVR4 compatibility
-q, --emit-relocs Generate relocations in final output
-r, -i, --relocatable Generate relocatable output
-R FILE, --just-symbols FILE
Just link symbols (if directory, same as --rpath)
-s, --strip-all Strip all symbols
-S, --strip-debug Strip debugging symbols
--strip-discarded Strip symbols in discarded sections
--no-strip-discarded Do not strip symbols in discarded sections
-t, --trace Trace file opens
-T FILE, --script FILE Read linker script
--default-script FILE, -dT Read default linker script
-u SYMBOL, --undefined SYMBOL
Start with undefined reference to SYMBOL
--unique [=SECTION] Don't merge input [SECTION | orphan] sections
-Ur Build global constructor/destructor tables
-v, --version Print version information
-V Print version and emulation information
-x, --discard-all Discard all local symbols
-X, --discard-locals Discard temporary local symbols (default)
--discard-none Don't discard any local symbols
-y SYMBOL, --trace-symbol SYMBOL
Trace mentions of SYMBOL
-Y PATH Default search path for Solaris compatibility
-(, --start-group Start a group
-), --end-group End a group
--accept-unknown-input-arch Accept input files whose architecture cannot be determined
--no-accept-unknown-input-arch
Reject input files whose architecture is unknown
--as-needed Only set DT_NEEDED for following dynamic libs if used
--no-as-needed Always set DT_NEEDED for dynamic libraries mentioned on
the command line
-assert KEYWORD Ignored for SunOS compatibility
-Bdynamic, -dy, -call_shared
Link against shared libraries
-Bstatic, -dn, -non_shared, -static
Do not link against shared libraries
-Bsymbolic Bind global references locally
-Bsymbolic-functions Bind global function references locally
--check-sections Check section addresses for overlaps (default)
--no-check-sections Do not check section addresses for overlaps
--copy-dt-needed-entries Copy DT_NEEDED links mentioned inside DSOs that follow
--no-copy-dt-needed-entries Do not copy DT_NEEDED links mentioned inside DSOs that follow
--cref Output cross reference table
--defsym SYMBOL=EXPRESSION Define a symbol
--demangle [=STYLE] Demangle symbol names [using STYLE]
--embedded-relocs Generate embedded relocs
--fatal-warnings Treat warnings as errors
--no-fatal-warnings Do not treat warnings as errors (default)
-fini SYMBOL Call SYMBOL at unload-time
--force-exe-suffix Force generation of file with .exe suffix
--gc-sections Remove unused sections (on some targets)
--no-gc-sections Don't remove unused sections (default)
--print-gc-sections List removed unused sections on stderr
--no-print-gc-sections Do not list removed unused sections
--hash-size= Set default hash table size close to
--help Print option help
-init SYMBOL Call SYMBOL at load-time
-Map FILE Write a map file
--no-define-common Do not define Common storage
--no-demangle Do not demangle symbol names
--no-keep-memory Use less memory and more disk I/O
--no-undefined Do not allow unresolved references in object files
--allow-shlib-undefined Allow unresolved references in shared libaries
--no-allow-shlib-undefined Do not allow unresolved references in shared libs
--allow-multiple-definition Allow multiple definitions
--no-undefined-version Disallow undefined version
--default-symver Create default symbol version
--default-imported-symver Create default symbol version for imported symbols
--no-warn-mismatch Don't warn about mismatched input files
--no-warn-search-mismatch Don't warn on finding an incompatible library
--no-whole-archive Turn off --whole-archive
--noinhibit-exec Create an output file even if errors occur
-nostdlib Only use library directories specified on
the command line
--oformat TARGET Specify target of output file
-qmagic Ignored for Linux compatibility
--reduce-memory-overheads Reduce memory overheads, possibly taking much longer
--relax Relax branches on certain targets
--retain-symbols-file FILE Keep only symbols listed in FILE
-rpath PATH Set runtime shared library search path
-rpath-link PATH Set link time shared library search path
-shared, -Bshareable Create a shared library
-pie, --pic-executable Create a position independent executable
--sort-common [=ascending|descending]
Sort common symbols by alignment [in specified order]
--sort-section name|alignment
Sort sections by name or maximum alignment
--spare-dynamic-tags COUNT How many tags to reserve in .dynamic section
--split-by-file [=SIZE] Split output sections every SIZE octets
--split-by-reloc [=COUNT] Split output sections every COUNT relocs
--stats Print memory usage statistics
--target-help Display target specific options
--task-link SYMBOL Do task level linking
--traditional-format Use same format as native linker
--section-start SECTION=ADDRESS
Set address of named section
-Tbss ADDRESS Set address of .bss section
-Tdata ADDRESS Set address of .data section
-Ttext ADDRESS Set address of .text section
-Ttext-segment ADDRESS Set address of text segment
--unresolved-symbols=
How to handle unresolved symbols. is:
ignore-all, report-all, ignore-in-object-files,
ignore-in-shared-libs
--verbose Output lots of information during link
--version-script FILE Read version information script
--version-exports-section SYMBOL
Take export symbols list from .exports, using
SYMBOL as the version.
--dynamic-list-data Add data symbols to dynamic list
--dynamic-list-cpp-new Use C++ operator new/delete dynamic list
--dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
--dynamic-list FILE Read dynamic list
--warn-common Warn about duplicate common symbols
--warn-constructors Warn if global constructors/destructors are seen
--warn-multiple-gp Warn if the multiple GP values are used
--warn-once Warn only once per undefined symbol
--warn-section-align Warn if start of section changes due to alignment
--warn-shared-textrel Warn if shared object has DT_TEXTREL
--warn-alternate-em Warn if an object has alternate ELF machine code
--warn-unresolved-symbols Report unresolved symbols as warnings
--error-unresolved-symbols Report unresolved symbols as errors
--whole-archive Include all objects from following archives
--wrap SYMBOL Use wrapper functions for SYMBOL
@FILE Read options from FILE
ld: supported targets: elf64-x86-64 elf32-i386 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-little elf64-big elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex
ld: supported emulations: elf_x86_64 elf_i386 i386linux elf_l1om
ld: emulation specific options:
elf_x86_64:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility
elf_i386:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility
elf_l1om:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility
Report bugs to
Usage: ld [options] file...
Options:
-a KEYWORD Shared library control for HP/UX compatibility
-A ARCH, --architecture ARCH
Set architecture
-b TARGET, --format TARGET Specify target for following input files
-c FILE, --mri-script FILE Read MRI format linker script
-d, -dc, -dp Force common symbols to be defined
-e ADDRESS, --entry ADDRESS Set start address
-E, --export-dynamic Export all dynamic symbols
--no-export-dynamic Undo the effect of --export-dynamic
-EB Link big-endian objects
-EL Link little-endian objects
-f SHLIB, --auxiliary SHLIB Auxiliary filter for shared object symbol table
-F SHLIB, --filter SHLIB Filter for shared object symbol table
-g Ignored
-G SIZE, --gpsize SIZE Small data size (if no size, same as --shared)
-h FILENAME, -soname FILENAME
Set internal name of shared library
-I PROGRAM, --dynamic-linker PROGRAM
Set PROGRAM as the dynamic linker to use
-l LIBNAME, --library LIBNAME
Search for library LIBNAME
-L DIRECTORY, --library-path DIRECTORY
Add DIRECTORY to library search path
--sysroot= Override the default sysroot location
-m EMULATION Set emulation
-M, --print-map Print map file on standard output
-n, --nmagic Do not page align data
-N, --omagic Do not page align data, do not make text readonly
--no-omagic Page align data, make text readonly
-o FILE, --output FILE Set output file name
-O Optimize output file
-Qy Ignored for SVR4 compatibility
-q, --emit-relocs Generate relocations in final output
-r, -i, --relocatable Generate relocatable output
-R FILE, --just-symbols FILE
Just link symbols (if directory, same as --rpath)
-s, --strip-all Strip all symbols
-S, --strip-debug Strip debugging symbols
--strip-discarded Strip symbols in discarded sections
--no-strip-discarded Do not strip symbols in discarded sections
-t, --trace Trace file opens
-T FILE, --script FILE Read linker script
--default-script FILE, -dT Read default linker script
-u SYMBOL, --undefined SYMBOL
Start with undefined reference to SYMBOL
--unique [=SECTION] Don't merge input [SECTION | orphan] sections
-Ur Build global constructor/destructor tables
-v, --version Print version information
-V Print version and emulation information
-x, --discard-all Discard all local symbols
-X, --discard-locals Discard temporary local symbols (default)
--discard-none Don't discard any local symbols
-y SYMBOL, --trace-symbol SYMBOL
Trace mentions of SYMBOL
-Y PATH Default search path for Solaris compatibility
-(, --start-group Start a group
-), --end-group End a group
--accept-unknown-input-arch Accept input files whose architecture cannot be determined
--no-accept-unknown-input-arch
Reject input files whose architecture is unknown
--as-needed Only set DT_NEEDED for following dynamic libs if used
--no-as-needed Always set DT_NEEDED for dynamic libraries mentioned on
the command line
-assert KEYWORD Ignored for SunOS compatibility
-Bdynamic, -dy, -call_shared
Link against shared libraries
-Bstatic, -dn, -non_shared, -static
Do not link against shared libraries
-Bsymbolic Bind global references locally
-Bsymbolic-functions Bind global function references locally
--check-sections Check section addresses for overlaps (default)
--no-check-sections Do not check section addresses for overlaps
--copy-dt-needed-entries Copy DT_NEEDED links mentioned inside DSOs that follow
--no-copy-dt-needed-entries Do not copy DT_NEEDED links mentioned inside DSOs that follow
--cref Output cross reference table
--defsym SYMBOL=EXPRESSION Define a symbol
--demangle [=STYLE] Demangle symbol names [using STYLE]
--embedded-relocs Generate embedded relocs
--fatal-warnings Treat warnings as errors
--no-fatal-warnings Do not treat warnings as errors (default)
-fini SYMBOL Call SYMBOL at unload-time
--force-exe-suffix Force generation of file with .exe suffix
--gc-sections Remove unused sections (on some targets)
--no-gc-sections Don't remove unused sections (default)
--print-gc-sections List removed unused sections on stderr
--no-print-gc-sections Do not list removed unused sections
--hash-size= Set default hash table size close to
--help Print option help
-init SYMBOL Call SYMBOL at load-time
-Map FILE Write a map file
--no-define-common Do not define Common storage
--no-demangle Do not demangle symbol names
--no-keep-memory Use less memory and more disk I/O
--no-undefined Do not allow unresolved references in object files
--allow-shlib-undefined Allow unresolved references in shared libaries
--no-allow-shlib-undefined Do not allow unresolved references in shared libs
--allow-multiple-definition Allow multiple definitions
--no-undefined-version Disallow undefined version
--default-symver Create default symbol version
--default-imported-symver Create default symbol version for imported symbols
--no-warn-mismatch Don't warn about mismatched input files
--no-warn-search-mismatch Don't warn on finding an incompatible library
--no-whole-archive Turn off --whole-archive
--noinhibit-exec Create an output file even if errors occur
-nostdlib Only use library directories specified on
the command line
--oformat TARGET Specify target of output file
-qmagic Ignored for Linux compatibility
--reduce-memory-overheads Reduce memory overheads, possibly taking much longer
--relax Relax branches on certain targets
--retain-symbols-file FILE Keep only symbols listed in FILE
-rpath PATH Set runtime shared library search path
-rpath-link PATH Set link time shared library search path
-shared, -Bshareable Create a shared library
-pie, --pic-executable Create a position independent executable
--sort-common [=ascending|descending]
Sort common symbols by alignment [in specified order]
--sort-section name|alignment
Sort sections by name or maximum alignment
--spare-dynamic-tags COUNT How many tags to reserve in .dynamic section
--split-by-file [=SIZE] Split output sections every SIZE octets
--split-by-reloc [=COUNT] Split output sections every COUNT relocs
--stats Print memory usage statistics
--target-help Display target specific options
--task-link SYMBOL Do task level linking
--traditional-format Use same format as native linker
--section-start SECTION=ADDRESS
Set address of named section
-Tbss ADDRESS Set address of .bss section
-Tdata ADDRESS Set address of .data section
-Ttext ADDRESS Set address of .text section
-Ttext-segment ADDRESS Set address of text segment
--unresolved-symbols=
How to handle unresolved symbols. is:
ignore-all, report-all, ignore-in-object-files,
ignore-in-shared-libs
--verbose Output lots of information during link
--version-script FILE Read version information script
--version-exports-section SYMBOL
Take export symbols list from .exports, using
SYMBOL as the version.
--dynamic-list-data Add data symbols to dynamic list
--dynamic-list-cpp-new Use C++ operator new/delete dynamic list
--dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
--dynamic-list FILE Read dynamic list
--warn-common Warn about duplicate common symbols
--warn-constructors Warn if global constructors/destructors are seen
--warn-multiple-gp Warn if the multiple GP values are used
--warn-once Warn only once per undefined symbol
--warn-section-align Warn if start of section changes due to alignment
--warn-shared-textrel Warn if shared object has DT_TEXTREL
--warn-alternate-em Warn if an object has alternate ELF machine code
--warn-unresolved-symbols Report unresolved symbols as warnings
--error-unresolved-symbols Report unresolved symbols as errors
--whole-archive Include all objects from following archives
--wrap SYMBOL Use wrapper functions for SYMBOL
@FILE Read options from FILE
ld: supported targets: elf64-x86-64 elf32-i386 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-little elf64-big elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex
ld: supported emulations: elf_x86_64 elf_i386 i386linux elf_l1om
ld: emulation specific options:
elf_x86_64:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility
elf_i386:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility
elf_l1om:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility
Report bugs to
man ld
ld(1) GNU Development Tools ld(1)
名前
ld - GNU リンカ
書式
ld [-o output] objfile...
[-Aarchitecture] [-b input-format] [-Bstatic] [-Bdynamic]
[-Bsymbolic] [-c commandfile] [--cref] [-d|-dc|-dp]
[-defsym symbol = expression] [-e entry] [-embedded-relocs] [-E]
[-export-dynamic] [-f name] [--auxiliary name] [-F name]
[--filter name] [-format input-format] [-g] [-G size] [-h name]
[-soname name] [--help] [-i] [-lar] [-Lsearchdir] [-M] [-Map
mapfile] [-m emulation] [-n|-N] [-noinhibit-exec]
[-no-keep-memory] [-no-warn-mismatch] [-oformat output-format]
[-R filename] [-relax] [-r|-Ur] [-rpath directory]
[-rpath-link directory] [-S] [-s] [-shared] [-sort-common]
[-split-by-reloc count] [-split-by-file] [-T commandfile]
[-Ttext textorg] [-Tdata dataorg] [-Tbss bssorg] [-t] [-u sym]
[-V] [-v] [--verbose] [--version] [-warn-common]
[-warn-constructors] [-warn-multiple-gp] [-warn-once]
[-warn-section-align] [--whole-archive] [--no-whole-archive]
[--wrap symbol] [-X] [-x]
説明
ld は複数のオブジェクトファイルや書庫 (archive) ファイルを結合し、それ
らのデータをリロケートして、シンボルの参照をまとめる。新たな実行プロ グ
ラ ムをコンパイルして作成する作業の最終ステップは、多くの場合 ld の呼び
出しとなる。
ld はリンカコマンド言語のファイルを受け付ける。このファイルでリンク処理
を明示的に、また完全に制御することができる。この man ページではコマンド
言語を説明していない。コマンド言語や GNU リンカのその他の内容に関する詳
細 は info の ‘ld’ エントリか、マニュアルである ld: the GNU linker を参
照すること。
ld の本バージョンではオブジェクトファイル関連の作業に汎用の BFD ライ ブ
ラ リを用いている。これによって ld では多くの異なるフォーマットのオブジ
ェクトファイルを読み、書き、結合することができるようになっている ( 例え
ば COFF や a.out)。異なるフォーマットをリンクして、あらゆる種類のオブジ
ェクトファイルを作成できる。サポートされているフォーマットや関連する ア
ー キ テ ク チ ャに関しては ‘ objdump -i’ を実行すればよい。詳細は obj-
dump(1) を見よ。
GNU リンカは柔軟であるだけでなく、診断 (diagnostic) メッセージも他の リ
ン カより詳しい。多くのリンカはエラーが生じるとすぐに動作を停止してしま
うが、 ld は可能な限り処理を続け、他のエラーに関しても知らせようとす る
( あるいはエラーにもかかわらず出力ファイルを作成してしまうことさえある)
。
GNU リンカ ld は多くの状況をカバーするように作成されている。また他の リ
ン カとできる限り互換性を保つようにしてある。したがって ld の振る舞いは
、コマンドラインや環境変数によって細かく制御できるようになっている。
オプション
コマンドラインオプションのあまりの多さに怖気づくかもしれないが、実際 の
作 業で指定されるオプションは、ほとんどの場合少ない。例として ld の良く
用いられる例、サポートされている標準的な Unix システムで標準 Unix の オ
ブ ジ ェクトファイルを作成する場合を考えよう。このようなシステムで hel-
lo.o ファイルをリンクする作業は以下のようになる。
$ ld -o output /lib/crt0.o hello.o -lc
この例では ld に output という名前のファイルを作成するように命令して い
る 。リンクするファイルは /lib/crt0.o 、 hello.o および標準的な検索ディ
レクトリにあるライブラリ libc.a である。
ld のコマンドラインオプションは任意の順序で指定でき、必要なだけ繰り返す
こ とができる。オプションの繰り返しは、多くの場合最初のもの以外を無視す
るか、先の指定 (コマンドラインの左にあるもの) を上書きするかになる。
例外 (複数回の指定が意味を持つもの) は以下の通り。 -A、-b (またはその同
義である -format)、 -defsym、-L、-l、-R、-u。
リンクする (複数の) オブジェクトファイルは objfile として与えるが、これ
はコマンドラインでオプションの後、前、あるいは混ぜて置いても構わない 。
ただし objfie をオプションのフラグとその引数の間に置くことはできない。
通 常リンカの実行には最低一つのオブジェクトファイルが指定されるが、異な
るフォーマットを持つバイナリファイルを -l、-R やスクリプトコマンド言 語
で 指定することもできる。バイナリの入力ファイルが一つも指定されない場合
には、リンカは出力ファイルを作成せず、 ‘ No input files’ というメッセー
ジを表示する。
オ プションの引数はオプション文字の直後にスペースなしで続けることもでき
るし、オプションの次に別の引数として置くこともできる。
-Aarchitecture
ld のこのリリースでは、このオプションは Intel 960 アーキテクチャ
の フ ァミリに対してのみ意味を持つ。このファミリ向けに設定された
ld では、 architecture 引数は 960 ファミリのメンバーを示す 2 文
字の名前のどれかを指定する。このオプションは出力ターゲットを指定
し、入力ファイルにある非互換な命令全てに対して警告メッセージを表
示する。またリンカが書庫ライブラリを検索する方法を変更し、指定さ
れたアーキテクチャに特有のライブラリが利用できるようにする。これ
は検索するファイルに、アーキテクチャを示す文字列を後置したものを
加えることによってなされる。
例えば使用している ld のコマンドラインに -ACA または -ltry が あ
れば、リンカは組み込みの検索パスと -L で指定されたパスを探し、以
下のような名前のライブラリを見つけようとする。
try
libtry.a
tryca
libtryca.a
最初の二つはどんな場合でも検索されるものであり、後の二つは -ACA
を用いたことによって加わったものである。
ld の将来のリリースでは、同じような機能が他のアーキテクチャファ
ミリでもサポートされる可能性がある。
-A オプションはコマンドラインで複数回用いられると、それぞれが 意
味を持つ。ただしアーキテクチャファミリがターゲットの組み合わせを
許す場合に限られる。それぞれの指定によって、 -l で指定されたライ
ブラリに名前のバリエーションを付けたものが検索される。
-b input-format
コマンドラインでこのオプションに続いて指定された入力オブジェクト
ファイルのバイナリフォーマットを指定する。通常この指定は必要ない
。 ld はそれぞれのマシンで最も一般的なフォーマットをデフォルトの
入力フォーマットとするように設定されているからであ る 。 input-
format はテキスト文字列で、 BFD ライブラリによってサポートされて
いる特定のフォーマットの名前である。 -format input-format はスク
リプトコマンド TARGET と同じ効力を持つ。
一般的なバイナリフォーマットではないファイルをリンクする場合に、
このオプションを指定することになる。また異なるフォーマットのオブ
ジェクトファイルをリンクする際に、フォーマットを明示的に変更する
目的に -b を使うこともできる。この際には -b input-foramt をそ れ
ぞれのフォーマットに属するオブジェクトファイル群の前に挿入する。
デフォルトのフォーマットは環境変数 GNUTARGET から取得される。 ス
クリプトでコマンド TARGET を用いて入力フォーマットを設定すること
もできる。
-Bstatic
共有ライブラリに対するリンクをしない。これは共有ライブラリをサポ
ートしているプラットフォームにおいてのみ意味を持つ。
-Bdynamic
動的ライブラリに対してリンクする。これは共有ライブラリをサポート
しているプラットフォームにおいてのみ意味を持つ。そのようなプラッ
トフォームではこのオプションは通常デフォルトになっている。
-Bsymbolic
共有ライブラリを作る場合、グローバルシンボルへの参照を共有ライブ
ラリ内部の定義 (definition) と結合する。共有ライブラリにリンクさ
れるプログラムでは、通常この共有ライブラリ内部の定義を上書きする
ことができる。このオプションが意味を持つのは共有ライブラリをサポ
ートする ELF プラットフォームのみである。
-c commandfile
commandfile からリンクコマンドを読むように ld に指示する。これら
のコマンドは ld デフォルトのリンクフォーマットを完全に上書きする
( デフォルトに追加されるわけではない)。 commandfile ではターゲッ
トフォーマットに関して必要な記述がすべてされていなければならない
。
リンクコマンドのスクリプトは、コマンドラインでも指定できる。これ
にはスクリプトの文字列をブラケット (‘{’ と ‘}’) で囲う。
--cref クロスリファレンスのテーブルを出力する。リンカのマップファイルが
生成される場合には、クロスリファレンステーブルはマップファイルに
出力される。それ以外の場合には標準出力に表示される。
-d
-dc
-dp これらの 3 つのオプションは等価である。複数の形式があるのは他 の
リ ンカとの互換性のためである。これらのいずれかを指定すると、 ld
はリロケータブル出力ファイルが指定 (-r) された場合でも共通シンボ
ル のための領域を割り当てる。スクリプトコマンド FORCE_COMMON_AL-
LOCATION が同じ効力を持つ。
-defsym symbol = expression
expression によって与えられた絶対アドレスを含むグローバルシン ボ
ルを出力ファイルに生成する。このオプションは必要なだけコマンドラ
インに指定でき、複数のシンボルを定義することができる 。 expres-
sion の指定には簡単な算術もサポートされている。 16 進定数や存在
する他のシンボルを与えたり、 + や - をそれらの間の足し引きに用い
ることもできる。より手の込んだ数式が必要な場合には、スクリプトで
リンカコマンド言語を用いることをすすめる。
-e entry
entry をプログラムのエントリポイントを示すシンボルとして取り扱う
(デフォルトのエントリポイントを上書きする)。デフォルトと他のエン
トリポイントの指定方法については ld の info の *Note Entry
Point:: を参照すること。
-embedded-relocs
こ の オ プ シ ョンが意味を持つのは GNU コンパイラやアセンブラの
-membedded-pic オプションによって生成された MIPS embedded な PIC
コードをリンクする場合だけである。これはリンカにテーブルを生成さ
せる。このテーブルは、ポインタ値に対して static に初期化された全
て の データを実行時にリロケートする際に用いられる。詳細は test-
suite/ld-empic 内部のコードを参照のこと。
-E
-export-dynamic
ELF ファイルを作成する際に、全てのシンボルをダイナミックなシンボ
ルテーブルに追加する。通常ダイナミックシンボルテーブルには動的な
オブジェクトによって用いられるシンボルのみが含まれている。このオ
プションは dlopen を使う場合などに必要となる。
-f name
--auxiliary name
ELF 共有オブジェクトを作成する際に、内部の DT_AUXILIARY フィール
ドを指定した名前に設定する。この指定によって、ダイナミックリンカ
は扱っている共有オブジェクトのシンボルテーブルを、他の共有オブジ
ェクト name のシンボルテーブルの補助フィルタとして用いるようにな
る。
-F name
--filter name
ELF 共有オブジェクトを作成する際に、内部の DT_FILTER フィールド
を指定した名前に設定する。この指定によって、ダイナミックリンカは
そ の 共有オブジェクトのシンボルテーブルを、他の共有オブジェクト
name のシンボルテーブルのフィルタとして用いるようになる。
-format input-format
-b input-format と同義。
-g 受け付けるが無視される。他のツールとの互換性のために用意されてい
る。
-G size
MIPS ECOFF において、 GP レジスタを用いて最適化するオブジェクト
の最大サイズを size に設定する。他のオブジェクトファイルフォーマ
ットでは無視される。
-h name
-soname name
ELF 共有オブジェクトを作成するとき、内部の DT_SONAME フィールド
を指定した名前に設定する。実行ファイルが DT_SONAME フィールド を
持つ共有オブジェクトとリンクされると、これの実行時にダイナミック
リンカは DT_SONAME によって指定された共有オブジェクトをロード し
よ うとする (通常はリンカに対して指定されたファイルをロードする)
。
--help コマンドラインオプションの要約を標準出力に表示して終了する。この
オプションと --version は、他の GNU プログラムとの互換性のためダ
ッシュ (-) 二つで始まる。これ以外のオプションは他のリンカとの 互
換性のためダッシュ一つで始まる。
-i インクリメンタルリンクを実行する (オプション -r と同じ)。
-lar アーカイブファイル ar をリンクするファイルのリストに加える。この
オプションは何回でも指定できる。 ld は ar が指定されるごと に 、
libar.a が見つかるまで検索パスを探す。
-Lsearchdir
こ のコマンドは searchdir を ld の書庫ライブラリの検索パスに追加
する。このオプションは必要なだけ指定できる。
デフォルトの検索パス (-L が指定されなかったときの検索パス) は ld
が用いているエミュレーションのモードに依存する。また設定に依存す
る場合もある。リンクスクリプトでは SEARCH_DIR コマンドを用いてこ
のパスを設定することもできる。
-M 標準出力にリンクマップを表示する。リンクマップには ld によってマ
ップされたシンボルの位置情報とグローバルな共通メモリ領域の割当て
情報が含まれている。
-Map mapfile
フ ァ イル mapfile にリンクマップを出力する。リンクマップには ld
によってマップされたシンボルの位置情報とグローバルな共通 storage
の割当て情報が含まれている。
-m emulation
リ ンカ emulation をエミュレートする。エミュレートできるもののリ
ストは --verbose または -V で得られる。このオプションはコンパ イ
ル 時のデフォルト (ld の設定を行ったシステム向けのリンカ) を上書
きする。
-N text と data セクションを読み書き可能にする。出力フォーマット が
Unix スタイルのマジック・ナンバーをサポートしている場合は、出力
ファイルに OMAGIC がマークされる。
-N オプションを指定するとリンカは data セグメントのページ位置 調
整を行わない。
-n text セグメントをリードオンリーにする。可能な場合は NMAGIC が書
き込まれる。
-noinhibit-exec
通常リンカはリンク処理の途中でエラーになると出力ファイルを生成し
ない。このフラグをもちいると致命的でないエラーの場合には出力ファ
イルを残すように指定できる。
-no-keep-memory
通常リンカはメモリ消費量よりも実行速度を優先するように最適化され
ている。すなわち入力ファイルのシンボルテーブルがメモリにキャッシ
ュされている。このオプションを指定すると、メモリ消費を抑えるよう
に なる (必要に応じてシンボルテーブルを読み直す)。このオプション
は大きな実行ファイルをリンクするとき、メモリを使い果たしてしまう
ような場合に指定する必要がある。
-no-warn-mismatch
何らかの理由でマッチしない入力ファイルをいっしょにリンクしようと
すると、リンカは通常エラーになります。この原因としては、それらの
入力ファイルが異なるプロセッサ用に、あるいは異なるエンディアン用
にコンパイルされたなどが考えられます。このオプションを指定すると
、リンカはこの種の潜在的なエラーを黙って許可します。このオプショ
ンは不用意に使うべきではありません。リンカのエラーをどうしても避
けたいような、特殊な作業を行っているときに限るべきです。
-o output
output は ld によって作成されるプログラムの名前である。このオプ
ションが指定されなかった場合は a.out がデフォルトとして用いら れ
る。スクリプトコマンド OUTPUT でも出力ファイル名を指定できる。
-oformat output-format
出力されるオブジェクトファイルのバイナリフォーマットを指定する。
通常はこのオプションは必要ない。 ld でのデフォルトの出力フォーマ
ットは、それぞれのマシンで最も普通のフォーマットになるように設定
されているからである。 output-format はテキスト文字列で、 BFD ラ
イブラリでサポートされている特定のフォーマットの名前である。スク
リプトコマンド OUTPUT_FORMAT でも出力フォーマットを指定できる 。
しかしこのオプションはスクリプトでの指定を上書きする。
-R filename
シンボル名とそれらのアドレスを filename から読み込む。しかしそれ
らのリロケートや出力への追加は行わない。これによって出力ファイル
で は、(他のプログラムで定義された) メモリ上の絶対アドレスをシン
ボルを用いて参照できることになる。
-relax 機能はマシンに依存する。現在では H8/300 でのみサポートされている
。
プラットフォームによっては、このオプションを指定するとグローバル
な最適化を行う場合もある。これはリンカがプログラムのアドレスを置
き換える (出力されるオブジェクトファイルのアドレスモードを relax
させたり新しい命令を同期させる) 場合に可能となる。
サポートされていないプラットフォームでは、 -relax は受け付けられ
るが何も起こらない。
-r リロケータブルな出力を生成する。すなわち再び ld の入力として用い
ることができるようなファイルを生成する。これはしばしば部分 (par-
tial) リンクと呼ばれる。また標準 Unix のマジック・ナンバーをサポ
ートする環境では、このオプションは出力ファイルのマジック・ナンバ
ーを OMAGIC にする。このオプションが指定されなかった場合は、完全
なファイルが生成される。 C++ プログラムをリンクする場合、この オ
プ ションはコンストラクタへの参照を解決しない。 C++ の場合には代
わりに -Ur を用いることができる。
このオプションは -i と同じ。
-rpath directory
ディレクトリを実行時ライブラリの検索パスに追加する。これ は ELF
の 実 行ファイルを共有オブジェクトとリンクするときに用いられる。
-rpath の引き数は全て結合され、ダイナミックリンカに渡される。 ダ
イナミックリンカは、これを用いてロードする共有オブジェクトを実行
時に決定する。 -rpath オプションはリンクに明示的に含まれている共
有オブジェクトによって必要とされる別の共有オブジェクトを指定する
のに用いることもできる。 -rpath-link オプションの説明を 見 よ 。
ELF 実行ファイルの -rpath が指定されない場合には、 (指定されてい
れば) 環境変数 LD_RUN_PATH の値が用いられる。
-rpath オプションは SunOS で用いることもできる。 SunOS のデフ ォ
ルトでは、リンカは実行時の検索パスを -L オプションで与えられたパ
スから生成する。 -rpath が用いられると、実行時 の 検 索 パ ス は
-rpath オプションで与えられたパスのみから生成され、 -L オプショ
ンは無視される。これは gcc を使っていて、 -L がたくさん指定さ れ
て しまう (これらは NFS マウントされたファイルシステムかもしれな
い) 場合などに便利である。
-rpath-link directory
ELF か SunOS を用いている場合、ある共有ライブラリが別の共有ラ イ
ブラリを必要とする場合がある。これは ld -shared によるリンクで入
力ファイルに共有ライブラリが含まれている場合に起こる。
リンカが非共有 (非リロケータブル) なリンクを行っているときに、こ
のような依存関係に遭遇すると、リンカは自動的にその必要とされてい
る共有ライブラリも (明示されていなくても) リンクしてしまおうとす
る 。このような場合に -rpath-link オプションは検索する最初のディ
レクトリセットを指定する。 -rpath-link オプションではディレク ト
リ名の並びをコロンで区切って一度に指定することもできるし、複数回
用いて指定することもできる。
必要な共有ライブラリが見つからないと、リンカは警告を出してリンク
処理を継続しようとする。
-S 出力ファイルからデバッガのシンボル情報を削除する (全てのシンボル
ではない)。
-s 出力ファイルから全てのシンボル情報を削除する。
-shared
共有ライブラリを生成する。現在のところ ELF と SunOS プラットフォ
ー ムでのみサポートされている (実際には SunOS では不要である。な
ぜならリンカは未定義シンボルが存在していたり -e オプションが指定
されている場合には自動的に共有ライブラリを生成するからである)。
-sort-common
通常 ld がグローバルな共通シンボルをそれぞれの出力セクションに配
置するにあたっては、それらはサイズによってソートされる。ま ず 1
バイト変数のシンボル、ついで 2 バイト、 4 バイト変数のシンボル、
最後にそれ以外のものが並ぶ。このオプションはアラインメントによっ
て生じてしまうシンボル間のギャップを防止する。このオプションはソ
ートを行わないようにする。
-split-by-reloc count
出力ファイルに余分なセクションを生成して、ファイル中のそれぞれの
出 力セクションが count 以上のリロケーションを含まないようにする
。これは COFF オブジェクトファイルフォーマットの巨大なリロケータ
ブルファイルを、リアルタイムカーネルにダウンロードする場合などに
役に立つ。 COFF はセクションあたり 65535 以上のリロケーション を
持てないからである。任意のセクションをサポートしていないフォーマ
ットでは、このオプションは機能しないことに注意。リンカはそれぞれ
の入力セクションを分割して再配置するわけではない。したがって入力
ファイルのセクションに count 以上のリロケーションを含むものが あ
れば、それに対応してそれだけのリロケーションを持った出力セクショ
ンは作成されてしまう。
-split-by-file
-split-by-reloc と似ているが、それぞれの入力ファイルに対して新た
な出力セクションを生成する。
-Tbss org
-Tdata org
-Ttext org
そ れぞれ出力ファイルの bss、 data、 text セグメントに対して org
を開始アドレスにする。 org は 16 進の整数でなければならない。
-T commandfile
-c commandfile と等価である。他のツールとの互換性のために用意 さ
れた。
-t 入力ファイルを ld が処理するごとに、ファイルの名前を表示する。
-u sym sym を出力ファイルに未定義なシンボルとして挿入する。例えばこれは
、標準ライブラリから付加的なモジュールをリンクするトリガに使うこ
とができる。 -u は必要な未定義シンボルの数だけ繰り返すことができ
る。
-Ur C++ プログラム以外では、このオプションは -r と等価であり、リロケ
ータブルな出力を生成する (つまり再び ld の入力ファイルに用いるこ
とのできるファイルを出力する)。 C++ プログラムをリンクする際には
、 -Ur は -r と異なり、コンストラクタへの参照を解決する。
--verbose
ld のバージョン番号を表示し、サポートされているエミュレーション
をリストする。入力ファイルがそれぞれオープンできるかどうかも表示
する。
-v, -V ld のバージョン番号を表示する。 -V はサポートされているエミュレ
ーションもリストする。
--version
ld のバージョン番号を表示して終了する。
-warn-common
共通シンボルが他の共通シンボルやシンボル定義と結合されている場合
に警告を発する。 Unix のリンカはこの点には比較的寛容であるが、他
の OS のリンカにはそうでないものもある。このオプションはグローバ
ルシンボルを結合することによって生じる問題点を見つける手がかりに
なるかもしれない。
-warn-constructors
グローバルコンストラクタが用いられたら警告を発する。これが意味を
持 つオブジェクトファイルフォーマットは少ない。 COFF や ELF では
、リンカはグローバルコンストラクタを検出することができない。
-warn-multiple-gp
出力ファイルに複数のグローバルなポインタ値が必要な場合に警告を発
す る。このオプションが意味を持つのは、 Alpha のような特殊なプロ
セッサだけである。
-warn-once
未定義シンボルに関する警告をシンボルごとに一度だけにする。デフォ
ルトではそのシンボルを参照するモジュール一つについて一回警告が出
る。
-warn-section-align
出力セクションのアドレスがアラインメントのために変更された場合に
警告を出す。通常アラインメントは入力セクションによって設定される
。アドレスは明示的に指定されなかった場合 (つまり SECTIONS コマン
ドがセクションのスタートアドレスを指定しなかった場合) にのみ変更
されうる。
--whole-archive
コマンドラインでこのオプション以降に指定されたそれぞれの書庫に対
して、書庫内部の全てのオブジェクトファイルをリンクする (デフォル
トでは書庫から必要なオブジェクトファイルを検索する)。これは通 常
書庫ファイルを共有ライブラリに変えるとき、内部のオブジェクトを全
て共有ライブラリに含めるために指定される。
--no-whole-archive
コマンドラインでこのオプション以降に現わ れ る 書 庫 に 対 し て
--whole-archive オプションの効果を無効にする。
--wrap symbol
symbol に対してラッパ機能を用いる。 symbol への未定義な参照は全
て __wrap_symbol として解決される。また __REAL_symbol への未定義
な参照はすべて symbol として解決される。
-X 一時的なローカルシンボルをすべて削除する。ほとんどのターゲットで
は、これは ‘L’ で始まるローカルシンボルを意味する。
-x ローカルシンボルを全て削除する。
環境変数
ld の動作は環境変数 GNUTARGET によって変更することができる。
GNUTARGET は -b (または等価なオプション -format) を用いない場合の入力フ
ァ イルのオブジェクトフォーマットを定義する。この値は入力フォーマットに
対して有効な BFD 名の一つでなければならない。 GNUTARGET が default に設
定されていた場合には、 BFD は入力されるバイナリファイルを調べて入力フォ
ーマットを決定しようとする。これは通常は成功するが、決定できない可能 性
も ある。オブジェクトファイルフォーマットで用いられているマジック・ナン
バーが一意であることを保証する方法は存在しないからである。しかし BFD を
そ れぞれのシステムで設定する際には、そのシステムに一般的なフォーマット
が検索リストの最初の方に置かれる。したがって複数フォーマットの可能性 が
存在した場合には、より一般的なフォーマットとして解釈される。
関連項目
objdump(1)
info の ‘ld’ および ‘binutils’ エントリ
ld: the GNU linker , Steve Chamberlain and Roland Pesch; The GNU Binary
Utilities , Roland H. Pesch
著作権
Copyright (c) 1991, 1992 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the en-
tire resulting derived work is distributed under the terms of a permis-
sion notice identical to this one.
Permission is granted to copy and distribute translations of this manu-
al into another language, under the above conditions for modified ver-
sions, except that this permission notice may be included in transla-
tions approved by the Free Software Foundation instead of in the origi-
nal English.
cygnus support 17 August 1992 ld(1)
LD(1) GNU Development Tools LD(1)
NAME
ld - The GNU linker
SYNOPSIS
ld [options] objfile ...
DESCRIPTION
ld combines a number of object and archive files, relocates their data
and ties up symbol references. Usually the last step in compiling a
program is to run ld.
ld accepts Linker Command Language files written in a superset of
AT&T’s Link Editor Command Language syntax, to provide explicit and
total control over the linking process.
This man page does not describe the command language; see the ld entry
in "info" for full details on the command language and on other aspects
of the GNU linker.
This version of ld uses the general purpose BFD libraries to operate on
object files. This allows ld to read, combine, and write object files
in many different formats---for example, COFF or "a.out". Different
formats may be linked together to produce any available kind of object
file.
Aside from its flexibility, the GNU linker is more helpful than other
linkers in providing diagnostic information. Many linkers abandon
execution immediately upon encountering an error; whenever possible, ld
continues executing, allowing you to identify other errors (or, in some
cases, to get an output file in spite of the error).
The GNU linker ld is meant to cover a broad range of situations, and to
be as compatible as possible with other linkers. As a result, you have
many choices to control its behavior.
OPTIONS
The linker supports a plethora of command-line options, but in actual
practice few of them are used in any particular context. For instance,
a frequent use of ld is to link standard Unix object files on a
standard, supported Unix system. On such a system, to link a file
"hello.o":
ld -o