Re: R_386_RELATIVE relocation type. what is it for?
- From: Peter Teoh <htmldeveloper@xxxxxxxxx>
- Date: 7 Nov 2007 02:03:17 -0800
On Nov 5, 11:31 pm, Pawel <paulin...@xxxxxxxxx> wrote:
Hallo group readers!
I am trying to understand why R_386_RELATIVE relocation type is needed
in shared libraries. As I understand PIC code, all references from
.text section of a library to its .data section are based on the fact
that the distance between these two is constant.
eh....are u sure your last statement is correct? my logical thinking
says no, as each section relative to each other's order is fixed, but
the distance in terms of bytes is not fixed, all depends on the
section size specified in the ELF header.
So regardless of
where is .text and .data mapped in process address space, the library
code, knowing the distance to the symbol it wants to use, can just read/write
this data.
Could You please give me some example when R_386_RELATIVE is needed.
From specs:
R_386_RELATIVE
The link editor creates this relocation type for dynamic linking. Its
offset
member gives a location within a shared object that contains a value
representing a relative address. The dynamic linker computes the
corresponding virtual address by adding the virtual address at which
the
shared object was loaded to the relative address. Relocation entries
for this
type must specify 0 for the symbol table index.
My interpretation:
Basically, the problem is that the shared object codes can be loaded
arbitrarily anywhere in memory space. So supposed you issued this:
0x8888: mov eax, 0x123456
where 0x123456 is a virtual address WITHIN THE address space specified
in the shared object - unloaded yet, and 0x8888 is the address of the
instruction. But after loading the shared object, the linker/loader
needs to modify it to:
mov eax, 0x45678
so, how to do that? The address pointing exactly to the starting
bytes of 0x123456 ie 0x8888+1, will have its contents added with the
amount of bytes shifted by the loader - to become 0x45678.
Correct me if I am wrong.
.
- References:
- R_386_RELATIVE relocation type. what is it for?
- From: Pawel
- R_386_RELATIVE relocation type. what is it for?
- Prev by Date: Re: open() behavior under heavy disk load
- Next by Date: Re: ----About too much global variables
- Previous by thread: Re: R_386_RELATIVE relocation type. what is it for?
- Next by thread: USB device timeout
- Index(es):
Relevant Pages
|