|
@@ -0,0 +1,201 @@
|
|
|
+From d930affa2d475d1cc6792f1e6d56bef3d6c617db Mon Sep 17 00:00:00 2001
|
|
|
+From: Cupertino Miranda <cmiranda@synopsys.com>
|
|
|
+Date: Fri, 2 Mar 2018 17:16:21 +0100
|
|
|
+Subject: [PATCH] Refactored location where GOT information is collected.
|
|
|
+
|
|
|
+Change location where GOT information is collected for ARC target, avoiding
|
|
|
+posible use conflicts of the previous .got field in the symbols hash_entry.
|
|
|
+
|
|
|
+bfd/
|
|
|
+2018-03-01 Cupertino Miranda <cmiranda@synopsys.com>
|
|
|
+
|
|
|
+ * arc-got.h (get_got_entry_list_for_symbol): Changed.
|
|
|
+ * ef32-arc.c (struct elf_arc_link_hash_entry): Moved and changed.
|
|
|
+ (elf_arc_link_hash_newfunc): Changed.
|
|
|
+ (arc_elf_link_hash_table_create): Removed old initializations.
|
|
|
+ (elf_arc_relocate_section, elf_arc_finish_dynamic_symbol): Changed.
|
|
|
+
|
|
|
+Signed-off-by: Cupertino Miranda <cmiranda@synopsys.com>
|
|
|
+Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
|
|
|
+[Romain: rebase on top of 2.31]
|
|
|
+Signed-off-by: Romain Naour <romain.naour@gmail.com>
|
|
|
+
|
|
|
+Upstream-Status: Pending
|
|
|
+---
|
|
|
+ bfd/arc-got.h | 6 +++--
|
|
|
+ bfd/elf32-arc.c | 77 +++++++++++++++++++++++++++++++--------------------------
|
|
|
+ 2 files changed, 46 insertions(+), 37 deletions(-)
|
|
|
+
|
|
|
+diff --git a/bfd/arc-got.h b/bfd/arc-got.h
|
|
|
+index a86061bcb38..81ce88fe21a 100644
|
|
|
+--- a/bfd/arc-got.h
|
|
|
++++ b/bfd/arc-got.h
|
|
|
+@@ -156,9 +156,11 @@ get_got_entry_list_for_symbol (bfd *abfd,
|
|
|
+ unsigned long r_symndx,
|
|
|
+ struct elf_link_hash_entry *h)
|
|
|
+ {
|
|
|
+- if (h != NULL)
|
|
|
++ struct elf_arc_link_hash_entry *h1 =
|
|
|
++ ((struct elf_arc_link_hash_entry *) h);
|
|
|
++ if (h1 != NULL)
|
|
|
+ {
|
|
|
+- return &h->got.glist;
|
|
|
++ return &h1->got_ents;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
|
|
|
+index a48ef0ca15f..ab84de43815 100644
|
|
|
+--- a/bfd/elf32-arc.c
|
|
|
++++ b/bfd/elf32-arc.c
|
|
|
+@@ -160,6 +160,18 @@ struct arc_relocation_data
|
|
|
+ const char * symbol_name;
|
|
|
+ };
|
|
|
+
|
|
|
++/* ARC ELF linker hash entry. */
|
|
|
++struct elf_arc_link_hash_entry
|
|
|
++{
|
|
|
++ struct elf_link_hash_entry root;
|
|
|
++
|
|
|
++ /* Track dynamic relocs copied for this symbol. */
|
|
|
++ struct elf_dyn_relocs *dyn_relocs;
|
|
|
++
|
|
|
++ struct got_entry *got_ents;
|
|
|
++};
|
|
|
++
|
|
|
++
|
|
|
+ /* Should be included at this location due to static declarations
|
|
|
+ defined before this point. */
|
|
|
+ #include "arc-got.h"
|
|
|
+@@ -281,15 +293,6 @@ struct arc_reloc_map
|
|
|
+ unsigned char elf_reloc_val;
|
|
|
+ };
|
|
|
+
|
|
|
+-/* ARC ELF linker hash entry. */
|
|
|
+-struct elf_arc_link_hash_entry
|
|
|
+-{
|
|
|
+- struct elf_link_hash_entry root;
|
|
|
+-
|
|
|
+- /* Track dynamic relocs copied for this symbol. */
|
|
|
+- struct elf_dyn_relocs *dyn_relocs;
|
|
|
+-};
|
|
|
+-
|
|
|
+ /* ARC ELF linker hash table. */
|
|
|
+ struct elf_arc_link_hash_table
|
|
|
+ {
|
|
|
+@@ -301,28 +304,28 @@ elf_arc_link_hash_newfunc (struct bfd_hash_entry *entry,
|
|
|
+ struct bfd_hash_table *table,
|
|
|
+ const char *string)
|
|
|
+ {
|
|
|
++ struct elf_arc_link_hash_entry * ret =
|
|
|
++ (struct elf_arc_link_hash_entry *) entry;
|
|
|
++
|
|
|
+ /* Allocate the structure if it has not already been allocated by a
|
|
|
+ subclass. */
|
|
|
+- if (entry == NULL)
|
|
|
+- {
|
|
|
+- entry = (struct bfd_hash_entry *)
|
|
|
+- bfd_hash_allocate (table,
|
|
|
+- sizeof (struct elf_arc_link_hash_entry));
|
|
|
+- if (entry == NULL)
|
|
|
+- return entry;
|
|
|
+- }
|
|
|
++ if (ret == NULL)
|
|
|
++ ret = (struct elf_arc_link_hash_entry *)
|
|
|
++ bfd_hash_allocate (table, sizeof (struct elf_arc_link_hash_entry));
|
|
|
++ if (ret == NULL)
|
|
|
++ return (struct bfd_hash_entry *) ret;
|
|
|
+
|
|
|
+ /* Call the allocation method of the superclass. */
|
|
|
+- entry = _bfd_elf_link_hash_newfunc (entry, table, string);
|
|
|
+- if (entry != NULL)
|
|
|
++ ret = ((struct elf_arc_link_hash_entry *)
|
|
|
++ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
|
|
|
++ table, string));
|
|
|
++ if (ret != NULL)
|
|
|
+ {
|
|
|
+- struct elf_arc_link_hash_entry *eh;
|
|
|
+-
|
|
|
+- eh = (struct elf_arc_link_hash_entry *) entry;
|
|
|
+- eh->dyn_relocs = NULL;
|
|
|
++ ret->dyn_relocs = NULL;
|
|
|
++ ret->got_ents = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+- return entry;
|
|
|
++ return (struct bfd_hash_entry *) ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Destroy an ARC ELF linker hash table. */
|
|
|
+@@ -352,11 +355,6 @@ arc_elf_link_hash_table_create (bfd *abfd)
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+- ret->elf.init_got_refcount.refcount = 0;
|
|
|
+- ret->elf.init_got_refcount.glist = NULL;
|
|
|
+- ret->elf.init_got_offset.offset = 0;
|
|
|
+- ret->elf.init_got_offset.glist = NULL;
|
|
|
+-
|
|
|
+ ret->elf.root.hash_table_free = elf_arc_link_hash_table_free;
|
|
|
+
|
|
|
+ return &ret->elf.root;
|
|
|
+@@ -1615,10 +1613,14 @@ elf_arc_relocate_section (bfd * output_bfd,
|
|
|
+ while (h->root.type == bfd_link_hash_indirect
|
|
|
+ || h->root.type == bfd_link_hash_warning)
|
|
|
+ {
|
|
|
+- struct elf_link_hash_entry *h_old = h;
|
|
|
++ struct elf_arc_link_hash_entry *ah_old =
|
|
|
++ (struct elf_arc_link_hash_entry *) h;
|
|
|
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
+- if (h->got.glist == 0 && h_old->got.glist != h->got.glist)
|
|
|
+- h->got.glist = h_old->got.glist;
|
|
|
++ struct elf_arc_link_hash_entry *ah =
|
|
|
++ (struct elf_arc_link_hash_entry *) h;
|
|
|
++
|
|
|
++ if (ah->got_ents == 0 && ah_old->got_ents != ah->got_ents)
|
|
|
++ ah->got_ents = ah_old->got_ents;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* TODO: Need to validate what was the intention. */
|
|
|
+@@ -1636,6 +1638,8 @@ elf_arc_relocate_section (bfd * output_bfd,
|
|
|
+
|
|
|
+ if (is_reloc_for_GOT (howto) && !bfd_link_pic (info))
|
|
|
+ {
|
|
|
++ struct elf_arc_link_hash_entry *ah =
|
|
|
++ (struct elf_arc_link_hash_entry *) h;
|
|
|
+ /* TODO: Change it to use arc_do_relocation with
|
|
|
+ ARC_32 reloc. Try to use ADD_RELA macro. */
|
|
|
+ bfd_vma relocation =
|
|
|
+@@ -1645,8 +1649,8 @@ elf_arc_relocate_section (bfd * output_bfd,
|
|
|
+ + reloc_data.sym_section->output_section->vma)
|
|
|
+ : 0);
|
|
|
+
|
|
|
+- BFD_ASSERT (h->got.glist);
|
|
|
+- bfd_vma got_offset = h->got.glist->offset;
|
|
|
++ BFD_ASSERT (ah->got_ents);
|
|
|
++ bfd_vma got_offset = ah->got_ents->offset;
|
|
|
+ bfd_put_32 (output_bfd, relocation,
|
|
|
+ htab->sgot->contents + got_offset);
|
|
|
+ }
|
|
|
+@@ -1958,6 +1962,7 @@ elf_arc_check_relocs (bfd * abfd,
|
|
|
+ else /* Global one. */
|
|
|
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
|
|
+
|
|
|
++
|
|
|
+ switch (r_type)
|
|
|
+ {
|
|
|
+ case R_ARC_32:
|
|
|
+@@ -2404,7 +2409,9 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd,
|
|
|
+ create respective dynamic relocs. */
|
|
|
+ /* TODO: Make function to get list and not access the list directly. */
|
|
|
+ /* TODO: Move function to relocate_section create this relocs eagerly. */
|
|
|
+- create_got_dynrelocs_for_got_info (&h->got.glist,
|
|
|
++ struct elf_arc_link_hash_entry *ah =
|
|
|
++ (struct elf_arc_link_hash_entry *) h;
|
|
|
++ create_got_dynrelocs_for_got_info (&ah->got_ents,
|
|
|
+ output_bfd,
|
|
|
+ info,
|
|
|
+ h);
|
|
|
+--
|
|
|
+2.14.4
|
|
|
+
|