This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: relocation type suitable for resources
- From: Brian Dessent <brian at dessent dot net>
- To: jafa <jafa at silicondust dot com>
- Cc: binutils at sourceware dot org
- Date: Fri, 13 Jun 2008 14:15:14 -0700
- Subject: Re: relocation type suitable for resources
- References: <48529EC3.2080302@silicondust.com>
- Reply-to: binutils at sourceware dot org
jafa wrote:
> 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.
Specifically, this is PE reloc type 0x06 that BFD calls BFD_RELOC_32
(and displays in objdump -r as "dir32") and the PE standard calls
IMAGE_REL_I386_DIR32.
> 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).
Aka the rva.
> 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?
What you need is reloc type 0x07 that BFD calls BFD_RELOC_RVA (and is
displayed in "objdump -j .rsrc -r" as "rva32") and the PE standard calls
IMAGE_REL_I386_DIR32NB. You can emit this reloc with the assembler op
".rva <label>".
Brian