Relocating section at virtual address 0

Daniel Jacobowitz drow@false.org
Tue Jul 26 14:04:00 GMT 2005


On Mon, Jul 25, 2005 at 09:12:23AM +0200, Daniël Mantione wrote:
> Hi,
> 
> I'm coding a more efficient way of threadvar handling for Free Pascal
> compiler. To do that I'm using the gs: register, which I make point to the
> threadvar area of the current thread by means of the modify_ldt syscall of
> the Linux kernel.
> 
> So, to access a threadvar, the compiler only needs to issue an instruction
> like 'mov eax,[gs:variableoffset]'.
> 
> I have modified the compiler to put all threadvars into their own section,
> .threadvars, now I need to make sure the linker relocates addresses inside
> that section from the virtual address 0.

I'm not sure if the linker can do what you are trying to make it do,
but I'm absolutely sure that you shouldn't be accomplishing your goal
this way.

Do you have a reason not to use the same thread-local storage ABI that
has already been implemented for C/C++?  If you use .tdata and .tbss,
everything will just work.  You can even reuse glibc to handle all of
the startup and relocation issues.

-- 
Daniel Jacobowitz
CodeSourcery, LLC



More information about the Binutils mailing list