Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的意思是在模块中定义的非静态全局变量,而不是在外部。
为什么必须通过 GOT 引用它?为什么不使用相对地址?(因为 .data 部分中的全局变量和 .text 部分中的引用之间的距离是一个常数,它也是与位置无关的)
由于您的变量不是static,因此可以在 ELF 上插入它(想想 LD_PRELOAD)。
static
我也有同样的困惑。如果在两个 DSO 中定义了一个同名的全局变量,并且它们被动态链接到一个可执行文件中,那么两个库会访问该变量的同一个副本吗?变量所在的库(库的数据部分)取决于库加载的顺序?