bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/27127] [mips] relocation type R_MIPS_GOT_HI16 conflict wit


From: dongjianqiang2 at huawei dot com
Subject: [Bug binutils/27127] [mips] relocation type R_MIPS_GOT_HI16 conflict with local symbol
Date: Tue, 29 Dec 2020 08:53:46 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=27127

--- Comment #1 from John Dong <dongjianqiang2 at huawei dot com> ---
This fixes mips32 got relocation overflow.

diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index d7e3aed3b6..4a8973a0b4 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -55,6 +55,13 @@ enum mips_got_tls_type {
   GOT_TLS_IE
 };

+/* Type of absolute address GOT entry.   */
+enum mips_got_abs_addr_type {
+  GOT_ABS_ADDR_NONE,
+  GOT_ABS_ADDR_LOW_PART,
+  GOT_ABS_ADDR_HIGH_PART
+};
+
 /* This structure is used to hold information about one GOT entry.
    There are four types of entry:

@@ -80,6 +87,8 @@ struct mips_got_entry
   /* The index of the symbol, as stored in the relocation r_info, if
      we have a local symbol; -1 otherwise.  */
   long symndx;
+  /* Absolute address type.  */
+  long type;
   union
   {
     /* If abfd == NULL, an address that must be stored in the got.  */
@@ -3129,7 +3138,8 @@ mips_elf_got_entry_eq (const void *entry1, const void
*entry2)
   return (e1->symndx == e2->symndx
          && e1->tls_type == e2->tls_type
          && (e1->tls_type == GOT_TLS_LDM ? TRUE
-             : !e1->abfd ? !e2->abfd && e1->d.address == e2->d.address
+             : !e1->abfd ? (!e2->abfd && e1->d.address == e2->d.address
+                            && e1->type == e2->type)
              : e1->symndx >= 0 ? (e1->abfd == e2->abfd
                                   && e1->d.addend == e2->d.addend)
              : e2->abfd && e1->d.h == e2->d.h));
@@ -3801,6 +3811,14 @@ mips_elf_create_local_got_entry (bfd *abfd, struct
bfd_link_info *info,
       return entry;
     }

+  if (got16_reloc_p (r_type)
+      || call16_reloc_p (r_type)
+      || got_page_reloc_p (r_type)
+      || got_disp_reloc_p (r_type))
+    lookup.type = GOT_ABS_ADDR_LOW_PART;
+  else
+    lookup.type = GOT_ABS_ADDR_HIGH_PART;
+
   lookup.abfd = NULL;
   lookup.symndx = -1;
   lookup.d.address = value;
@@ -3825,10 +3843,7 @@ mips_elf_create_local_got_entry (bfd *abfd, struct
bfd_link_info *info,
   if (!entry)
     return NULL;

-  if (got16_reloc_p (r_type)
-      || call16_reloc_p (r_type)
-      || got_page_reloc_p (r_type)
-      || got_disp_reloc_p (r_type))
+  if (lookup.type == GOT_ABS_ADDR_LOW_PART)
     lookup.gotidx = MIPS_ELF_GOT_SIZE (abfd) * g->assigned_low_gotno++;
   else
     lookup.gotidx = MIPS_ELF_GOT_SIZE (abfd) * g->assigned_high_gotno--;

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]