This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[4/20] MIPS GOT: Avoid double-counting TLS entries
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 11 Feb 2013 17:29:29 +0000
- Subject: [4/20] MIPS GOT: Avoid double-counting TLS entries
- References: <87fw1222fy.fsf@talisman.default>
When indirect and warning symbols have TLS type, that type is recorded
in both the original symbol and the target symbol. This leads the current
GOT code to set aside two sets of entries, wasting some space.
These count functions disappear in later patches, so I didn't bother
adding comments. The assert and testsuite changes stay though.
Richard
bfd/
* elfxx-mips.c (mips_elf_count_global_tls_entries)
(mips_elf_count_global_tls_relocs): Don't count indirect or
warning symbols.
(mips_elf_multi_got, mips_elf_lay_out_got): Assert that the right
number of TLS entries were allocated.
ld/testsuite/
* ld-mips-elf/tlsdyn-o32-2.got, ld-mips-elf/tlsdyn-o32-3.got: Remove
unused GOT entries.
Index: bfd/elfxx-mips.c
===================================================================
--- bfd/elfxx-mips.c 2013-02-11 14:06:31.292149605 +0000
+++ bfd/elfxx-mips.c 2013-02-11 14:06:31.820153685 +0000
@@ -2982,6 +2982,10 @@ mips_elf_count_global_tls_entries (void
= (struct mips_elf_link_hash_entry *) arg1;
struct mips_elf_count_tls_arg *arg = arg2;
+ if (hm->root.root.type == bfd_link_hash_indirect
+ || hm->root.root.type == bfd_link_hash_warning)
+ return 1;
+
if (hm->tls_type & GOT_TLS_GD)
arg->needed += 2;
if (hm->tls_type & GOT_TLS_IE)
@@ -3000,6 +3004,10 @@ mips_elf_count_global_tls_relocs (void *
= (struct mips_elf_link_hash_entry *) arg1;
struct mips_elf_count_tls_arg *arg = arg2;
+ if (hm->root.root.type == bfd_link_hash_indirect
+ || hm->root.root.type == bfd_link_hash_warning)
+ return 1;
+
arg->needed += mips_tls_got_relocs (arg->info, hm->tls_type, &hm->root);
return 1;
@@ -4688,6 +4696,7 @@ mips_elf_multi_got (bfd *abfd, struct bf
all non-TLS entries. */
g->tls_assigned_gotno = g->local_gotno + g->global_gotno;
htab_traverse (g->got_entries, mips_elf_initialize_tls_index, g);
+ BFD_ASSERT (g->tls_assigned_gotno == assign);
/* Move onto the next GOT. It will be a secondary GOT if nonull. */
g = gn;
@@ -8956,6 +8965,8 @@ mips_elf_lay_out_got (bfd *output_bfd, s
/* Set up TLS entries. */
g->tls_assigned_gotno = g->global_gotno + g->local_gotno;
htab_traverse (g->got_entries, mips_elf_initialize_tls_index, g);
+ BFD_ASSERT (g->tls_assigned_gotno
+ == g->global_gotno + g->local_gotno + g->tls_gotno);
/* Allocate room for the TLS relocations. */
arg.info = info;
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
===================================================================
--- ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got 2013-02-11 14:06:20.389068401 +0000
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got 2013-02-11 14:06:31.821153694 +0000
@@ -15,5 +15,4 @@ OFFSET TYPE VALUE
Contents of section .got:
10000020 00000000 80000000 004004ac 00000000 .*
10000030 00000000 00000000 00000000 00000000 .*
- 10000040 00000001 00000000 00000000 00000000 .*
- 10000050 00000000 00000000 .*
+ 10000040 00000001 00000000 00000000 .*
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
===================================================================
--- ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got 2013-02-11 14:06:20.390068409 +0000
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got 2013-02-11 14:06:31.822153702 +0000
@@ -15,5 +15,4 @@ OFFSET TYPE VALUE
Contents of section .got:
10000020 00000000 80000000 0040055c 00000000 .*
10000030 00000000 00000000 00000000 00000000 .*
- 10000040 00000001 00000000 00000000 00000000 .*
- 10000050 00000000 00000000 .*
+ 10000040 00000001 00000000 00000000 .*