+2002-09-12 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/dl-machine.h (elf_machine_rel)
+ (case R_386_TLS_DTPMOD32): Don't use addend.
+ [case R_386_TLS_TPOFF32]: Remove redundant SYM_MAP != NULL check.
+ (elf_machine_rela): Add support for TLS relocs.
+
2002-09-14 Roland McGrath <roland@redhat.com>
* Makefile (manual/%): Add this pattern target to the iconvdata/% rule.
*reloc_addr = value;
break;
- /* XXX Remove TLS relocations which are not needed. */
-
#ifdef USE_TLS
case R_386_TLS_DTPMOD32:
# ifdef RTLD_BOOTSTRAP
/* During relocation all TLS symbols are defined and used.
Therefore the offset is already correct. */
if (sym != NULL)
- *reloc_addr += sym->st_value;
+ *reloc_addr = sym->st_value;
# endif
break;
case R_386_TLS_TPOFF32:
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_map != NULL && sym != NULL)
+ if (sym != NULL)
*reloc_addr += sym_map->l_tls_offset - sym->st_value;
# endif
break;
case R_386_PC32:
*reloc_addr = (value + reloc->r_addend - (Elf32_Addr) reloc_addr);
break;
- /* XXX Do we have to handle the TLS relocation here? */
+
+#ifdef USE_TLS
+ case R_386_TLS_DTPMOD32:
+# ifdef RTLD_BOOTSTRAP
+ /* During startup the dynamic linker is always the module
+ with index 1.
+ XXX If this relocation is necessary move before RESOLVE
+ call. */
+ *reloc_addr = 1;
+# else
+ /* Get the information from the link map returned by the
+ resolv function. */
+ if (sym_map != NULL)
+ *reloc_addr = sym_map->l_tls_modid;
+# endif
+ break;
+ case R_386_TLS_DTPOFF32:
+# ifndef RTLD_BOOTSTRAP
+ /* During relocation all TLS symbols are defined and used.
+ Therefore the offset is already correct. */
+ *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
+# endif
+ break;
+ 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 + reloc->r_addend;
+# 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. */
+ *reloc_addr
+ = (sym == NULL ? 0 : sym_map->l_tls_offset - sym->st_value)
+ + reloc->r_addend;
+# endif
+ break;
+#endif /* use TLS */
default:
/* We add these checks in the version to relocate ld.so only
if we are still debugging. */