nptl: mark symbols with libc forwarder hidden
Timo Teräs
timo.teras at iki.fi
Fri Apr 16 11:04:57 UTC 2010
Timo Teräs wrote:
> Joakim Tjernlund wrote:
>> Timo Teräs <timo.teras at gmail.com> wrote on 2010/04/16 11:39:00:
>>> Joakim Tjernlund wrote:
>>>>>> Yes. Exactly that. It's __attribute__(( visibility("protected") )).
>>>>>> Or .protected for asm. I'm doing a patch on this right now.
>>>>>> http://www.ohse.de/uwe/articles/gcc-attributes.html#func-visibility
>>>>> But this is PROTECTED and you might need to impl. STB_PROTECTED in
>>>>> ldso
>>>> That should be STV_PROTECTED
>>>>
>>>>> to support it. I once looked at that when I was hacking ldso in uClibc
>>>>> some years ago but I don't remember the details any more.
>>> Ah, you're right. It does need ld.so support. I'll try to figure out
>>> if it's easy to implement, or if we get away with some linker flags.
>>>
>>
>> This MIGHT do it(completely untested):
>>
>> diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c
>> index a01c1d0..7f1b408 100644
>> --- a/ldso/ldso/i386/elfinterp.c
>> +++ b/ldso/ldso/i386/elfinterp.c
>> @@ -175,7 +175,9 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct
>> dyn_elf *scope,
>> symbol_addr = 0;
>> symname = strtab + symtab[symtab_index].st_name;
>>
>> - if (symtab_index) {
>> + if (symtab_index &&
>> + (ELF32_ST_VISIBILITY(symtab[symtab_index].st_other)
>> + != STV_PROTECTED)) {
>> symbol_addr = (unsigned long)_dl_find_hash(symname, scope, tpnt,
>> elf_machine_type_class(reloc_type),
>> &tls_tpnt);
>>
>>
>
> Does not seem to work as expected. When using this, and getting the
> case when pthread_self is being forwarded via libc (so we end up using
> relocation of protected __pthread_self in nptl).
>
> where
> #0 0x0000964d in ?? ()
> #1 0xb785302f in pthread_self () at libpthread/nptl/forward.c:137
> #2 0xb77b66be in plugin_main () from ./plugin.so
> #3 0xb7876672 in main () from /home/ncopa/pthread/test
>
> But the symbol should is actually located at:
>
> (gdb) p __pthread_self
> $3 = {pthread_t (void)} 0xb77c264d <__pthread_self>
>
> Smells like we did not add the base address.
We are missing a:
DL_FIND_HASH_VALUE(tpnt, type_class, sym);
that turns into:
DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr)
# define DL_RELOC_ADDR(LOADADDR, ADDR) \
((LOADADDR) + (ADDR))
That is done implicitly by the _dl_find_hash.
I wonder if we can just simply add this to the else
block, or if need to make the protected symbol case
separate.
More information about the uClibc
mailing list