什么是程序连接表的目的是什么? [英] What is the purpose of the procedure linkage table?

查看:352
本文介绍了什么是程序连接表的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,为什么过程链接表存在。它起什么作用?无法装配直接调用全局偏移表?什么优势呢调用PLT有超过调用全局偏移表?

I'm curious why the Procedure Linkage Table exists. What purpose does it serve? Couldn't the assembly call the global offset table directly? What advantage does calling the PLT have over calling the Global Offset Table?

整个过程依然是那样的混乱给我,我试图找出在的和动态链接,所以任何助阵的将是AP preciated。

The whole process is still kind of confusing to me and I'm trying to figure out the in's and out's of dynamic linking so any help would be appreciated.

推荐答案

有关从PIC code的通话,你是正确的,是不是真的需要的PLT。编译器可能刚以及生成GOT查找和间接调用从GOT得到的地址。使用PLT往往使code稍微更有效,虽然(至少,每次通话较少的尺寸膨胀),所​​以它一般还是使用。

For calls made from PIC code, you are correct that the PLT is not really needed. The compiler could just was well generate a GOT lookup and indirect call to the address obtained from the GOT. Using a PLT tends to make the code slightly more efficient though (at least, less size bloat per call) so it's generally used anyway.

在哪里是绝对需要的PLT,然而,就是在非PIC code这是动态的链接。 (这通常只发生在主程序;许多archs,非PIC code根本不准/共享库的支持。)当编译器为函数调用生成非PIC code,它有没有办法知道实际的目标地址将在通过GOT运行时动态解析。所以它只是产生一个普通的调用指令。然后,链接程序负责,当它看到一个呼叫类型的拆迁那不是本地解析的象征,需要运行时链接,生成加载从GOT的地址,使间接跳转到它的PLT条目。这样一来,原来的非PIC函数调用code工作不变。

Where the PLT is absolutely needed, however, is in non-PIC code that's dynamic linked. (Usually this occurs only in the main program; on many archs, non-PIC code is not even allowed/supported in shared libraries.) When the compiler generates non-PIC code for a function call, it has no way to know that the actual destination address will be resolved dynamically at runtime via the GOT. So it just generates an ordinary call instruction. The linker then is responsible, when it sees a call-type relocation for a symbol that's not resolved locally and that requires runtime linking, for generating a PLT entry that loads the address from the GOT and makes an indirect jump to it. This way, the original non-PIC function call code works unmodified.

这篇关于什么是程序连接表的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆