This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
relocation type suitable for resources
- From: jafa <jafa at silicondust dot com>
- To: binutils at sourceware dot org
- Date: Fri, 13 Jun 2008 09:22:27 -0700
- Subject: relocation type suitable for resources
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