+2008-07-28 Alexandre Oliva <aoliva@redhat.com>
+
+ * elf32-i386.c (struct elf_i386_link_hash_table): Added field
+ tls_module_base.
+ (elf_i386_link_hash_table_create): Initialize it.
+ (elf_i386_always_size_sections): Set it.
+ (set_tls_module_base): New.
+ (elf_i386_relocate_sections): Call it.
+ * elf64-x86-64.c (struct elf64_x86_64_link_hash_table): Added
+ field tls_module_base.
+ (elf64_x86_64_link_hash_table_create): Initialize it.
+ (elf64_x86_64_always_size_sections): Set it.
+ (set_tls_module_base): New.
+ (elf64_x86_64_relocate_sections): Call it.
+ Reported by Cary Coutant <ccoutant@google.com>
+
2008-07-28 Ineiev <ineiev@yahoo.co.uk>
* elf32-arm.c (arm_map_one_stub): Declare variables at beginning
/* Small local sym to section mapping cache. */
struct sym_sec_cache sym_sec;
+
+ /* _TLS_MODULE_BASE_ symbol. */
+ struct bfd_link_hash_entry *tls_module_base;
};
/* Get the i386 ELF linker hash table from a link_info structure. */
ret->is_vxworks = 0;
ret->srelplt2 = NULL;
ret->plt0_pad_byte = 0;
+ ret->tls_module_base = NULL;
return &ret->elf.root;
}
tls_sec, 0, NULL, FALSE,
bed->collect, &bh)))
return FALSE;
+
+ elf_i386_hash_table (info)->tls_module_base = bh;
+
tlsbase = (struct elf_link_hash_entry *)bh;
tlsbase->def_regular = 1;
tlsbase->other = STV_HIDDEN;
return TRUE;
}
+/* _TLS_MODULE_BASE_ needs to be treated especially when linking
+ executables. Rather than setting it to the beginning of the TLS
+ section, we have to set it to the end. This function may be called
+ multiple times, it is idempotent. */
+
+static void
+set_tls_module_base (struct bfd_link_info *info)
+{
+ struct bfd_link_hash_entry *base;
+
+ if (!info->executable)
+ return;
+
+ base = elf_i386_hash_table (info)->tls_module_base;
+
+ if (!base)
+ return;
+
+ base->u.def.value = elf_hash_table (info)->tls_size;
+}
+
/* Return the base VMA address which should be subtracted from real addresses
when resolving @dtpoff relocation.
This is PT_TLS segment p_vaddr. */
&& !strcmp (input_section->output_section->name,
".tls_vars"));
+ set_tls_module_base (info);
+
rel = relocs;
relend = relocs + input_section->reloc_count;
for (; rel < relend; rel++)
/* Small local sym to section mapping cache. */
struct sym_sec_cache sym_sec;
+
+ /* _TLS_MODULE_BASE_ symbol. */
+ struct bfd_link_hash_entry *tls_module_base;
};
/* Get the x86-64 ELF linker hash table from a link_info structure. */
ret->tlsdesc_got = 0;
ret->tls_ld_got.refcount = 0;
ret->sgotplt_jump_table_size = 0;
+ ret->tls_module_base = NULL;
return &ret->elf.root;
}
tls_sec, 0, NULL, FALSE,
bed->collect, &bh)))
return FALSE;
+
+ elf64_x86_64_hash_table (info)->tls_module_base = bh;
+
tlsbase = (struct elf_link_hash_entry *)bh;
tlsbase->def_regular = 1;
tlsbase->other = STV_HIDDEN;
return TRUE;
}
+/* _TLS_MODULE_BASE_ needs to be treated especially when linking
+ executables. Rather than setting it to the beginning of the TLS
+ section, we have to set it to the end. This function may be called
+ multiple times, it is idempotent. */
+
+static void
+set_tls_module_base (struct bfd_link_info *info)
+{
+ struct bfd_link_hash_entry *base;
+
+ if (!info->executable)
+ return;
+
+ base = elf64_x86_64_hash_table (info)->tls_module_base;
+
+ if (!base)
+ return;
+
+ base->u.def.value = elf_hash_table (info)->tls_size;
+}
+
/* Return the base VMA address which should be subtracted from real addresses
when resolving @dtpoff relocation.
This is PT_TLS segment p_vaddr. */
local_got_offsets = elf_local_got_offsets (input_bfd);
local_tlsdesc_gotents = elf64_x86_64_local_tlsdesc_gotent (input_bfd);
+ set_tls_module_base (info);
+
rel = relocs;
relend = relocs + input_section->reloc_count;
for (; rel < relend; rel++)
+2008-07-28 Alexandre Oliva <aoliva@redhat.com>
+
+ * ld-i386/tlsbindesc.dd: Adjust incorrect expectations for LD to
+ LE relaxation.
+ * ld-x86-64/tlsbindesc.dd: Likewise.
+ * ld-i386/tlsbindesc.rd: Adjust address of _TLS_MODULE_BASE_.
+ * ld-x86-64/tlsbindesc.rd: Likewise.
+ Reported by Cary Coutant <ccoutant@google.com>
+
2008-07-27 Alan Modra <amodra@bigpond.net.au>
* ld-gc/gc.exp (test_gc): xfail powerpc64.
[0-9a-f]+: 90[ ]+nop *
[0-9a-f]+: 90[ ]+nop *
# LD -> LE
- [0-9a-f]+: 8d 05 00 f0 ff ff[ ]+lea 0xfffff000,%eax
+ [0-9a-f]+: 8d 05 00 00 00 00[ ]+lea 0x0,%eax
[0-9a-f]+: 66 90[ ]+xchg %ax,%ax
[0-9a-f]+: 90[ ]+nop *
[0-9a-f]+: 90[ ]+nop *
[0-9a-f]+: 90[ ]+nop *
[0-9a-f]+: 90[ ]+nop *
# LD -> LE against hidden variables
- [0-9a-f]+: 8d 05 00 f0 ff ff[ ]+lea 0xfffff000,%eax
+ [0-9a-f]+: 8d 05 00 00 00 00[ ]+lea 0x0,%eax
[0-9a-f]+: 66 90[ ]+xchg %ax,%ax
[0-9a-f]+: 90[ ]+nop *
[0-9a-f]+: 90[ ]+nop *
+[0-9]+: 00000094 +0 TLS +LOCAL DEFAULT +8 bl6
+[0-9]+: 00000098 +0 TLS +LOCAL DEFAULT +8 bl7
+[0-9]+: 0000009c +0 TLS +LOCAL DEFAULT +8 bl8
- +[0-9]+: 00000000 +0 TLS +LOCAL HIDDEN +7 _TLS_MODULE_BASE_
+ +[0-9]+: 00001000 +0 TLS +LOCAL HIDDEN +7 _TLS_MODULE_BASE_
+[0-9]+: 0+804a060 +0 OBJECT LOCAL HIDDEN 9 _DYNAMIC
+[0-9]+: [0-9a-f]+ +0 OBJECT LOCAL HIDDEN 11 _GLOBAL_OFFSET_TABLE_
+[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT UND sG3
[0-9a-f]+: 90[ ]+nop *
[0-9a-f]+: 90[ ]+nop *
# LD -> LE
- [0-9a-f]+: 48 c7 c0 60 ff ff ff[ ]+mov \$0xf+60,%rax
+ [0-9a-f]+: 48 c7 c0 00 00 00 00[ ]+mov \$0x0,%rax
[0-9a-f]+: 66 90[ ]+xchg %ax,%ax
[0-9a-f]+: 90[ ]+nop *
[0-9a-f]+: 90[ ]+nop *
+[0-9]+: 0+94 +0 TLS +LOCAL DEFAULT +8 bl6
+[0-9]+: 0+98 +0 TLS +LOCAL DEFAULT +8 bl7
+[0-9]+: 0+9c +0 TLS +LOCAL DEFAULT +8 bl8
- +[0-9]+: 0+0 +0 TLS +LOCAL HIDDEN +7 _TLS_MODULE_BASE_
+ +[0-9]+: 0+a0 +0 TLS +LOCAL HIDDEN +7 _TLS_MODULE_BASE_
+[0-9]+: 0+601258 +0 OBJECT LOCAL HIDDEN 9 _DYNAMIC
+[0-9]+: 0+601378 +0 OBJECT LOCAL HIDDEN 11 _GLOBAL_OFFSET_TABLE_
+[0-9]+: 0+1c +0 TLS +GLOBAL DEFAULT +7 sg8