すでにマンページを読みましたが、とgcc
の違いがわかりません。誰かがそれを非常に単純で明確な方法で説明できますか?-fpic
-fPIC
関連する質問:
すでにマンページを読みましたが、とgcc
の違いがわかりません。誰かがそれを非常に単純で明確な方法で説明できますか?-fpic
-fPIC
関連する質問:
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
`-fPIC`または`-fpic`を使用して、位置に依存しないコードを生成します。位置に依存しないコードを生成するために`-fPIC`または`-fpic`を使用するかどうかは、ターゲットに依存します。`-fPIC`の選択は常に機能しますが、` -fpic`よりも大きなコードを生成する可能性があります(これを覚えておくためのニーモニックは、PICがより大きなケースであるため、大量のコードを生成する可能性があることです)。`-fpic`オプションを使用すると、通常、より小さく高速なコードが生成されますが、グローバルに表示されるシンボルの数やコードのサイズなど、プラットフォームに依存する制限があります。リンカは、共有ライブラリを作成するときに、それが適合するかどうかを通知します。疑わしい場合は、常に機能するため、`-fPIC`を選択します。Gccのマニュアルページから:
共有ライブラリのコードを生成する場合、-fpicは-msmall-dataを意味し、-fPICは-mlarge-dataを意味します。
どこ:
-msmall-data
-mlarge-data
When -mexplicit-relocs is in effect, static data is accessed via
gp-relative relocations. When -msmall-data is used, objects 8
bytes long or smaller are placed in a small data area (the
".sdata" and ".sbss" sections) and are accessed via 16-bit
relocations off of the $gp register. This limits the size of the
small data area to 64KB, but allows the variables to be directly
accessed via a single instruction.
The default is -mlarge-data. With this option the data area is
limited to just below 2GB. Programs that require more than 2GB
of data must use "malloc" or "mmap" to allocate the data in the
heap instead of in the program's data segment.
When generating code for shared libraries, -fpic implies
-msmall-data and -fPIC implies -mlarge-data.