Saturday, 1 October 2011

What is the GOT?

The Global Offset Tables (GOTs) are used to store the memory addresses of all accessed global variables. A single GOT that is positioned at a fixed offset from the code will be created for each compilation unit or object module. The Global Offset Table redirects position independent address calculations to an absolute location. These can be found in the .got section of an ELF executable or shared object. The reason for this is that Position-independent code cannot, in general, contain absolute virtual addresses.

Global Offset Tables hold absolute addresses in private data. This allows the addresses to be accessible when still providing a level of position-independence for the code’s text. The code will reference its respective GOT through the use of position-independent addressing. This allows it to maintain absolute values such that it can still readdress position-independent references over to absolute locations.

clip_image002

Figure: Mapping Shared Memory, the GOT

The GOT is isolated in each process with (ideally) just the owning process having write permissions to it’s GOT. On the other hand, the library code is shared. Each process needs to be restricted such that it is limited to just read and execute permissions on the code. When this is not true, a serious security compromise can occur through code modification.

No comments: