* [PATCH] Fix TLS handling in ld.so on i386/sh/sparc32
@ 2004-05-14 23:15 Jakub Jelinek
2004-05-15 7:50 ` Jakub Jelinek
2004-05-18 0:40 ` Ulrich Drepper
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2004-05-14 23:15 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers, tcallawa
Hi!
When attempting to add TLS support for prelink on SPARC, I have noticed
ld.so segfaults. CHECK_STATIC_TLS must never be called if sym_map == NULL
(which is iff sym == NULL). Looking around revealed the same problem
on SH and in i386 RELA handling (I have added 2 new testcases to prelink
where one of them fails on i386 unless this patch is in).
2004-05-14 Jakub Jelinek <jakub@redhat.com>
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Only
CHECK_STATIC_TLS if sym != NULL.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/i386/dl-machine.h (elf_machine_rela): Likewise.
--- libc/sysdeps/sparc/sparc32/dl-machine.h.jj 2004-04-21 10:06:11.000000000 +0200
+++ libc/sysdeps/sparc/sparc32/dl-machine.h 2004-05-14 23:37:55.412726806 +0200
@@ -521,22 +521,27 @@ elf_machine_rela (struct link_map *map,
/* We know the offset of object the symbol is contained in.
It is a negative value which will be added to the
thread pointer. */
- CHECK_STATIC_TLS (map, sym_map);
- *reloc_addr
- = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
- + reloc->r_addend;
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = sym->st_value - sym_map->l_tls_offset
+ + reloc->r_addend;
+ }
break;
# ifndef RTLD_BOOTSTRAP
case R_SPARC_TLS_LE_HIX22:
case R_SPARC_TLS_LE_LOX10:
- CHECK_STATIC_TLS (map, sym_map);
- value = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
- + reloc->r_addend;
- if (r_type == R_SPARC_TLS_LE_HIX22)
- *reloc_addr = (*reloc_addr & 0xffc00000) | ((~value) >> 10);
- else
- *reloc_addr = (*reloc_addr & 0xffffe000) | (value & 0x3ff)
- | 0x1c00;
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ value = sym->st_value - sym_map->l_tls_offset
+ + reloc->r_addend;
+ if (r_type == R_SPARC_TLS_LE_HIX22)
+ *reloc_addr = (*reloc_addr & 0xffc00000) | ((~value) >> 10);
+ else
+ *reloc_addr = (*reloc_addr & 0xffffe000) | (value & 0x3ff)
+ | 0x1c00;
+ }
break;
# endif
#endif
--- libc/sysdeps/sh/dl-machine.h.jj 2004-03-11 11:10:19.000000000 +0100
+++ libc/sysdeps/sh/dl-machine.h 2004-05-14 23:36:13.157052354 +0200
@@ -580,10 +580,12 @@ elf_machine_rela (struct link_map *map,
It is a positive value which will be added to the thread
pointer. To get the variable position in the TLS block
we add the offset from that of the TLS block. */
- CHECK_STATIC_TLS (map, sym_map);
- *reloc_addr
- = ((sym == NULL ? 0 : sym_map->l_tls_offset + sym->st_value)
- + reloc->r_addend);
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = sym_map->l_tls_offset + sym->st_value
+ + reloc->r_addend;
+ }
# endif
break;
#endif /* use TLS */
--- libc/sysdeps/i386/dl-machine.h.jj 2004-03-09 10:58:16.000000000 +0100
+++ libc/sysdeps/i386/dl-machine.h 2004-05-14 23:35:10.295317995 +0200
@@ -587,20 +587,24 @@ elf_machine_rela (struct link_map *map,
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. */
- CHECK_STATIC_TLS (map, sym_map);
- *reloc_addr
- = (sym == NULL ? 0 : sym_map->l_tls_offset - sym->st_value)
- + reloc->r_addend;
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = sym_map->l_tls_offset - sym->st_value
+ + reloc->r_addend;
+ }
break;
case R_386_TLS_TPOFF:
/* The offset is negative, forward from the thread pointer. */
/* We know the offset of object the symbol is contained in.
It is a negative value which will be added to the
thread pointer. */
- CHECK_STATIC_TLS (map, sym_map);
- *reloc_addr
- = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
- + reloc->r_addend;
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = sym->st_value - sym_map->l_tls_offset
+ + reloc->r_addend;
+ }
break;
# endif /* use TLS */
case R_386_COPY:
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Fix TLS handling in ld.so on i386/sh/sparc32
2004-05-14 23:15 [PATCH] Fix TLS handling in ld.so on i386/sh/sparc32 Jakub Jelinek
@ 2004-05-15 7:50 ` Jakub Jelinek
2004-05-18 0:40 ` Ulrich Drepper
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2004-05-15 7:50 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers, tcallawa
Hi!
When attempting to add TLS support for prelink on SPARC, I have noticed
ld.so segfaults. CHECK_STATIC_TLS must never be called if sym_map == NULL
(which is iff sym == NULL). Looking around revealed the same problem
on SH and in i386 RELA handling (I have added 2 new testcases to prelink
where one of them fails on i386 unless this patch is in).
2004-05-14 Jakub Jelinek <jakub@redhat.com>
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Only
CHECK_STATIC_TLS if sym != NULL.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/i386/dl-machine.h (elf_machine_rela): Likewise.
--- libc/sysdeps/sparc/sparc32/dl-machine.h.jj 2004-04-21 10:06:11.000000000 +0200
+++ libc/sysdeps/sparc/sparc32/dl-machine.h 2004-05-14 23:37:55.412726806 +0200
@@ -521,22 +521,27 @@ elf_machine_rela (struct link_map *map,
/* We know the offset of object the symbol is contained in.
It is a negative value which will be added to the
thread pointer. */
- CHECK_STATIC_TLS (map, sym_map);
- *reloc_addr
- = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
- + reloc->r_addend;
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = sym->st_value - sym_map->l_tls_offset
+ + reloc->r_addend;
+ }
break;
# ifndef RTLD_BOOTSTRAP
case R_SPARC_TLS_LE_HIX22:
case R_SPARC_TLS_LE_LOX10:
- CHECK_STATIC_TLS (map, sym_map);
- value = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
- + reloc->r_addend;
- if (r_type == R_SPARC_TLS_LE_HIX22)
- *reloc_addr = (*reloc_addr & 0xffc00000) | ((~value) >> 10);
- else
- *reloc_addr = (*reloc_addr & 0xffffe000) | (value & 0x3ff)
- | 0x1c00;
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ value = sym->st_value - sym_map->l_tls_offset
+ + reloc->r_addend;
+ if (r_type == R_SPARC_TLS_LE_HIX22)
+ *reloc_addr = (*reloc_addr & 0xffc00000) | ((~value) >> 10);
+ else
+ *reloc_addr = (*reloc_addr & 0xffffe000) | (value & 0x3ff)
+ | 0x1c00;
+ }
break;
# endif
#endif
--- libc/sysdeps/sh/dl-machine.h.jj 2004-03-11 11:10:19.000000000 +0100
+++ libc/sysdeps/sh/dl-machine.h 2004-05-14 23:36:13.157052354 +0200
@@ -580,10 +580,12 @@ elf_machine_rela (struct link_map *map,
It is a positive value which will be added to the thread
pointer. To get the variable position in the TLS block
we add the offset from that of the TLS block. */
- CHECK_STATIC_TLS (map, sym_map);
- *reloc_addr
- = ((sym == NULL ? 0 : sym_map->l_tls_offset + sym->st_value)
- + reloc->r_addend);
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = sym_map->l_tls_offset + sym->st_value
+ + reloc->r_addend;
+ }
# endif
break;
#endif /* use TLS */
--- libc/sysdeps/i386/dl-machine.h.jj 2004-03-09 10:58:16.000000000 +0100
+++ libc/sysdeps/i386/dl-machine.h 2004-05-14 23:35:10.295317995 +0200
@@ -587,20 +587,24 @@ elf_machine_rela (struct link_map *map,
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. */
- CHECK_STATIC_TLS (map, sym_map);
- *reloc_addr
- = (sym == NULL ? 0 : sym_map->l_tls_offset - sym->st_value)
- + reloc->r_addend;
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = sym_map->l_tls_offset - sym->st_value
+ + reloc->r_addend;
+ }
break;
case R_386_TLS_TPOFF:
/* The offset is negative, forward from the thread pointer. */
/* We know the offset of object the symbol is contained in.
It is a negative value which will be added to the
thread pointer. */
- CHECK_STATIC_TLS (map, sym_map);
- *reloc_addr
- = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
- + reloc->r_addend;
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = sym->st_value - sym_map->l_tls_offset
+ + reloc->r_addend;
+ }
break;
# endif /* use TLS */
case R_386_COPY:
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix TLS handling in ld.so on i386/sh/sparc32
2004-05-14 23:15 [PATCH] Fix TLS handling in ld.so on i386/sh/sparc32 Jakub Jelinek
2004-05-15 7:50 ` Jakub Jelinek
@ 2004-05-18 0:40 ` Ulrich Drepper
1 sibling, 0 replies; 3+ messages in thread
From: Ulrich Drepper @ 2004-05-18 0:40 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Glibc hackers, tcallawa
Applied.
--
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-05-17 18:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-14 23:15 [PATCH] Fix TLS handling in ld.so on i386/sh/sparc32 Jakub Jelinek
2004-05-15 7:50 ` Jakub Jelinek
2004-05-18 0:40 ` Ulrich Drepper
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).