What is the point of the Global Offset Table?

会有一股神秘感。 提交于 2019-12-04 12:04:41

Thus, is the only point of the GOT in a shared lib, to be able to keep that lib's code section position-independent by localizing all relocations to symbols defined in other shared libraries, in the GOT?

You are correct that the GOT is the mechanism which allows code to be relocatable.

However, it applies to both traditional shared objects and programs. It applies to programs due to Position Independent Code (PIE) (a.k.a Address Space Layout Randomization).

Generally speaking, PIE is a subset of PIC. That is, you can compile all code (programs and shared libraries) with -fPIC. However, the converse is not true. You cannot compile all code (programs and shared libraries) with -fPIE. Shared libraries require -fPIC.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!