aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-mips.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2003-04-12 00:31:42 +0000
committerAlexandre Oliva <aoliva@redhat.com>2003-04-12 00:31:42 +0000
commit0176c794f8a432e7f115af1dfb8f9ad6f24a0a5e (patch)
tree249259a72fc0f22ef2c7210b0f1fc73dacd67894 /bfd/elfxx-mips.c
parent2252e863673a8c1b0c7a3753cf600a96a574e619 (diff)
downloadgdb-0176c794f8a432e7f115af1dfb8f9ad6f24a0a5e.zip
gdb-0176c794f8a432e7f115af1dfb8f9ad6f24a0a5e.tar.gz
gdb-0176c794f8a432e7f115af1dfb8f9ad6f24a0a5e.tar.bz2
* elfxx-mips.c (mips_elf_get_global_gotsym_index): New.
(mips_elf_calculate_relocation): Decay GOT_PAGE/GOT_OFST to GOT_DISP/addend only if the symbol got a global GOT entry.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r--bfd/elfxx-mips.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index d2ba1cf..73d0520 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -408,6 +408,7 @@ static asection * mips_elf_rel_dyn_section PARAMS ((bfd *, bfd_boolean));
static asection * mips_elf_got_section PARAMS ((bfd *, bfd_boolean));
static struct mips_got_info *mips_elf_got_info
PARAMS ((bfd *, asection **));
+static long mips_elf_get_global_gotsym_index PARAMS ((bfd *abfd));
static bfd_vma mips_elf_local_got_index
PARAMS ((bfd *, bfd *, struct bfd_link_info *, bfd_vma));
static bfd_vma mips_elf_global_got_index
@@ -1707,6 +1708,29 @@ mips_elf_got_info (abfd, sgotp)
return g;
}
+/* Obtain the lowest dynamic index of a symbol that was assigned a
+ global GOT entry. */
+static long
+mips_elf_get_global_gotsym_index (abfd)
+ bfd *abfd;
+{
+ asection *sgot;
+ struct mips_got_info *g;
+
+ if (abfd == NULL)
+ return 0;
+
+ sgot = mips_elf_got_section (abfd, TRUE);
+ if (sgot == NULL || mips_elf_section_data (sgot) == NULL)
+ return 0;
+
+ g = mips_elf_section_data (sgot)->u.got_info;
+ if (g == NULL || g->global_gotsym == NULL)
+ return 0;
+
+ return g->global_gotsym->dynindx;
+}
+
/* Returns the GOT offset at which the indicated address can be found.
If there is not yet a GOT entry for this value, create one. Returns
-1 if no satisfactory GOT offset can be found. */
@@ -3197,9 +3221,12 @@ mips_elf_calculate_relocation (abfd, input_bfd, input_section, info,
switch (r_type)
{
case R_MIPS_GOT_PAGE:
- /* If we didn't create a dynamic index for this symbol, it can
- be regarded as local. */
- if (local_p || ! h || h->root.dynindx < 0)
+ /* If this symbol got a global GOT entry, we have to decay
+ GOT_PAGE/GOT_OFST to GOT_DISP/addend. */
+ if (local_p || ! h
+ || (h->root.dynindx
+ < mips_elf_get_global_gotsym_index (elf_hash_table (info)
+ ->dynobj)))
break;
/* Fall through. */