This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Fix TLS Initial Exec relocs against local symbols
- From: Jakub Jelinek <jakub at redhat dot com>
- To: binutils at sources dot redhat dot com
- Cc: roland at redhat dot com, drepper at redhat dot com
- Date: Wed, 7 Aug 2002 23:30:49 +0200
- Subject: [PATCH] Fix TLS Initial Exec relocs against local symbols
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
As for non-dynamic symbols we are using symndx 0, we need to store
the addend to adjust the address to point to the actual static variable
in TLS image.
Ok to commit?
Note to Roland, unless you've done so already, i386/dl-machine.h in glibc
has to change too:
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_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_map != NULL && sym != NULL)
- *reloc_addr = sym_map->l_tls_offset - sym->st_value;
+ *reloc_addr += sym_map->l_tls_offset - sym->st_value;
# endif
2002-08-07 Jakub Jelinek <jakub@redhat.com>
* elf32-i386.c (elf_i386_relocate_section): Fill in proper addend
for R_386_TLS_TPOFF32 relocs against symndx 0.
--- bfd/elf32-i386.c.jj 2002-07-30 16:14:55.000000000 +0200
+++ bfd/elf32-i386.c 2002-08-07 23:41:48.000000000 +0200
@@ -2561,13 +2567,17 @@ elf_i386_relocate_section (output_bfd, i
outrel.r_offset = (htab->sgot->output_section->vma
+ htab->sgot->output_offset + off);
- bfd_put_32 (output_bfd, 0,
- htab->sgot->contents + off);
indx = h && h->dynindx != -1 ? h->dynindx : 0;
if (r_type == R_386_TLS_GD)
dr_type = R_386_TLS_DTPMOD32;
else
dr_type = R_386_TLS_TPOFF32;
+ if (dr_type == R_386_TLS_TPOFF32 && indx == 0)
+ bfd_put_32 (output_bfd, relocation - dtpoff_base (info),
+ htab->sgot->contents + off);
+ else
+ bfd_put_32 (output_bfd, 0,
+ htab->sgot->contents + off);
outrel.r_info = ELF32_R_INFO (indx, dr_type);
loc = (Elf32_External_Rel *) htab->srelgot->contents;
loc += htab->srelgot->reloc_count++;
Jakub