Jump to content

Relocation table

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 71.179.18.138 (talk) at 23:44, 15 April 2011 (External links: Removed broken link). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The relocation table is a list of pointers created by the linker and linked into the MSDOS .exe file. The relocation table tells the loader where these segments can be found in program image loaded into memory.

16-bit Windows

Far pointers (32-bit pointers with segment:offset, used to address 20-bit 640 KB memory space available to DOS programs), which point to code or data within an DOS executable (EXE) do not have absolute segments, because the actual address of code/data depends on where the program is loaded in memory and this is not known until the program is loaded.

Instead, segments are relative values in the DOS EXE file. These segments need to be corrected, when the executable has been loaded into memory. The EXE loader uses a relocation table to find the segments which need to be adjusted.

32-bit Windows

With 32-bit Windows operating systems it is not mandatory to provide relocation tables for EXE files, since they are the first image loaded into the virtual address space and thus will be loaded at their preferred base address.

For both DLLs and for EXEs which opt into Address Space Layout Randomisation - an exploit mitigation technique introduced with Windows Vista, relocation tables once again become mandatory because of the possibility that the binary may be dynamically moved before being executed, even though they are still the first thing loaded in the virtual address space.

64-bit Windows

When running native 64-bit binaries on Windows Vista and above, ASLR is mandatory, and thus relocation sections cannot be omitted by the compiler.

Unix/Linux systems

The ELF executable format and SO shared library format used by most Unix/Linux systems allows to define several types of relocations.

See also