gold's emission of _GLOBAL_OFFSET_TABLE_
David Miller
davem@davemloft.net
Tue Apr 8 00:49:00 GMT 2008
From: Alan Modra <amodra@bigpond.net.au>
Date: Tue, 8 Apr 2008 09:58:19 +0930
> Use the .got section index rather than SHN_ABS if doing so works with
> all dynamic loaders of interest. _G_O_T_ being SHN_ABS requires the
> dynamic loader relocate SHN_ABS symbols (which is silly) in shared
> libraries.
>
> Or even better, use just one section symbol for all local dynamic
> relocs.
When there is an absolute reference to _GLOBAL_OFFSET_TABLE_ on sparc
(which happens when non-relocatable code is linked shared) that's
essentially what ends up happening, you get a section relative reloc.
For example, from tls_test_shared_nonpic.so:
...
0000026c 00000009 R_SPARC_HI22 000117b0
00000274 0000000c R_SPARC_LO10 000117b0
...
2: 000007d0 0 SECTION LOCAL DEFAULT 4
I think in practice the case you describe, where ABS symbols need
to be relocated in shared libraries, does not occur at least on
sparc. We'll see PC relative relocs to _GLOBAL_OFFSET_TABLE_
when PIC/pic code is generated, which will be fully resolved
by the linker and not result in dynamic relocs.
You won't even get a _GLOBAL_OFFSET_TABLE_ entry in the .dynsym
section.
More information about the Binutils
mailing list