简体   繁体   English

如何在全局偏移表中初始化不是函数的全局符号条目?

[英]How are the entries for Global Symbols that are not functions initialized in the Global Offset Table?

So I am trying to learn about dynamic linking.所以我正在尝试了解动态链接。 On SysV ABI on amd64, functions from other shared libraries can be loaded lazily via the Procedure Linkage Table by initializing the GOT entry for the function to point at the next instruction in its plt entry.在 amd64 上的 SysV ABI 上,可以通过过程链接表延迟加载来自其他共享库的函数,方法是初始化函数的 GOT 条目以指向其 plt 条目中的下一条指令。 This will eventually pass control on to the dynamic linker that will load the library, update the GOT entry and jump to function.这最终会将控制权传递给将加载库、更新 GOT 条目并跳转到函数的动态链接器。 Now for other global symbols that are not functions (do not have PLT entries), how or when will they be initialized?现在对于其他不是函数的全局符号(没有 PLT 条目),它们将如何或何时被初始化? Can it be done lazily?可以懒惰地做吗?

This will eventually pass control on to the dynamic linker that will load the library, update the GOT entry and jump to function这最终会将控制权传递给将加载库、更新 GOT 条目并跳转到函数的动态链接器

This is only partially correct: the library will normally already be loaded, and the loader only resolves the symbol and updates the GOT entry to point to the symbol definition.这只是部分正确:库通常已经被加载,加载器只解析符号并更新GOT条目以指向符号定义。

Now for other global symbols that are not functions (do not have PLT entries), how or when will they be initialized?现在对于其他不是函数的全局符号(没有 PLT 条目),它们将如何或何时被初始化?

When the library (or executable) referencing the symbol is loaded, the loader resolves all the data symbols in it, before making it available.当引用该符号的库(或可执行文件)被加载时,加载器在使其可用之前解析其中的所有数据符号。

Can it be done lazily?可以懒惰地做吗?

No.不。

See also this answer .另请参阅此答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM