I have a few questions regarding relocation.
This is the reference i've been using.
https://docs.oracle.com/cd/E19120-01/op ... index.html
All entries are of the 'rela' type.
A refers to the addend,
S refers to the location of the symbol being applied.
P refers to the memory location of the relocation (what we are modifying).
P32 is a 32-bit pointer to P
P64 is a 64-bit pointer to P.
Code: Select all
...
{ // R_AMD64_64
*P64 = S + A;
}
...
{ // R_AMD64_PC32
*P32 = S + A - P;
}
...
{ // R_AMD64_32
*P32 = S + A;
}
...
{ // R_AMD64_32S
*P32 = S + A;
}
I'm just not understanding those 2 relocations. Am I supposed to add (S + A) as a 64-bit value, then shove the bottom 32 bits into *P32 ?R_AMD64_32
The computed value is truncated to 32–bits. The link-editor verifies that the generated value for the relocation zero-extends to the original 64–bit value.
R_AMD64_32S
The computed value is truncated to 32–bits. The link-editor verifies that the generated value for the relocation sign-extends to the original 64–bit value.
It just doesn't seem right, with the sign-extending and all. Maybe i'm supposed to use a 64-bit value, manipulate, then shove that value into *P64? (where manipulate is result & 0x00000000ffffffff for the R_AMD64_32) and if (result & (1 << 31)) then result |= 0xffffffff00000000 for R_AMD64_32S ?
Any help would be appreciated.