加载程序如何在共享库中引用变量? [英] How are variables in shared libraries referenced by loader?

查看:76
本文介绍了加载程序如何在共享库中引用变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在了解如何通过如下的过程链接表来引用动态函数:

I now understand how dynamic functions are referenced, by procedure linkage table like below:

Dump of assembler code for function foo@plt:
0x0000000000400528 <foo@plt+0>: jmpq   *0x2004d2(%rip)        # 0x600a00 <_GLOBAL_OFFSET_TABLE_+40>
0x000000000040052e <foo@plt+6>: pushq  $0x2
0x0000000000400533 <foo@plt+11>:    jmpq   0x4004f8
(gdb) disas 0x4004f8
No function contains specified address.

但是我不知道如何引用动态变量,尽管我发现值已填充到GOT一旦启动,但是没有上面的存根,它是如何工作的?

But I don't know how dynamic variables are referenced,though I found the values are populated in the GOT once started,but there's no stub like above,how does it work?

推荐答案

动态加载程序会先重新定位对变量的所有引用将控制权转移给用户程序。

The dynamic loader relocates all references to variables before transferring control to the user program.

它们没有存根,因为一旦用户程序开始执行,加载程序就无法重新获得控制权并更新变量地址。如果您不清楚这一点,那么您还真的不了解PLT惰性分辨率存根的工作原理。

There is no "stub" for them, because once the user program starts executing, it is not possible for the loader to regain control and update variable addresses. If this isn't clear to you, then you have not really understood how the PLT lazy-resolution stub works.

这篇关于加载程序如何在共享库中引用变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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