public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* ld.so TLS problems
@ 2002-09-16  6:44 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2002-09-16  6:44 UTC (permalink / raw)
  To: Roland McGrath, Ulrich Drepper; +Cc: Glibc hackers

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-16 13:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-16  6:44 ld.so TLS problems Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).