|Understanding relocation information email@example.com (AG) (2010-03-08)|
|Re: Understanding relocation information firstname.lastname@example.org (Kamil Konieczny) (2010-03-10)|
|Date:||Mon, 8 Mar 2010 02:28:36 -0800 (PST)|
|Keywords:||linker, question, comment|
|Posted-Date:||09 Mar 2010 23:25:21 EST|
I am trying to understand how relocation information in PE/COFF files
work, and I am half the way. For PE files, everything is in the .reloc
section, and as far as I read the PE file specifications (provided by
microsoft on their web site) I am fine. But for Object files, I don't
really understand the specifications, and I would appreciate if
someone could help me.
As far as I understand, relocation information is a field of the size
of an address which must be modified at runtime. So basically it is
made of three information:
- The address of the item to which relocation is applied: let's call
- The address to be used to for the relocation: let's call it B
- The way the relocation should be done: let's call it f() (a
I assume that the way the relocation is done is :
A = f(B)
is that correct ?
If so, then I read further the specifications, and I have difficulties
to understand the f() part, which is called the relocation type.
Here is a copy of the relocation types I am interested in:
IMAGE_REL_I386_DIR32 0x0006 The target's 32-bit VA.
IMAGE_REL_I386_DIR32NB 0x0007 The target's 32-bit RVA.
IMAGE_REL_I386_SECTION 0x000A The 16-bit section index of the section
that contains the target. This is used to support debugging
IMAGE_REL_I386_SECREL 0x000B The 32-bit offset of the target from the
beginning of its section. This is used to support debugging
information and static thread local storage.
IMAGE_REL_I386_TOKEN 0x000C The CLR token.
IMAGE_REL_I386_SECREL7 0x000D A 7-bit offset from the base of the
section that contains the target.
IMAGE_REL_I386_REL32 0x0014 The 32-bit relative displacement to the
target. This supports the x86 relative branch and call instructions.
In these lines, I don't understand what the word "target" is referring
to ? Neither do I understand the sentence themselves. For instance
what should I do with "The target's 32-bit VA" ? How does it relates
with my equation A = f(B) ?
I know I am asking a very specific question, but I don't find someone
around me to answer it. Thanks in advance if you can at least drive me
in the right direction.
[The target is B, the address value that is supposed to be stored at
A. Actually, it's more like A += f(B). -John]
Return to the
Search the comp.compilers archives again.