1 From d930affa2d475d1cc6792f1e6d56bef3d6c617db Mon Sep 17 00:00:00 2001
2 From: Cupertino Miranda <cmiranda@synopsys.com>
3 Date: Fri, 2 Mar 2018 17:16:21 +0100
4 Subject: [PATCH] Refactored location where GOT information is collected.
6 Change location where GOT information is collected for ARC target, avoiding
7 posible use conflicts of the previous .got field in the symbols hash_entry.
10 2018-03-01 Cupertino Miranda <cmiranda@synopsys.com>
12 * arc-got.h (get_got_entry_list_for_symbol): Changed.
13 * ef32-arc.c (struct elf_arc_link_hash_entry): Moved and changed.
14 (elf_arc_link_hash_newfunc): Changed.
15 (arc_elf_link_hash_table_create): Removed old initializations.
16 (elf_arc_relocate_section, elf_arc_finish_dynamic_symbol): Changed.
18 Signed-off-by: Cupertino Miranda <cmiranda@synopsys.com>
19 Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
20 [Romain: rebase on top of 2.31]
21 Signed-off-by: Romain Naour <romain.naour@gmail.com>
23 Upstream-Status: Pending
25 bfd/arc-got.h | 6 +++--
26 bfd/elf32-arc.c | 77 +++++++++++++++++++++++++++++++--------------------------
27 2 files changed, 46 insertions(+), 37 deletions(-)
29 diff --git a/bfd/arc-got.h b/bfd/arc-got.h
30 index a86061bcb38..81ce88fe21a 100644
33 @@ -156,9 +156,11 @@ get_got_entry_list_for_symbol (bfd *abfd,
34 unsigned long r_symndx,
35 struct elf_link_hash_entry *h)
38 + struct elf_arc_link_hash_entry *h1 =
39 + ((struct elf_arc_link_hash_entry *) h);
42 - return &h->got.glist;
43 + return &h1->got_ents;
47 diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
48 index a48ef0ca15f..ab84de43815 100644
51 @@ -160,6 +160,18 @@ struct arc_relocation_data
52 const char * symbol_name;
55 +/* ARC ELF linker hash entry. */
56 +struct elf_arc_link_hash_entry
58 + struct elf_link_hash_entry root;
60 + /* Track dynamic relocs copied for this symbol. */
61 + struct elf_dyn_relocs *dyn_relocs;
63 + struct got_entry *got_ents;
67 /* Should be included at this location due to static declarations
68 defined before this point. */
70 @@ -281,15 +293,6 @@ struct arc_reloc_map
71 unsigned char elf_reloc_val;
74 -/* ARC ELF linker hash entry. */
75 -struct elf_arc_link_hash_entry
77 - struct elf_link_hash_entry root;
79 - /* Track dynamic relocs copied for this symbol. */
80 - struct elf_dyn_relocs *dyn_relocs;
83 /* ARC ELF linker hash table. */
84 struct elf_arc_link_hash_table
86 @@ -301,28 +304,28 @@ elf_arc_link_hash_newfunc (struct bfd_hash_entry *entry,
87 struct bfd_hash_table *table,
90 + struct elf_arc_link_hash_entry * ret =
91 + (struct elf_arc_link_hash_entry *) entry;
93 /* Allocate the structure if it has not already been allocated by a
97 - entry = (struct bfd_hash_entry *)
98 - bfd_hash_allocate (table,
99 - sizeof (struct elf_arc_link_hash_entry));
104 + ret = (struct elf_arc_link_hash_entry *)
105 + bfd_hash_allocate (table, sizeof (struct elf_arc_link_hash_entry));
107 + return (struct bfd_hash_entry *) ret;
109 /* Call the allocation method of the superclass. */
110 - entry = _bfd_elf_link_hash_newfunc (entry, table, string);
112 + ret = ((struct elf_arc_link_hash_entry *)
113 + _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
117 - struct elf_arc_link_hash_entry *eh;
119 - eh = (struct elf_arc_link_hash_entry *) entry;
120 - eh->dyn_relocs = NULL;
121 + ret->dyn_relocs = NULL;
122 + ret->got_ents = NULL;
126 + return (struct bfd_hash_entry *) ret;
129 /* Destroy an ARC ELF linker hash table. */
130 @@ -352,11 +355,6 @@ arc_elf_link_hash_table_create (bfd *abfd)
134 - ret->elf.init_got_refcount.refcount = 0;
135 - ret->elf.init_got_refcount.glist = NULL;
136 - ret->elf.init_got_offset.offset = 0;
137 - ret->elf.init_got_offset.glist = NULL;
139 ret->elf.root.hash_table_free = elf_arc_link_hash_table_free;
141 return &ret->elf.root;
142 @@ -1615,10 +1613,14 @@ elf_arc_relocate_section (bfd * output_bfd,
143 while (h->root.type == bfd_link_hash_indirect
144 || h->root.type == bfd_link_hash_warning)
146 - struct elf_link_hash_entry *h_old = h;
147 + struct elf_arc_link_hash_entry *ah_old =
148 + (struct elf_arc_link_hash_entry *) h;
149 h = (struct elf_link_hash_entry *) h->root.u.i.link;
150 - if (h->got.glist == 0 && h_old->got.glist != h->got.glist)
151 - h->got.glist = h_old->got.glist;
152 + struct elf_arc_link_hash_entry *ah =
153 + (struct elf_arc_link_hash_entry *) h;
155 + if (ah->got_ents == 0 && ah_old->got_ents != ah->got_ents)
156 + ah->got_ents = ah_old->got_ents;
159 /* TODO: Need to validate what was the intention. */
160 @@ -1636,6 +1638,8 @@ elf_arc_relocate_section (bfd * output_bfd,
162 if (is_reloc_for_GOT (howto) && !bfd_link_pic (info))
164 + struct elf_arc_link_hash_entry *ah =
165 + (struct elf_arc_link_hash_entry *) h;
166 /* TODO: Change it to use arc_do_relocation with
167 ARC_32 reloc. Try to use ADD_RELA macro. */
169 @@ -1645,8 +1649,8 @@ elf_arc_relocate_section (bfd * output_bfd,
170 + reloc_data.sym_section->output_section->vma)
173 - BFD_ASSERT (h->got.glist);
174 - bfd_vma got_offset = h->got.glist->offset;
175 + BFD_ASSERT (ah->got_ents);
176 + bfd_vma got_offset = ah->got_ents->offset;
177 bfd_put_32 (output_bfd, relocation,
178 htab->sgot->contents + got_offset);
180 @@ -1958,6 +1962,7 @@ elf_arc_check_relocs (bfd * abfd,
181 else /* Global one. */
182 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
188 @@ -2404,7 +2409,9 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd,
189 create respective dynamic relocs. */
190 /* TODO: Make function to get list and not access the list directly. */
191 /* TODO: Move function to relocate_section create this relocs eagerly. */
192 - create_got_dynrelocs_for_got_info (&h->got.glist,
193 + struct elf_arc_link_hash_entry *ah =
194 + (struct elf_arc_link_hash_entry *) h;
195 + create_got_dynrelocs_for_got_info (&ah->got_ents,