What's the point of the global offset table?

The whole reason the GOT works is because the offset between sections of code and data is constant; ergo, the offset between the code and some given database in the data section is constant.

This SO question confirms this and confirms that for the data defined in the library, the GOT is redundant.

The only possibility is data used in the library, but defined elsewhere.

So this is the only GOT point in a shared lib to be able to keep this section of lib code out of position by localizing all relocations to symbols defined in other shared libraries in the GOT?

+3


source to share


1 answer


So, is it the only GOT point in the shared lib to be able to save this section of lib code out of position, localizing all permutations to symbols defined in other shared libraries in the GOT?

You are correct that GOT is a mechanism to move code around.



However, it applies to both traditional shared objects and programs. This applies to programs because of the position code independent (PIE) (aka).

Generally speaking, PIE is a subset of PIC. That is, you can compile all your code (programs and shared libraries) with -fPIC

. However, the opposite is not true. You cannot compile all code (programs and shared libraries) with -fPIE

. For shared libraries it is required -fPIC

.

0


source







All Articles