This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: relocation type suitable for resources


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]