更新时间:2022-06-25 05:26:01
在与 -fPIC
编译问题的对象将通过确定全局符号的地址全局偏移表的。会发生什么,虽然当code的一部分,是 -fPIC
和部分不就是一个你的 INT全球
s将会使用该表来确定该地址,而另一部分是不
When you compile with -fPIC
the object in question will determine the address of global symbols using the Global Offset Table. What happens though when part of the code is -fPIC
and part isn't is that one of your int global
s will be using this table to determine the address whilst the other part isn't.
如果你有两个共享对象, -fPIC
联系,但主程序没有,那么你仍然有两个地址 INT全球
,一个使用这只是本地的非PIC code。
If you had two shared object linked with -fPIC
, but your main program not then you would still have two addresses for int global
, one using the global offset table and one which was just local to the non-PIC code.
有一个关于PIC一个真正伟大的讨论VS PIC与非PIC 如果你要进一步阅读。
There's a really great discussion on PIC vs pic vs non PIC if you want to read further.