我已经阅读了
相关问题:
gcc
的手册,但我仍然无法理解 -fpic
和 -fPIC
之间的区别。有人能以非常简单明了的方式解释一下吗?
相关问题:
gcc
的手册,但我仍然无法理解 -fpic
和 -fPIC
之间的区别。有人能以非常简单明了的方式解释一下吗?
-fPIC
和-fpic
生成的代码是一样的。似乎只有在m68k、PowerPC和SPARC上才会生成不同的代码。 - Denilson Sá Maiaman gcc
的说明,这也会对 ARM64 产生影响。 - iFreilicht从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.
man gcc
中,而是在info gcc
中,那里有更详细的文档。 - user2284570