This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ld.so TLS problems


Hi!

We have a problem with errno in --with-tls ld.so:

        case R_386_TLS_TPOFF32:
          /* The offset is positive, backward from the thread pointer.  */
# ifdef RTLD_BOOTSTRAP
          *reloc_addr += map->l_tls_offset - sym->st_value;
# else
          /* We know the offset of object the symbol is contained in.
             It is a positive value which will be subtracted from the
             thread pointer.  To get the variable position in the TLS
             block we subtract the offset from that of the TLS block.  */
          if (sym != NULL)
            *reloc_addr += sym_map->l_tls_offset - sym->st_value;
# endif

This means that errno R_386_TLS_TPOFF32 .got slot is relocated
twice, without undoing what the first ld.so relocation did.
Even if _dl_rtld_map l_tls_offset is (temporarily) adjusted
for its initial l_tls_offset, I have a problem with prelink: if prelink
is to store the initial TPOFF32 reloc into ld.so, it would either
have to do REL->RELA conversion for ld.so (very bad - rela handling is
ATM #ifndef RTLD_BOOTSTRAP), or would have to be special cased for ld.so
all over prelink.

I wonder, do we really need TLS errno in ld.so?
ATM --without-tls ld.so has its private errno and __errno_location which
returns address of that variable (for all threads). Either this means
that all accesses to errno within the dynamic linker are before application
starts, or are guarded by dl_load_lock. Or it means --without-tls ld.so
is broken (as two different threads could modify/read the same errno
variable at the same time).
If the former is true, I think we should just use extern int errno attribute_hidden;
for IS_IN_rtld, otherwise we need to fix --without-tls ld.so first...

The only other TLS variable ld.so uses is __libc_tsd_DL_ERROR (but this one
for some reason doesn't use TPOFF32 ATM, will figure out what's going on).
I think that could be handled by *(GL(__libc_internal_tsd_[sg]et))().

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]