* elfxx-mips.c (mips_got_entry): Update comments.
(mips_elf_multi_got_entry_eq): Rename to...
(mips_elf_got_entry_eq): ...this, deleting the old definition.
(mips_elf_create_got_info): Remove master_got_p argument.
Always use mips_elf_got_entry_eq.
(mips_elf_bfd_got, mips_elf_multi_got, mips_elf_create_got_section):
Update calls accordingly.
ld/testsuite/
* ld-mips-elf/tlsdyn-o32-1.d, ld-mips-elf/tlsdyn-o32-1.got,
ld-mips-elf/tlsdyn-o32-2.d, ld-mips-elf/tlsdyn-o32-2.got,
ld-mips-elf/tlsdyn-o32-3.d, ld-mips-elf/tlsdyn-o32-3.got,
ld-mips-elf/tls-hidden3.d, ld-mips-elf/tls-hidden3.got: Update
for new hash table order.
+2013-02-11 Richard Sandiford <rdsandiford@googlemail.com>
+
+ * elfxx-mips.c (mips_got_entry): Update comments.
+ (mips_elf_multi_got_entry_eq): Rename to...
+ (mips_elf_got_entry_eq): ...this, deleting the old definition.
+ (mips_elf_create_got_info): Remove master_got_p argument.
+ Always use mips_elf_got_entry_eq.
+ (mips_elf_bfd_got, mips_elf_multi_got, mips_elf_create_got_section):
+ Update calls accordingly.
+
2013-02-11 Richard Sandiford <rdsandiford@googlemail.com>
* elfxx-mips.c (mips_got_info): Remove bfd2got.
#include "hashtab.h"
/* This structure is used to hold information about one GOT entry.
- There are three types of entry:
-
- (1) absolute addresses
- (abfd == NULL)
- (2) SYMBOL + OFFSET addresses, where SYMBOL is local to an input bfd
- (abfd != NULL, symndx >= 0)
- (3) SYMBOL addresses, where SYMBOL is not local to an input bfd
- (abfd != NULL, symndx == -1)
-
- Type (3) entries are treated differently for different types of GOT.
- In the "master" GOT -- i.e. the one that describes every GOT
- reference needed in the link -- the mips_got_entry is keyed on both
- the symbol and the input bfd that references it. If it turns out
- that we need multiple GOTs, we can then use this information to
- create separate GOTs for each input bfd.
-
- However, we want each of these separate GOTs to have at most one
- entry for a given symbol, so their type (3) entries are keyed only
- on the symbol. The input bfd given by the "abfd" field is somewhat
- arbitrary in this case.
-
- This means that when there are multiple GOTs, each GOT has a unique
- mips_got_entry for every symbol within it. We can therefore use the
- mips_got_entry fields (tls_type and gotidx) to track the symbol's
- GOT index.
-
- However, if it turns out that we need only a single GOT, we continue
- to use the master GOT to describe it. There may therefore be several
- mips_got_entries for the same symbol, each with a different input bfd.
- We want to make sure that each symbol gets a unique GOT entry, so when
- there's a single GOT, we use the symbol's hash entry, not the
- mips_got_entry fields, to track a symbol's GOT index. */
+ There are four types of entry:
+
+ (1) an absolute address
+ requires: abfd == NULL
+ fields: d.address
+
+ (2) a SYMBOL + OFFSET address, where SYMBOL is local to an input bfd
+ requires: abfd != NULL, symndx >= 0, tls_type != GOT_TLS_LDM
+ fields: abfd, symndx, d.addend, tls_type
+
+ (3) a SYMBOL address, where SYMBOL is not local to an input bfd
+ requires: abfd != NULL, symndx == -1
+ fields: d.h, tls_type
+
+ (4) a TLS LDM slot
+ requires: abfd != NULL, symndx == 0, tls_type == GOT_TLS_LDM
+ fields: none; there's only one of these per GOT. */
struct mips_got_entry
{
- /* The input bfd in which the symbol is defined. */
+ /* One input bfd that needs the GOT entry. */
bfd *abfd;
/* The index of the symbol, as stored in the relocation r_info, if
we have a local symbol; -1 otherwise. */
that should be added to the symbol value. */
bfd_vma addend;
/* If abfd != NULL && symndx == -1, the hash table entry
- corresponding to symbol in the GOT. The symbol's entry
+ corresponding to a symbol in the GOT. The symbol's entry
is in the local area if h->global_got_area is GGA_NONE,
otherwise it is in the global area. */
struct mips_elf_link_hash_entry *h;
#endif
}
-/* got_entries only match if they're identical, except for gotidx, so
- use all fields to compute the hash, and compare the appropriate
- union members. */
-
-static int
-mips_elf_got_entry_eq (const void *entry1, const void *entry2)
-{
- const struct mips_got_entry *e1 = (struct mips_got_entry *)entry1;
- const struct mips_got_entry *e2 = (struct mips_got_entry *)entry2;
-
- return (e1->abfd == e2->abfd
- && e1->symndx == e2->symndx
- && (e1->tls_type & GOT_TLS_TYPE) == (e2->tls_type & GOT_TLS_TYPE)
- && (!e1->abfd ? e1->d.address == e2->d.address
- : e1->symndx >= 0 ? e1->d.addend == e2->d.addend
- : e1->d.h == e2->d.h));
-}
-
-/* multi_got_entries are still a match in the case of global objects,
- even if the input bfd in which they're referenced differs, so the
- hash computation and compare functions are adjusted
- accordingly. */
-
static hashval_t
mips_elf_got_entry_hash (const void *entry_)
{
}
static int
-mips_elf_multi_got_entry_eq (const void *entry1, const void *entry2)
+mips_elf_got_entry_eq (const void *entry1, const void *entry2)
{
const struct mips_got_entry *e1 = (struct mips_got_entry *)entry1;
const struct mips_got_entry *e2 = (struct mips_got_entry *)entry2;
return entry1->abfd == entry2->abfd && entry1->symndx == entry2->symndx;
}
\f
-/* Create and return a new mips_got_info structure. MASTER_GOT_P
- is true if this is the master GOT rather than a multigot. */
+/* Create and return a new mips_got_info structure. */
static struct mips_got_info *
-mips_elf_create_got_info (bfd *abfd, bfd_boolean master_got_p)
+mips_elf_create_got_info (bfd *abfd)
{
struct mips_got_info *g;
return NULL;
g->tls_ldm_offset = MINUS_ONE;
- if (master_got_p)
- g->got_entries = htab_try_create (1, mips_elf_got_entry_hash,
- mips_elf_got_entry_eq, NULL);
- else
- g->got_entries = htab_try_create (1, mips_elf_got_entry_hash,
- mips_elf_multi_got_entry_eq, NULL);
+ g->got_entries = htab_try_create (1, mips_elf_got_entry_hash,
+ mips_elf_got_entry_eq, NULL);
if (g->got_entries == NULL)
return NULL;
tdata = mips_elf_tdata (abfd);
if (!tdata->got && create_p)
- tdata->got = mips_elf_create_got_info (abfd, FALSE);
+ tdata->got = mips_elf_create_got_info (abfd);
return tdata->got;
}
/* If we do not find any suitable primary GOT, create an empty one. */
if (got_per_bfd_arg.primary == NULL)
- g->next = mips_elf_create_got_info (abfd, FALSE);
+ g->next = mips_elf_create_got_info (abfd);
else
g->next = got_per_bfd_arg.primary;
g->next->next = got_per_bfd_arg.current;
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
return FALSE;
- htab->got_info = mips_elf_create_got_info (abfd, TRUE);
+ htab->got_info = mips_elf_create_got_info (abfd);
mips_elf_section_data (s)->elf.this_hdr.sh_flags
|= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
+2013-02-11 Richard Sandiford <rdsandiford@googlemail.com>
+
+ * ld-mips-elf/tlsdyn-o32-1.d, ld-mips-elf/tlsdyn-o32-1.got,
+ ld-mips-elf/tlsdyn-o32-2.d, ld-mips-elf/tlsdyn-o32-2.got,
+ ld-mips-elf/tlsdyn-o32-3.d, ld-mips-elf/tlsdyn-o32-3.got,
+ ld-mips-elf/tls-hidden3.d, ld-mips-elf/tls-hidden3.got: Update
+ for new hash table order.
+
2013-02-11 Richard Sandiford <rdsandiford@googlemail.com>
* ld-mips-elf/tls-hidden4.got, ld-mips-elf/tls-multi-got-1.d,
#
# The TLS entries are ordered as follows:
#
-# foo0 (-0x7ff0 + 0x20)
+# foo3 (-0x7ff0 + 0x20)
# foo1 (-0x7ff0 + 0x24)
# foo2 (-0x7ff0 + 0x28)
-# foo3 (-0x7ff0 + 0x2c)
+# foo0 (-0x7ff0 + 0x2c)
#
# Any order would be acceptable, but it must match the .got dump.
#
00080c00 <\.text>:
- 80c00: 8f84801c lw a0,-32740\(gp\)
+ 80c00: 8f848028 lw a0,-32728\(gp\)
80c04: 8f848020 lw a0,-32736\(gp\)
80c08: 8f848024 lw a0,-32732\(gp\)
- 80c0c: 8f848028 lw a0,-32728\(gp\)
- 80c10: 8f84801c lw a0,-32740\(gp\)
+ 80c0c: 8f84801c lw a0,-32740\(gp\)
+ 80c10: 8f848028 lw a0,-32728\(gp\)
80c14: 8f848020 lw a0,-32736\(gp\)
80c18: 8f848024 lw a0,-32732\(gp\)
- 80c1c: 8f848028 lw a0,-32728\(gp\)
+ 80c1c: 8f84801c lw a0,-32740\(gp\)
#
# The order of the TLS entries is:
#
-# foo0 (offset 0x20)
+# foo3 (offset 0x20)
# foo1 (offset 0x24)
# foo2 (offset 0x28)
-# foo3 (offset 0x2c)
+# foo0 (offset 0x2c)
#
# Any order would be acceptable, but it must match the .d dump.
#
Contents of section \.got:
- 90000 00000000 80000000 00000000 0000abc0 .*
- 90010 0000abc4 0000abc8 0000abcc .*
+ 90000 00000000 80000000 00000000 0000abcc .*
+ 90010 0000abc4 0000abc8 0000abc0 .*
.*: 03a0f021 move s8,sp
.*: afbc0000 sw gp,0\(sp\)
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848020 addiu a0,gp,-32736
+ .*: 27848028 addiu a0,gp,-32728
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848034 addiu a0,gp,-32716
+ .*: 2784801c addiu a0,gp,-32740
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848028 addiu a0,gp,-32728
+ .*: 27848034 addiu a0,gp,-32716
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 24638000 addiu v1,v1,-32768
.*: 00621821 addu v1,v1,v0
.*: 7c02283b rdhwr v0,\$5
- .*: 8f83801c lw v1,-32740\(gp\)
+ .*: 8f838024 lw v1,-32732\(gp\)
.*: 00000000 nop
.*: 00621821 addu v1,v1,v0
.*: 8f838030 lw v1,-32720\(gp\)
.*: 03a0f021 move s8,sp
.*: afbc0000 sw gp,0\(sp\)
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848020 addiu a0,gp,-32736
+ .*: 27848028 addiu a0,gp,-32728
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848034 addiu a0,gp,-32716
+ .*: 2784801c addiu a0,gp,-32740
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848028 addiu a0,gp,-32728
+ .*: 27848034 addiu a0,gp,-32716
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 24638000 addiu v1,v1,-32768
.*: 00621821 addu v1,v1,v0
.*: 7c02283b rdhwr v0,\$5
- .*: 8f83801c lw v1,-32740\(gp\)
+ .*: 8f838024 lw v1,-32732\(gp\)
.*: 00000000 nop
.*: 00621821 addu v1,v1,v0
.*: 8f838030 lw v1,-32720\(gp\)
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-10000030 R_MIPS_TLS_DTPMOD32 tlsbin_gd
-10000034 R_MIPS_TLS_DTPREL32 tlsbin_gd
-10000044 R_MIPS_TLS_DTPMOD32 tlsvar_gd
-10000048 R_MIPS_TLS_DTPREL32 tlsvar_gd
+10000038 R_MIPS_TLS_DTPMOD32 tlsbin_gd
+1000003c R_MIPS_TLS_DTPREL32 tlsbin_gd
+1000002c R_MIPS_TLS_DTPMOD32 tlsvar_gd
+10000030 R_MIPS_TLS_DTPREL32 tlsvar_gd
10000040 R_MIPS_TLS_TPREL32 tlsvar_ie
-1000002c R_MIPS_TLS_TPREL32 tlsbin_ie
+10000034 R_MIPS_TLS_TPREL32 tlsbin_ie
Contents of section .got:
10000020 00000000 80000000 004004ac 00000000 .........@......
- 10000030 00000000 00000000 00000001 00000000 ................
- 10000040 00000000 00000000 00000000 ............
+ 10000030 00000000 00000000 00000000 00000000 ................
+ 10000040 00000000 00000001 00000000 ............
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848034 addiu a0,gp,-32716
+ .*: 2784801c addiu a0,gp,-32740
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848020 addiu a0,gp,-32736
+ .*: 27848034 addiu a0,gp,-32716
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 24638000 addiu v1,v1,-32768
.*: 00621821 addu v1,v1,v0
.*: 7c02283b rdhwr v0,\$5
- .*: 8f83801c lw v1,-32740\(gp\)
+ .*: 8f838024 lw v1,-32732\(gp\)
.*: 00000000 nop
.*: 00621821 addu v1,v1,v0
.*: 8f838030 lw v1,-32720\(gp\)
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848034 addiu a0,gp,-32716
+ .*: 2784801c addiu a0,gp,-32740
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848020 addiu a0,gp,-32736
+ .*: 27848034 addiu a0,gp,-32716
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 24638000 addiu v1,v1,-32768
.*: 00621821 addu v1,v1,v0
.*: 7c02283b rdhwr v0,\$5
- .*: 8f83801c lw v1,-32740\(gp\)
+ .*: 8f838024 lw v1,-32732\(gp\)
.*: 00000000 nop
.*: 00621821 addu v1,v1,v0
.*: 8f838030 lw v1,-32720\(gp\)
00000000 R_MIPS_NONE \*ABS\*
10000038 R_MIPS_TLS_DTPMOD32 tlsbin_gd
1000003c R_MIPS_TLS_DTPREL32 tlsbin_gd
-10000044 R_MIPS_TLS_DTPMOD32 tlsvar_gd
-10000048 R_MIPS_TLS_DTPREL32 tlsvar_gd
+1000002c R_MIPS_TLS_DTPMOD32 tlsvar_gd
+10000030 R_MIPS_TLS_DTPREL32 tlsvar_gd
10000040 R_MIPS_TLS_TPREL32 tlsvar_ie
-1000002c R_MIPS_TLS_TPREL32 tlsbin_ie
+10000034 R_MIPS_TLS_TPREL32 tlsbin_ie
Contents of section .got:
10000020 00000000 80000000 004004ac 00000000 .*
- 10000030 00000001 00000000 00000000 00000000 .*
- 10000040 00000000 00000000 00000000 .*
+ 10000030 00000000 00000000 00000000 00000000 .*
+ 10000040 00000000 00000001 00000000 .*
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848034 addiu a0,gp,-32716
+ .*: 2784801c addiu a0,gp,-32740
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848020 addiu a0,gp,-32736
+ .*: 27848034 addiu a0,gp,-32716
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 24638000 addiu v1,v1,-32768
.*: 00621821 addu v1,v1,v0
.*: 7c02283b rdhwr v0,\$5
- .*: 8f83801c lw v1,-32740\(gp\)
+ .*: 8f838024 lw v1,-32732\(gp\)
.*: 00000000 nop
.*: 00621821 addu v1,v1,v0
.*: 8f838030 lw v1,-32720\(gp\)
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848034 addiu a0,gp,-32716
+ .*: 2784801c addiu a0,gp,-32740
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 00000000 nop
.*: 8f998018 lw t9,-32744\(gp\)
- .*: 27848020 addiu a0,gp,-32736
+ .*: 27848034 addiu a0,gp,-32716
.*: 0320f809 jalr t9
.*: 00000000 nop
.*: 8fdc0000 lw gp,0\(s8\)
.*: 24638000 addiu v1,v1,-32768
.*: 00621821 addu v1,v1,v0
.*: 7c02283b rdhwr v0,\$5
- .*: 8f83801c lw v1,-32740\(gp\)
+ .*: 8f838024 lw v1,-32732\(gp\)
.*: 00000000 nop
.*: 00621821 addu v1,v1,v0
.*: 8f838030 lw v1,-32720\(gp\)
00000000 R_MIPS_NONE \*ABS\*
10000038 R_MIPS_TLS_DTPMOD32 tlsbin_gd
1000003c R_MIPS_TLS_DTPREL32 tlsbin_gd
-10000044 R_MIPS_TLS_DTPMOD32 tlsvar_gd
-10000048 R_MIPS_TLS_DTPREL32 tlsvar_gd
+1000002c R_MIPS_TLS_DTPMOD32 tlsvar_gd
+10000030 R_MIPS_TLS_DTPREL32 tlsvar_gd
10000040 R_MIPS_TLS_TPREL32 tlsvar_ie
-1000002c R_MIPS_TLS_TPREL32 tlsbin_ie
+10000034 R_MIPS_TLS_TPREL32 tlsbin_ie
Contents of section .got:
10000020 00000000 80000000 0040055c 00000000 .*
- 10000030 00000001 00000000 00000000 00000000 .*
- 10000040 00000000 00000000 00000000 .*
+ 10000030 00000000 00000000 00000000 00000000 .*
+ 10000040 00000000 00000001 00000000 .*