relocation type suitable for resources

jafa jafa@silicondust.com
Fri Jun 13 21:13:00 GMT 2008


Hi guys,

In 32-bit x86 code most relocations are absolute 32-bit addresses.
In assembly code you simply use a label. AS creates a 32-bit absolute 
relocation entry for it. LD resolves it for the default base address and 
adds a run-time relocation entry in case the loader wants to move the 
base address.
This works well.

The resource section of a windows executable needs offset addresses 
relative to the image base (the VMA offset relative to the image VMA 
base address).

Example - if the executable has a VMA base address of 0x00400000 and the 
resource is to be loaded at 0x00412345 then the address in the binary 
needs to be 0x00012345.

Using "<resource label> - <image base address>" fails because it crosses 
a section boundary.

Using "<resource label> - 0x00400000" causes LD to create run-time 
relocation entries. If the loader puts the image at 0x00400000 then the 
resources work. If the loader moves the base address (common for DLLs) 
then the resource addresses get mangled by the run-time relocation 
information.

What is the best way to specify that I need a link-time-calculated 
"offset from image-base" address that should not result in a run-time 
relocation entry?

Thanks,

Nick



More information about the Binutils mailing list