.\" Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, .\" 2001 Free Software Foundation, Inc. .\" See section COPYING for conditions for redistribution .\" .\" Copyright (c) 2001 FreeBSD jpman project .\" This is for Japanese translation done by FreeBSD jpman project. .\" %FreeBSD: src/contrib/binutils/ld/ld.1,v 1.2.2.3 2001/08/01 23:03:10 obrien Exp % .\" $FreeBSD$ .TH ld 1 "" "Free Software Foundation" "GNU Development Tools" .de BP .sp .ti \-.2i \(** .. .SH 名称 ld \- GNU リンカ .SH 書式 .hy 0 .na .TP .B ld .RB "[\|" \-o " .I output\c \&\|] \c .I objfile\c \&.\|.\|. .br .RB "[\|" \-A\c .I architecture\c \&\|] .RB "[\|" "\-b\ "\c .I input-format\c \&\|] .RB "[\|" \-Bstatic "\|]" .RB "[\|" \-Bgroup "\|]" .RB "[\|" \-Bdynamic "\|]" .RB "[\|" \-Bsymbolic "\|]" .RB "[\|" "\-c\ "\c .I commandfile\c \&\|] .RB "[\|" \-\-cref "\|]" .RB "[\|" \-d | \-dc | \-dp\c \|] .br .RB "[\|" "\-defsym\ "\c .I symbol\c \&=\c .I expression\c \&\|] .RB "[\|" \-\-demangle "\|]" .RB "[\|" \-\-no\-demangle "\|]" .RB "[\|" "\-e\ "\c .I entry\c \&\|] .RB "[\|" \-embedded\-relocs "\|]" .RB "[\|" \-E "\|]" .RB "[\|" \-export\-dynamic "\|]" .RB "[\|" "\-f\ "\c .I name\c \&\|] .RB "[\|" "\-\-auxiliary\ "\c .I name\c \&\|] .RB "[\|" "\-F\ "\c .I name\c \&\|] .RB "[\|" "\-\-filter\ "\c .I name\c \&\|] .RB "[\|" "\-format\ "\c .I input-format\c \&\|] .RB "[\|" \-g "\|]" .RB "[\|" \-G .I size\c \&\|] .RB "[\|" "\-h\ "\c .I name\c \&\|] .RB "[\|" "\-soname\ "\c .I name\c \&\|] .RB "[\|" \-\-help "\|]" .RB "[\|" \-i "\|]" .RB "[\|" \-l\c .I ar\c \&\|] .RB "[\|" \-L\c .I searchdir\c \&\|] .RB "[\|" \-M "\|]" .RB "[\|" \-Map .I mapfile\c \&\|] .RB "[\|" \-m .I emulation\c \&\|] .RB "[\|" \-n | \-N "\|]" .RB "[\|" \-noinhibit-exec "\|]" .RB "[\|" \-no\-keep\-memory "\|]" .RB "[\|" \-no\-warn\-mismatch "\|]" .RB "[\|" \-O\c .I level\c \&\|] .RB "[\|" "\--oformat\ "\c .I output-format\c \&\|] .RB "[\|" "\-R\ "\c .I filename\c \&\|] .RB "[\|" \-relax "\|]" .RB "[\|" \-r | \-Ur "\|]" .RB "[\|" "\-rpath\ "\c .I directory\c \&\|] .RB "[\|" "\-rpath\-link\ "\c .I directory\c \&\|] .RB "[\|" \-S "\|]" .RB "[\|" \-s "\|]" .RB "[\|" \-shared "\|]" .RB "[\|" \-sort\-common "\|]" .RB "[\|" "\-split\-by\-reloc\ "\c .I count\c \&\|] .RB "[\|" \-split\-by\-file "\|]" .RB "[\|" "\-T\ "\c .I commandfile\c \&\|] .RB "[\|" "\-\-section\-start\ "\c .I sectionname\c \&=\c .I sectionorg\c \&\|] .RB "[\|" "\-Ttext\ "\c .I textorg\c \&\|] .RB "[\|" "\-Tdata\ "\c .I dataorg\c \&\|] .RB "[\|" "\-Tbss\ "\c .I bssorg\c \&\|] .RB "[\|" \-t "\|]" .RB "[\|" "\-u\ "\c .I sym\c \&] .RB "[\|" \-V "\|]" .RB "[\|" \-v "\|]" .RB "[\|" \-\-verbose "\|]" .RB "[\|" \-\-version "\|]" .RB "[\|" \-warn\-common "\|]" .RB "[\|" \-warn\-constructors "\|]" .RB "[\|" \-warn\-multiple\-gp "\|]" .RB "[\|" \-warn\-once "\|]" .RB "[\|" \-warn\-section\-align "\|]" .RB "[\|" \-\-whole\-archive "\|]" .RB "[\|" \-\-no\-whole\-archive "\|]" .RB "[\|" "\-\-wrap\ "\c .I symbol\c \&\|] .RB "[\|" \-X "\|]" .RB "[\|" \-x "\|]" .ad b .hy 1 .SH 解説 \c .B ld\c \& はいくつかのオブジェクトとアーカイブファイルを結合し、 データを再配置してシンボル参照を解決します。コンパイルされた 新しいプログラムが実行可能になるように、多くの場合 最終段階として \c .B ld\c \& が呼び出されます。 \c .B ld\c \& はリンク処理を明示的かつ総合的に制御する目的の リンカコマンド言語のファイルを受け付けます。 このマニュアルページではコマンド言語についてふれません; コマンド言語の詳細と GNUリンカの別の側面からの詳細については `\|\c .B info\c \|' の `\|\c .B ld\c \|' の項、またはマニュアル .I ld: the GNU linker \& を参照して下さい。 このバージョンの \c .B ld\c \& はオブジェクトファイルの操作に汎用の BFD ライブラリを使います。 これによって \c .B ld\c \& は多くの異なった形式 \(em\& 例えば COFF や \c .B a.out\c \& のようなオブジェクトファイル \(em\& の読み込み、結合、書き込みが 出来るようになっています。異なる形式のファイルを、利用可能な いずれかの形式のオブジェクトファイルを生成するために一緒に リンクできます。`\|\c .B objdump \-i\c \|' で各種アーキテクチャでサポートされる形式の一覧を得られます; .BR objdump ( 1 ) を参照してください。 その柔軟性の一方で、GNU リンカは診断情報の提供という点で 他のリンカよりも親切です。多くのリンカは エラーを起こした時点で即座に実行を中断してしまいます; 可能であればいつでも \c .B ld\c \& は実行を続け、他のエラーも知らせます (または、場合によっては、エラーの代わりに出力ファイルを生成します)。 GNU リンカ \c .B ld\c \& は広い範囲の各種状況をカバーすること、 そして他のリンカと可能な限り互換性を持つことを意図しています。 その結果、コマンドラインと環境変数を通して動作を制御するための 多くの選択肢を提供しています。 .SH オプション 過度のコマンドラインオプションは恐ろしく見えるかもしれませんが、 実際にはいかなる局面においてでも使用されるオプションは少ししかありません。 例えば、\c .B ld\c \& がよく使われるのは標準の Unix の オブジェクトファイルを、標準のサポートしている Unixシステム上で リンクする場合です。そのようなシステムでは、\c .B hello.o\c \& というファイルをリンクするためには以下のようにします: .sp .br $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc .br .sp これは、\c .B output\c \& という名前のファイルを、 ファイル \c .B /lib/crt0.o\c \& と \c .B hello.o\c \& そして 標準で検索されるディレクトリから来るライブラリ \c .B libc.a\c \& をリンクした結果として生成する事を、 .B ld\c \& に対して指示しています。 .B ld\c \& へのコマンドラインオプションは 任意の順番で、何度でも繰り返してかまいません。 大抵の場合、異なる引数でオプションを繰り返すと なんの効果も無いか、または以前のオプションの指定 (コマンドラインで より左側にあるもの) を上書きします。 例外 \(em\& 2 回以上 意味を持って指定できる\(em\& は \c .B \-A\c \&, \c .B \-b\c \& (または その同義語の \c .B \-format\c \&), \c .B \-defsym\c \&, \c .B \-\-section\-start\c \&, \c .B \-L\c \&, \c .B \-l\c \&, \c .B \-R\c \&, \c .B \-u\c \& です。 .I objfile\c \& として示されているひとまとめにリンクされるオブジェクトファイルの リストは、コマンドラインオプションの後に続けても、前に置いても、また 混ぜてもかまいません; 引数 \c .I objfile\c \& をオプションフラグとその引数の間に置く事は出来ないので、 これは守って下さい。 通常、リンカは少なくとも 1 つのオブジェクトファイルを指定して 起動しますが、他の形式のバイナリ入力ファイルも \c .B \-l\c \&, \c .B \-R\c \& を使って、そしてスクリプトコマンド言語で指定できます。 バイナリ入力ファイルがまったく .I 指定されない\c \& 場合は、リンカは出力ファイルを生成しません。そして `\|\c .B No input files\c \|' というメッセージを出します。 オプションの引数は空白をはさまずにオプション文字に続けるか、 その引数を必要とするオプションの直後に続けて独立した引数として 与えなければなりません。 .TP .BI "-A" "architecture" 現在リリースされている \c .B ld\c \& では、このオプションは Intel 960 ファミリの アーキテクチャでのみ使われます。そのような設定の \c .B ld\c \& では、引数の \c .I architecture\c \& には 960 ファミリのメンバを指定する 2 文字の名称のいずれかを指定します; オプションは必要な出力のターゲットを指定して、 入力ファイル中に非互換な命令があれば警告します。 またリンカがアーカイブライブラリを検索する方式も変更します。 個々のアーキテクチャに特有なライブラリを使うようにするために、 アーキテクチャを識別する文字列をサフィックスに加えた名前を 検索ループに含めます。 例えば、\c .B ld\c \& のコマンドラインに `\|\c .B \-ACA\c \|' を `\|\c .B \-ltry\c \|' と共に指定すると、リンカは (組み込まれているサーチパスと、\c .B \-L\c \& で指定されたすべてのパスについて) 以下の名前のライブラリを探します。 .sp .br try .br libtry.a .br tryca .br libtryca.a .br .sp 最初の 2 つの候補は常に検索されます; 後ろの 2 つは `\|\c .B \-ACA\c \|' を指定した事によるものです。 将来の \c .B ld\c \& のリリースでは他のアーキテクチャファミリでも同様の機能を サポートするかもしれません。 アーキテクチャファミリがターゲットアーキテクチャの組合せを 認めるのなら、意味を持ってコマンドライン上で 2 回以上 \c .B \-A\c \& を指定することが出来ます; \c .B \-l でライブラリが指定される時に、それぞれの指定による別の派生の 名前のペアが検索のために追加されます。 .TP .BI "\-b " "input-format" コマンドライン上でこのオプションに続いている入力オブジェクトファイルの バイナリ形式を指定します。 通常はこれを指定する必要はありません。 それぞれのマシン上で最も一般的な形式がデフォルトの入力形式であると 期待するように、\c .B ld\c \& が設定されているからです。 \c .I input-format\c \& は文字列テキストで、BFD ライブラリでサポートされる 形式名です。 \c .B \-format \c .I input-format\c \&\c \& と、スクリプトコマンド中の .BR TARGET も同じ機能です。 ファイルを通常でないバイナリ形式とリンクする場合にこのオプションを 使いたいかも知れません。 (異なる形式のオブジェクトファイルとリンクする時に) 同様に \c .B \-b\c \& で明示的に形式を切り替えられます。その場合は \c .B \-b \c .I input-format\c \&\c \& を特定の形式のオブジェクトファイルの各グループの前で 指定します。 デフォルトの形式は環境変数 .B GNUTARGET\c \& からとられます。スクリプトから入力形式を指定する事もでき、 その場合は \c .B TARGET\c \& コマンドを使います。 .TP .B \-Bstatic 共有ライブラリとリンクしません。これは共有ライブラリを サポートしているプラットフォーム上でのみ意味を持ちます。 .TP .B \-Bdynamic ダイナミックライブラリとリンクします。 これは共有ライブラリをサポートしている プラットフォームでのみ意味を持ちます。そのようなプラットフォームでは 通常このオプションがデフォルトです。 .TP .B \-Bgroup .B DF_1_GROUP フラグを、動的セクションの .B DT_FLAGS_1 エントリにセットします。 これにより、実行時リンカが行うオブジェクト内の検索と依存関係の実行が、 グループ内に限定されます。 未定義シンボルは許されません。 共有ライブラリをサポートする ELF プラットフォームでのみ意味があります。 .TP .B \-Bsymbolic 共有ライブラリを作成する際に、もしあれば、グローバルシンボルへの 参照を共有ライブラリ内の定義と対応づけます。通常は 共有ライブラリとリンクされたプログラムが共有ライブラリ内の 定義を上書きする事が可能です。このオプションは 共有ライブラリをサポートする ELF のプラットフォームでのみ意味を持ちます。 .TP .BI "\-c " "commandfile" ファイル \c .I commandfile\c \& からリンクコマンドを読み込むよう \c .B ld\c \& に指示します。 読み込まれたコマンドは \c .B ld\c \& のデフォルトのリンク形式を (付け加えるのではなく) 完全に置き換えます; \c .I commandfile\c \& には目的の形式を指示するために必要な物をすべて 書いておかなければなりません。 リンクコマンドのスクリプトをコマンドラインで直接 指定することも可能で、その場合はそれを文字 `\|\c .B {\c \|' と `\|\c .B }\c \|' で囲んで指定します。 .TP .B \-\-cref クロスリファレンステーブルを出力します。リンクマップファイルが 生成されていれば、クロスリファレンステーブルがマップファイルに 出力されます。そうでない場合は標準出力に表示されます。 .TP .B \-d .TP .B \-dc .TP .B \-dp これらの 3 つのオプションは等価です; 他のリンカとの互換性のために 複数の形式がサポートされています。再配置可能なファイルを出力する ように指定された場合 (\c .B \-r\c \&) でもコモンシンボルに空間を割り当てるよう \c .B ld に指示する場合に、いずれかを使います。 スクリプト中での \c .B FORCE_COMMON_ALLOCATION\c \& コマンドも同じ効果を持ちます。 .TP .BI "-defsym " "symbol" "\fR=\fP" expression 出力ファイル中に \c .I expression\c \& で与えられた絶対アドレスを持つグローバルシンボルを生成します。 複数のシンボルを定義するためにコマンドラインで必要回数だけ このオプションを指定してかまいません。この文脈では 限定されますが \c .I expression\c \& として式を使う事ができます: 16 進定数や定義済シンボル、 または \c .B +\c \& と \c .B \-\c \& で 16 進定数や定義済シンボルの加減算を行えます。 より手の込んだ式が必要であれば、スクリプトから リンカコマンド言語を使う事を検討してください。 .TP .B \-\-demangle .TP .B \-\-no\-demangle このオプションは、 エラーメッセージや他の出力において、 シンボル名を元に戻す (demangle する) か否かを制御します。 リンカが元に戻すように指示された場合、シンボル名を可読形式にしようとします。 すなわち、 オブジェクトファイルが使用しているならば先頭のアンダスコアを削除し、 C++ で変換されたシンボル名をユーザが可読な名前に変換します。 リンカは、デフォルトでは元に戻す動作を行いますが、環境変数 .B COLLECT_NO_DEMANGLE が設定されている場合は例外です。 これらのオプションを使用してデフォルトを上書き可能です。 .TP .BI "-e " "entry"\c \& プログラムの実行開始番地を示す明示的なシンボルとして、 デフォルトの開始番地の代わりに \c .I entry\c を使用します。 デフォルトと開始番地指定の他の方法については .B info\c の .B ld\c の項を参照してください。 .TP .B \-embedded\-relocs このオプションは、 .B \-membedded\-pic オプションを GNU コンパイラとアセンブラに指定して生成した MIPS 組み込み用位置独立コードをリンクする場合にのみ意味を持ちます。 これによってリンカは、ポインタ値に初期化されている静的変数を 実行時に再配置するために利用できるテーブルを生成するようになります。 詳しくは testsuite/ld-empic にあるコードを参照してください。 .TP .B \-E .TP .B \-export\-dynamic ELF ファイルを生成する際に、すべてのシンボルを実行時シンボルテーブルに 加えます。通常、実行時シンボルテーブルは実行時オブジェクトが 使用するシンボルだけを含みます。このオプションは .I dlopen を使用する場合に必要です。 .TP .BI "-f " "name" .TP .BI "--auxiliary " "name" ELF の共有オブジェクトを生成する際に、内部の DT_AUXILIARY フィールドを 指定した name にセットします。これは、 共有オブジェクトのシンボルテーブルを、 共有オブジェクト .I name のシンボルテーブルに適用する補助のフィルタとして使う事を、 実行時リンカに対して指示します。 .TP .BI "-F " "name" .TP .BI "--filter " "name" ELF の共有オブジェクトを生成する際に、内部の DT_FILTER フィールドを 指定した name にセットします。これは、 共有オブジェクトのシンボルテーブルを、 共有オブジェクト .I name のシンボルテーブルに適用するフィルタとして使う事を、 実行時リンカに対して指示します。 .TP .BI "\-format " "input\-format" .B \-b\c \& \c .I input\-format\c \& と同意です。 .TP .B \-g 受け付けますが、無視されます; 他のツールとの互換性のために提供されています。 .TP .BI "\-G " "size"\c MIPS ECOFF において GP レジスタを使って最適化されるオブジェクトの 最大サイズを .I size にします。他のオブジェクトファイル形式では無視されます。 .TP .BI "-h " "name" .TP .BI "-soname " "name" ELF の共有オブジェクトを生成する際に、内部の DT_SONAME フィールドを 指定した name にセットします。実行形式が DT_SONAME フィールドを持つ 共有オブジェクトとリンクされると、実行形式が実行される時に、 実行時リンカはリンカに与えられたファイル名を使う代わりに DT_SONAME フィールドで指定された共有オブジェクトをロードしようとします。 .TP .B \-\-help コマンドラインオプションのサマリを標準出力に表示して終了します。 このオプションと、1 つではなく 2 つのダッシュで始まる .B \-\-version は他の GNUプログラムとの互換性のためのものです。 1 つだけのダッシュで始まる他のオプションは他のリンカとの互換性のための ものです。 .TP .B \-i インクリメンタルリンクを行います (\c .B \-r\c \& オプションと同じです)。 .TP .BI "\-l" "ar"\c \& アーカイブファイル \c .I ar\c \& をリンクするファイルのリストに加えます。このオプションは 何度でも指定できます。\c .B ld\c \& は、指定された各 \c .I ar について \c .B lib\c .I ar\c \&.a\c \& を自己のパスリストから探します。 .TP .BI "\-L" "searchdir" このコマンドはパス \c .I searchdir\c \& を、 \c .B ld\c \& がアーカイブライブラリを探すパスのリストに追加します。 このオプションは何度でも指定して構いません。 デフォルトで (\c .B \-L\c \& で指定されずに) 探すパスの組は \c .B ld\c \& がどのエミュレーションモードを使っているか、そして 場合によってはどうコンフィギュレーションされているか、 に依存します。パスはリンクスクリプトの中でも .B SEARCH_DIR コマンドを使って指定できます。 .TP .B \-M リンクマップ \(em\& \c .B ld\c \& によってシンボルがどこに配置されたかの診断情報、そして グローバルなコモン領域の配置情報 \(em\& を (標準出力ファイルへ) 出力します。 .TP .BI "\-Map " "mapfile"\c ファイル .I mapfile にリンクマップ \(em\& \c .B ld\c \& によってシンボルがどこに配置されたかの診断情報、そして グローバルなコモン領域の配置情報 \(em\& を出力します。 .TP .BI "\-m " "emulation"\c .I emulation で指定されたリンカをエミュレートします。 .I emulation として指定できる物は .I \-\-verbose か .I \-V オプションでリストできます。このオプションは、 .BR ld をコンパイルする際にコンフィギュレーションでデフォルトとして指定して 埋め込まれている目的システムに優先します。 .TP .B \-N .B text\c \& と \c .B data\c \& セクションを読み書き可能にする指定です。 出力形式が Unix スタイルのマジックナンバをサポートしているなら、 出力は \c .B OMAGIC\c \& とマークされます。 `\|\c .B \-N\c \&\|' オプションを指定した場合は、リンカは データセグメントをページ境界に合わせることをしません。 .TP .B \-n テキストセグメントを読み込み専用にします。そして可能であれば \c .B NMAGIC\c \& が書き込まれます。 .TP .B \-noinhibit\-exec 通常、リンカはリンク処理中にエラーがあった場合は出力ファイルを生成しません。 このフラグを指定すると、致命的ではないエラーの後であっても 出力ファイルを残しておく事を望んでいる事を指示できます。 .TP .B \-no\-keep\-memory 通常、リンカは速度面での最適化を、 入力ファイルのシンボルテーブルをメモリ中にキャッシュすることでの メモリ使用量の増大よりも優先します。このオプションで、 そうではなく必要に応じてシンボルを再読み込みする事でメモリ使用量を 最適化する事を指示できます。大きな実行ファイルをリンクしている際に メモリ領域を使いきってしまうような場合に、このオプションが 必要になるかもしれません。 .TP .B \-no\-warn\-mismatch 通常、何らかの理由でマッチしない入力ファイル同士をリンクしようとすると、 リンカはエラーを起こします。 おそらくは、異なる プロセッサ用か異なるエンディアン向けにコンパイルされたことが原因でしょう。 このオプションは、そのような起こり得るエラーを黙って許容するよう、 リンカに対して指示します。このオプションは、リンカが エラーとする事が不適切と確証を持てる特別な処理を行う場合にのみ 注意深く使うべきです。 .TP .BI "\-o " "output" .I output\c \& が \c .B ld\c \& の生成するプログラム名です; このオプションが 指定されていない場合は、デフォルトの名前 `\|\c .B a.out\c \|' が使われます。 スクリプトのコマンド \c .B OUTPUT\c \& でも出力ファイル名を指定できます。 .TP .BI "\-O" "level" 最適化した出力ファイルを生成します。 非常に長い時間がかかるかもしれませんので、 最終的なバイナリを生成するときのみ有効にすべきかもしれません。 \c .I level\c \& は数値であるものとして扱われます。 0 より大きな値は最適化を有効にします。 .TP .BI "\--oformat " "output\-format" 出力オブジェクトファイルのバイナリ形式を指定します。\c .B ld\c \& はデフォルトの出力形式としてそれぞれのマシンで最も一般的な形式を 生成するようにコンフィギュレーションされているので、 通常はこれを指定する必要はありません。\c .I output-format\c \& は文字列テキストで、BFD ライブラリでサポートされる 形式名で指定します。スクリプトでのコマンド .B OUTPUT_FORMAT でも出力形式を指定できますが、このオプションはそれより優先されます。 .TP .BI "\-R " "filename" シンボル名とそのアドレスを \c .I filename\c \& から読み込みますが、それを再配置したり出力に 含めたりはしません。これによって、 他のプログラムが定義しているメモリ中の絶対番地を、 出力するファイルからシンボルで参照することが可能になります。 .TP .B \-relax マシン固有の効果を持つオプションです。現在はこのオプションは H8/300 でのみサポートされます。 プラットフォームによっては、このオプションでリンカがプログラム中の アドレッシングを解決する時にアドレスモードを緩めて、出力ファイルに 新しい命令を生成する広域最適化を行う事が可能になります。 これがサポートされないプラットフォームでは、 `\|\c .B \-relax\c \&\|' は受け付けますが影響はありません。 .TP .B \-r 再配置可能な出力を生成します \(em\& つまり、再度 \c .B ld\c \& に入力として与えられる出力ファイルを生成します。 これはしばしば \c .I 部分的な リンク\c \&と呼ばれます。副作用として、標準的な Unix のマジックナンバを サポートする環境では、このオプションは同時に出力ファイルの マジックナンバを \c .B OMAGIC\c \& にします。 このオプションが指定されないと、絶対ファイルが生成されます。 C++ のプログラムをリンクしている時は、このオプションでは コンストラクタへの参照は解決 \c .I されません\c \&; 代わりに \c .B \-Ur\c \& を使ってください。 このオプションは \c .B \-i\c \& と同じ事をします。 .TP .B \-rpath\ \fIdirectory 実行時のライブラリ検索パスにディレクトリを追加します。これは ELF 実行形式を共有オブジェクトとリンクする時に使われます。 すべての .B \-rpath 引数がつながれて、実行時リンカに渡されます。実行時リンカは それらを使って共有オブジェクトの位置を実行時に突き止めます。 .B \-rpath オプションは、リンク時に明示的に含められた共有オブジェクトが 必要とする共有オブジェクトの位置を突き止めるためにも使われます; .B \-rpath\-link オプションの説明を参照してください。もし ELF 実行形式をリンクする時に .B \-rpath が使われないと、定義されていれば環境変数 .B LD_RUN_PATH の内容が使われます。 .B \-rpath リンカは与えられたすべての .B \-L オプションを含む実行時の検索パスを生成します。 もし .B \-rpath が指定されれば、実行時の検索パスは .B \-rpath オプションを使い、 .B \-L オプションは無視して排他的に形成されます。 このことは gcc を使う時に有効でしょう。 gcc は多くの .B \-L オプションを付け、それらは NFSマウントされたファイルシステムに あるかもしれないからです。 .TP .B \-rpath\-link\ \fIdirectory ELF か SunOS で使う時に、1 つの共有ライブラリが他の共有ライブラリを 必要とするかも知れません。これは .B ld\ \-shared によるリンクで入力ファイルの 1 つとして共有ライブラリが含まれる 場合に発生します。 リンカがそのような依存関係に出会った時、非共有、再配置不可能の リンクをしている時は、もし必要な共有ライブラリが明示的には含まれて いないのなら、自動的にその位置を突き止めてリンク作業に 含めようとします。そのような場合、 .B \-rpath\-link オプションで最初に検索するディレクトリのセットを指定できます。 .B \-rpath\-link オプションは、コロンで区切って名前をリストにするか 複数回指定する事でディレクトリ名の並びを指定できます。 必要な共有ライブラリが見付からないと、リンカは 警告を出力してリンク作業を継続します。 .TP .B \-S (すべてのシンボルではなく) デバッガシンボル情報だけを、 出力ファイルに出しません。 .TP .B \-s すべてのシンボル情報を出力ファイルに出しません。 .TP .B \-shared 共有ライブラリを作成します。これは現時点では ELF と SunOS のプラットフォームでのみサポートされます (SunOS では指定しなくても構いません。リンカは未定義シンボルが あって .B \-e オプションが指定されていなければ自動的に共有ライブラリを作成します)。 .TP .B \-sort\-common 通常、 .B ld がグローバルのコモンシンボルを適切な出力セクションに置く時、 それらをサイズ順に並べます。最初にすべての 1 バイトのシンボルが来て、 すべての 2 バイト、それからすべての 4 バイト、そしてそれら以外の 順になります。これはアラインメントの制約によるシンボル間のすき間を 避けるために行われます。このオプションでは、その並べ替えを抑止します。 .TP .B \-split\-by\-reloc\ \fIcount .I count 個より多くの再配置を含む出力セクションが 1 つもできないように、 出力ファイルに追加のセクションを作る事を試みます。 これは、ある種のリアルタイムカーネルに、COFF オブジェクト形式で ダウンロードするための巨大な再配置可能ファイルを生成する時に有用です; COFF では 1 つのセクションで 65535 個より多い再配置情報を持てないからです。 これは任意のセクションをサポートしないオブジェクトファイル形式では うまく動作しない事に注意してください。リンカは個々の入力の セクションを再分配のために切り分ける事はありません。このため、もし 1 つの入力セクションが .I count より多い再配置を含んでいると、1 つの出力セクションがその数の 再配置を含む事になります。 .TP .B \-split\-by\-file .B \-split\-by\-reloc と同様ですが、入力ファイル毎に新しい出力セクションを生成します。 .TP .BI "--section-start " "sectionname" "\fR=\fP"org 出力ファイル中のセクションの絶対アドレスを .I org で指定します。 .I org は 16 進整数であることが必要です。 複数セクションの位置を指定するために、複数回コマンドラインで指定可能です。 手の込んだ式を使う必要がある場合、 スクリプトからリンカコマンド言語を使用することを検討してください。 .TP .BI "\-Tbss " "org"\c .TP .BI "\-Tdata " "org"\c .TP .BI "\-Ttext " "org"\c 出力ファイルの \c .B bss\c \&, \c .B data\c \&, \c .B text\c セグメントの開始番地を\(em\&それぞれ\(em\& .I org\c \& にします。 \c .I org\c \& は 16 進整数でなければなりません。 .TP .BI "\-T " "commandfile" .B \-c \c .I commandfile\c \&\c \& と等価です; 他のツールとの互換性のためにサポートされています。 .TP .B \-t \c .B ld\c \& が処理している入力ファイル名を出力します。 .TP .BI "\-u " "sym" 強制的に \c .I sym\c \& が未定義シンボルとして出力ファイルに入るようにします。 これは、例えば、標準ライブラリから追加のモジュールをリンクする 引金となり得ます。 さらに未定義シンボルを追加するために \c .B \-u\c \& を 異なるオプション引数で繰り返し可能です。 .TP .B \-Ur C++ プログラム以外の物については、このオプションは \c .B \-r\c \& と等価です: 再配置可能な出力 \(em\& つまり、再度 \c .B ld\c \& に入力として与えられる出力ファイル \(em\& を生成します。 C++ プログラムをリンクする時は、\c .B \-r\c \& と異なり \c .B \-Ur \& はコンストラクタの参照を解決 .I します\c 。 .TP .B \-\-verbose .B ld のバージョン番号とサポートするエミュレーションのリストを表示します。 どの入力ファイルが開けた/開けなかったかを表示します。 .TP .B \-v, \-V .B ld\c \& のバージョン番号を表示します。 .B \-V オプションではサポートするエミュレーションのリストも表示します。 .TP .B \-\-version .B ld のバージョン番号を表示して終了します。 .TP .B \-warn\-common コモンシンボルが他のコモンシンボルかシンボル定義と結合された時に 警告します。Unix のリンカはこのややずさんな慣習を許しますが、 他のいくつかのオペレーティングシステムのリンカは許しません。 このオプションでグローバルシンボルの結合による問題の可能性を 見つけることができます。 .TP .B \-warn\-constructors グローバルコンストラクタの使用を警告します。これは 2、3 の オブジェクトファイル形式でのみ有用です。COFF や ELF といった 形式については、リンカはグローバルコンストラクタの使用を 検出できません。 .TP .B \-warn\-multiple\-gp 出力ファイルが複数のグローバルポインタ値を必要とする場合に警告します。 このオプションはある種のプロセッサ、Alpha などでのみ意味を持ちます。 .TP .B \-warn\-once 未定義シンボルのそれぞれについて、それを参照するモジュール毎でなく、 1 回だけ警告します。 .TP .B \-warn\-section\-align 出力セクションのアドレスがアラインメントのために変更されると警告します。 典型的には、アラインメントは入力セクションによってセットされます。 アドレスはアラインメントが明示的に指定されなかった場合にのみ変更されます; つまり SECTIONS コマンドがセクションの開始番地を指定しなかった場合です。 .TP .B \-\-whole\-archive コマンドライン上で .B \-\-whole\-archive オプションの後に指定された各アーカイブについて、 必要なオブジェクトファイルをアーカイブから探す代わりに、 アーカイブ中の全オブジェクトファイルをリンクします。 これは通常、アーカイブファイルを共有ライブラリにするのに使い、 作成する共有ライブラリに全オブジェクトが確実に入るようにします。 .TP .B \-\-no\-whole\-archive これ以降にコマンドライン上で指定されたアーカイブについて .B \-\-whole\-archive オプションの効果を無効にします。 .TP .BI "--wrap " "symbol" .I symbol についてラッパー関数を使います。 未解決の .I symbol への参照を .BI "__wrap_" "symbol" で解決します。 未解決の .BI "__real_" "symbol" への参照を .I symbol で解決します。 .TP .B \-X テンポラリのローカルシンボルをすべて削除します。大部分のターゲットでは、 これは名前が `\|\c .B L\c \|' で始まるすべてのローカルシンボルになります。 .TP .B \-x すべてのローカルシンボルを削除します。 .PP .SH 環境変数 \c 環境変数 \c .B GNUTARGET\c \& で .B ld\c \& の動作を変えることが出来ます。 \c .B \-b\c \& (またはその同義語の \c .B \-format\c \&) を使わない場合に .B GNUTARGET\c \& で入力ファイルオブジェクト形式が決まります。\c その値は入力形式を示す BFD 名でなければなりません。 環境変数に \c .B GNUTARGET\c \& が無ければ、\c .B ld\c \& はホストの自然な形式を 使います。もし\c .B GNUTARGET\c \& が .B default\c \& にセットされていれば\c BFD はバイナリ入力ファイルを調べることで入力形式を 見つけようとします; このやりかたは多くの場合に成功しますが、 あいまいになる可能性があります。オブジェクトファイル形式の 印として使われているマジックナンバが重複していない事を 確認する方法が存在しないからです。しかしながら、各システムでの BFD のコンフィギュレーション処理で、そのシステムで慣習的に 使われる形式を検索リストの最初に置きます。よってあいまいさは 慣習に合わせる事で解決されます。 .PP .SH "関連項目" .BR objdump ( 1 ) .br .br .B info\c の .RB "`\|" ld "\|' と `\|" binutils "\|'" の項 .br .I ld: the GNU linker\c , Steve Chamberlain and Roland Pesch; .I The GNU Binary Utilities\c , Roland H. Pesch .SH COPYING .PP This document is distributed under the terms of the GNU Free Documentation License, version 1.1. That license is described in the sources for this manual page, but it is not displayed here in order to make this manual more consise. Copies of this license can also be obtained from: http://www.gnu.org/copyleft/. \" .SH GNU Free Documentation License \" Version 1.1, March 2000 \" Copyright (C) 2000 Free Software Foundation, Inc. \" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \" Everyone is permitted to copy and distribute verbatim \" copies of this license document, but changing it is \" not allowed. \" .PP \" 0. PREAMBLE \" .PP \" The purpose of this License is to make a manual, textbook, or other \" written document "free" in the sense of freedom: to assure everyone \" the effective freedom to copy and redistribute it, with or without \" modifying it, either commercially or noncommercially. Secondarily, \" this License preserves for the author and publisher a way to get \" credit for their work, while not being considered responsible for \" modifications made by others. \" .PP \" This License is a kind of "copyleft", which means that derivative \" works of the document must themselves be free in the same sense. It \" complements the GNU General Public License, which is a copyleft \" license designed for free software. \" .PP \" We have designed this License in order to use it for manuals for free \" software, because free software needs free documentation: a free \" program should come with manuals providing the same freedoms that the \" software does. But this License is not limited to software manuals; \" it can be used for any textual work, regardless of subject matter or \" whether it is published as a printed book. We recommend this License \" principally for works whose purpose is instruction or reference. \" .PP \" 1. APPLICABILITY AND DEFINITIONS \" .PP \" This License applies to any manual or other work that contains a \" notice placed by the copyright holder saying it can be distributed \" under the terms of this License. The "Document", below, refers to any \" such manual or work. Any member of the public is a licensee, and is \" addressed as "you". \" .PP \" A "Modified Version" of the Document means any work containing the \" Document or a portion of it, either copied verbatim, or with \" modifications and/or translated into another language. \" .PP \" A "Secondary Section" is a named appendix or a front-matter section of \" the Document that deals exclusively with the relationship of the \" publishers or authors of the Document to the Document's overall subject \" (or to related matters) and contains nothing that could fall directly \" within that overall subject. (For example, if the Document is in part a \" textbook of mathematics, a Secondary Section may not explain any \" mathematics.) The relationship could be a matter of historical \" connection with the subject or with related matters, or of legal, \" commercial, philosophical, ethical or political position regarding \" them. \" .PP \" The "Invariant Sections" are certain Secondary Sections whose titles \" are designated, as being those of Invariant Sections, in the notice \" that says that the Document is released under this License. \" .PP \" The "Cover Texts" are certain short passages of text that are listed, \" as Front-Cover Texts or Back-Cover Texts, in the notice that says that \" the Document is released under this License. \" .PP \" A "Transparent" copy of the Document means a machine-readable copy, \" represented in a format whose specification is available to the \" general public, whose contents can be viewed and edited directly and \" straightforwardly with generic text editors or (for images composed of \" pixels) generic paint programs or (for drawings) some widely available \" drawing editor, and that is suitable for input to text formatters or \" for automatic translation to a variety of formats suitable for input \" to text formatters. A copy made in an otherwise Transparent file \" format whose markup has been designed to thwart or discourage \" subsequent modification by readers is not Transparent. A copy that is \" not "Transparent" is called "Opaque". \" .PP \" Examples of suitable formats for Transparent copies include plain \" ASCII without markup, Texinfo input format, LaTeX input format, SGML \" or XML using a publicly available DTD, and standard-conforming simple \" HTML designed for human modification. Opaque formats include \" PostScript, PDF, proprietary formats that can be read and edited only \" by proprietary word processors, SGML or XML for which the DTD and/or \" processing tools are not generally available, and the \" machine-generated HTML produced by some word processors for output \" purposes only. \" .PP \" The "Title Page" means, for a printed book, the title page itself, \" plus such following pages as are needed to hold, legibly, the material \" this License requires to appear in the title page. For works in \" formats which do not have any title page as such, "Title Page" means \" the text near the most prominent appearance of the work's title, \" preceding the beginning of the body of the text. \" .PP \" 2. VERBATIM COPYING \" .PP \" You may copy and distribute the Document in any medium, either \" commercially or noncommercially, provided that this License, the \" copyright notices, and the license notice saying this License applies \" to the Document are reproduced in all copies, and that you add no other \" conditions whatsoever to those of this License. You may not use \" technical measures to obstruct or control the reading or further \" copying of the copies you make or distribute. However, you may accept \" compensation in exchange for copies. If you distribute a large enough \" number of copies you must also follow the conditions in section 3. \" .PP \" You may also lend copies, under the same conditions stated above, and \" you may publicly display copies. \" .PP \" 3. COPYING IN QUANTITY \" .PP \" If you publish printed copies of the Document numbering more than 100, \" and the Document's license notice requires Cover Texts, you must enclose \" the copies in covers that carry, clearly and legibly, all these Cover \" Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on \" the back cover. Both covers must also clearly and legibly identify \" you as the publisher of these copies. The front cover must present \" the full title with all words of the title equally prominent and \" visible. You may add other material on the covers in addition. \" Copying with changes limited to the covers, as long as they preserve \" the title of the Document and satisfy these conditions, can be treated \" as verbatim copying in other respects. \" .PP \" If the required texts for either cover are too voluminous to fit \" legibly, you should put the first ones listed (as many as fit \" reasonably) on the actual cover, and continue the rest onto adjacent \" pages. \" .PP \" If you publish or distribute Opaque copies of the Document numbering \" more than 100, you must either include a machine-readable Transparent \" copy along with each Opaque copy, or state in or with each Opaque copy \" a publicly-accessible computer-network location containing a complete \" Transparent copy of the Document, free of added material, which the \" general network-using public has access to download anonymously at no \" charge using public-standard network protocols. If you use the latter \" option, you must take reasonably prudent steps, when you begin \" distribution of Opaque copies in quantity, to ensure that this \" Transparent copy will remain thus accessible at the stated location \" until at least one year after the last time you distribute an Opaque \" copy (directly or through your agents or retailers) of that edition to \" the public. \" .PP \" It is requested, but not required, that you contact the authors of the \" Document well before redistributing any large number of copies, to give \" them a chance to provide you with an updated version of the Document. \" .PP \" 4. MODIFICATIONS \" .PP \" You may copy and distribute a Modified Version of the Document under \" the conditions of sections 2 and 3 above, provided that you release \" the Modified Version under precisely this License, with the Modified \" Version filling the role of the Document, thus licensing distribution \" and modification of the Modified Version to whoever possesses a copy \" of it. In addition, you must do these things in the Modified Version: \" .PP \" A. Use in the Title Page (and on the covers, if any) a title distinct \" from that of the Document, and from those of previous versions \" (which should, if there were any, be listed in the History section \" of the Document). You may use the same title as a previous version \" if the original publisher of that version gives permission. \" .PP \" B. List on the Title Page, as authors, one or more persons or entities \" responsible for authorship of the modifications in the Modified \" Version, together with at least five of the principal authors of the \" Document (all of its principal authors, if it has less than five). \" .PP \" C. State on the Title page the name of the publisher of the \" Modified Version, as the publisher. \" .PP \" D. Preserve all the copyright notices of the Document. \" .PP \" E. Add an appropriate copyright notice for your modifications \" adjacent to the other copyright notices. \" .PP \" F. Include, immediately after the copyright notices, a license notice \" giving the public permission to use the Modified Version under the \" terms of this License, in the form shown in the Addendum below. \" Preserve in that license notice the full lists of Invariant Sections \" and required Cover Texts given in the Document's license notice. \" .PP \" H. Include an unaltered copy of this License. \" .PP \" I. Preserve the section entitled "History", and its title, and add to \" it an item stating at least the title, year, new authors, and \" publisher of the Modified Version as given on the Title Page. If \" there is no section entitled "History" in the Document, create one \" stating the title, year, authors, and publisher of the Document as \" given on its Title Page, then add an item describing the Modified \" Version as stated in the previous sentence. \" .PP \" J. Preserve the network location, if any, given in the Document for \" public access to a Transparent copy of the Document, and likewise \" the network locations given in the Document for previous versions \" it was based on. These may be placed in the "History" section. \" You may omit a network location for a work that was published at \" least four years before the Document itself, or if the original \" publisher of the version it refers to gives permission. \" .PP \" K. In any section entitled "Acknowledgements" or "Dedications", \" preserve the section's title, and preserve in the section all the \" substance and tone of each of the contributor acknowledgements \" and/or dedications given therein. \" .PP \" L. Preserve all the Invariant Sections of the Document, \" unaltered in their text and in their titles. Section numbers \" or the equivalent are not considered part of the section titles. \" .PP \" M. Delete any section entitled "Endorsements". Such a section \" may not be included in the Modified Version. \" .PP \" N. Do not retitle any existing section as "Endorsements" \" or to conflict in title with any Invariant Section. \" .PP \" If the Modified Version includes new front-matter sections or \" appendices that qualify as Secondary Sections and contain no material \" copied from the Document, you may at your option designate some or all \" of these sections as invariant. To do this, add their titles to the \" list of Invariant Sections in the Modified Version's license notice. \" These titles must be distinct from any other section titles. \" .PP \" You may add a section entitled "Endorsements", provided it contains \" nothing but endorsements of your Modified Version by various \" parties--for example, statements of peer review or that the text has \" been approved by an organization as the authoritative definition of a \" standard. \" .PP \" You may add a passage of up to five words as a Front-Cover Text, and a \" passage of up to 25 words as a Back-Cover Text, to the end of the list \" of Cover Texts in the Modified Version. Only one passage of \" Front-Cover Text and one of Back-Cover Text may be added by (or \" through arrangements made by) any one entity. If the Document already \" includes a cover text for the same cover, previously added by you or \" by arrangement made by the same entity you are acting on behalf of, \" you may not add another; but you may replace the old one, on explicit \" permission from the previous publisher that added the old one. \" .PP \" The author(s) and publisher(s) of the Document do not by this License \" give permission to use their names for publicity for or to assert or \" imply endorsement of any Modified Version. \" .PP \" 5. COMBINING DOCUMENTS \" .PP \" You may combine the Document with other documents released under this \" License, under the terms defined in section 4 above for modified \" versions, provided that you include in the combination all of the \" Invariant Sections of all of the original documents, unmodified, and \" list them all as Invariant Sections of your combined work in its \" license notice. \" .PP \" The combined work need only contain one copy of this License, and \" multiple identical Invariant Sections may be replaced with a single \" copy. If there are multiple Invariant Sections with the same name but \" different contents, make the title of each such section unique by \" adding at the end of it, in parentheses, the name of the original \" author or publisher of that section if known, or else a unique number. \" Make the same adjustment to the section titles in the list of \" Invariant Sections in the license notice of the combined work. \" .PP \" In the combination, you must combine any sections entitled "History" \" in the various original documents, forming one section entitled \" "History"; likewise combine any sections entitled "Acknowledgements", \" and any sections entitled "Dedications". You must delete all sections \" entitled "Endorsements." \" .PP \" 6. COLLECTIONS OF DOCUMENTS \" .PP \" You may make a collection consisting of the Document and other documents \" released under this License, and replace the individual copies of this \" License in the various documents with a single copy that is included in \" the collection, provided that you follow the rules of this License for \" verbatim copying of each of the documents in all other respects. \" .PP \" You may extract a single document from such a collection, and distribute \" it individually under this License, provided you insert a copy of this \" License into the extracted document, and follow this License in all \" other respects regarding verbatim copying of that document. \" .PP \" 7. AGGREGATION WITH INDEPENDENT WORKS \" .PP \" A compilation of the Document or its derivatives with other separate \" and independent documents or works, in or on a volume of a storage or \" distribution medium, does not as a whole count as a Modified Version \" of the Document, provided no compilation copyright is claimed for the \" compilation. Such a compilation is called an "aggregate", and this \" License does not apply to the other self-contained works thus compiled \" with the Document, on account of their being thus compiled, if they \" are not themselves derivative works of the Document. \" .PP \" If the Cover Text requirement of section 3 is applicable to these \" copies of the Document, then if the Document is less than one quarter \" of the entire aggregate, the Document's Cover Texts may be placed on \" covers that surround only the Document within the aggregate. \" Otherwise they must appear on covers around the whole aggregate. \" .PP \" 8. TRANSLATION \" .PP \" Translation is considered a kind of modification, so you may \" distribute translations of the Document under the terms of section 4. \" Replacing Invariant Sections with translations requires special \" permission from their copyright holders, but you may include \" translations of some or all Invariant Sections in addition to the \" original versions of these Invariant Sections. You may include a \" translation of this License provided that you also include the \" original English version of this License. In case of a disagreement \" between the translation and the original English version of this \" License, the original English version will prevail. \" .PP \" 9. TERMINATION \" .PP \" You may not copy, modify, sublicense, or distribute the Document except \" as expressly provided for under this License. Any other attempt to \" copy, modify, sublicense or distribute the Document is void, and will \" automatically terminate your rights under this License. However, \" parties who have received copies, or rights, from you under this \" License will not have their licenses terminated so long as such \" parties remain in full compliance. \" .PP \" 10. FUTURE REVISIONS OF THIS LICENSE \" .PP \" The Free Software Foundation may publish new, revised versions \" of the GNU Free Documentation License from time to time. Such new \" versions will be similar in spirit to the present version, but may \" differ in detail to address new problems or concerns. See \" http://www.gnu.org/copyleft/. \" .PP \" Each version of the License is given a distinguishing version number. \" If the Document specifies that a particular numbered version of this \" License "or any later version" applies to it, you have the option of \" following the terms and conditions either of that specified version or \" of any later version that has been published (not as a draft) by the \" Free Software Foundation. If the Document does not specify a version \" number of this License, you may choose any version ever published (not \" as a draft) by the Free Software Foundation. \" .PP \" ADDENDUM: How to use this License for your documents \" .PP \" To use this License in a document you have written, include a copy of \" the License in the document and put the following copyright and \" license notices just after the title page: \" .PP \" Copyright (c) YEAR YOUR NAME. \" Permission is granted to copy, distribute and/or \" modify this document under the terms of the GNU \" Free Documentation License, Version 1.1 or any later \" version published by the Free Software Foundation; \" with the Invariant Sections being LIST THEIR TITLES, \" with the Front-Cover Texts being LIST, and with the \" Back-Cover Texts being LIST. A copy of the license \" is included in the section entitled "GNU Free \" Documentation License". \" .PP \" If you have no Invariant Sections, write "with no Invariant Sections" \" instead of saying which ones are invariant. If you have no \" Front-Cover Texts, write "no Front-Cover Texts" instead of \" "Front-Cover Texts being LIST"; likewise for Back-Cover Texts. \" .PP \" If your document contains nontrivial examples of program code, we \" recommend releasing these examples in parallel under your choice of \" free software license, such as the GNU General Public License, \" to permit their use in free software. .SH 日本語訳 野首 寛高(hnokubi@yyy.or.jp): FreeBSD 用に翻訳 .\" .SH 履歴 .\" 野首 寛高 1998/10/25 FreeBSD 用に翻訳 .\" 堀川和雄 2001/08/04 binutil 2.11.2 用に修正