]> code.ossystems Code Review - openembedded-core.git/blob
d41339a9a6645aea91fdfb42baec7bafcda7c42a
[openembedded-core.git] /
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.
5
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.
8
9 bfd/
10 2018-03-01  Cupertino Miranda  <cmiranda@synopsys.com>
11
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.
17
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>
22
23 Upstream-Status: Pending
24 ---
25  bfd/arc-got.h   |  6 +++--
26  bfd/elf32-arc.c | 77 +++++++++++++++++++++++++++++++--------------------------
27  2 files changed, 46 insertions(+), 37 deletions(-)
28
29 diff --git a/bfd/arc-got.h b/bfd/arc-got.h
30 index a86061bcb38..81ce88fe21a 100644
31 --- a/bfd/arc-got.h
32 +++ b/bfd/arc-got.h
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)
36  {
37 -  if (h != NULL)
38 +  struct elf_arc_link_hash_entry *h1 =
39 +    ((struct elf_arc_link_hash_entry *) h);
40 +  if (h1 != NULL)
41      {
42 -      return &h->got.glist;
43 +      return &h1->got_ents;
44      }
45    else
46      {
47 diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
48 index a48ef0ca15f..ab84de43815 100644
49 --- a/bfd/elf32-arc.c
50 +++ b/bfd/elf32-arc.c
51 @@ -160,6 +160,18 @@ struct arc_relocation_data
52    const char *    symbol_name;
53  };
54  
55 +/* ARC ELF linker hash entry.  */
56 +struct elf_arc_link_hash_entry
57 +{
58 +  struct elf_link_hash_entry root;
59 +
60 +  /* Track dynamic relocs copied for this symbol.  */
61 +  struct elf_dyn_relocs *dyn_relocs;
62 +
63 +  struct got_entry *got_ents;
64 +};
65 +
66 +
67  /* Should be included at this location due to static declarations
68     defined before this point.  */
69  #include "arc-got.h"
70 @@ -281,15 +293,6 @@ struct arc_reloc_map
71    unsigned char                    elf_reloc_val;
72  };
73  
74 -/* ARC ELF linker hash entry.  */
75 -struct elf_arc_link_hash_entry
76 -{
77 -  struct elf_link_hash_entry root;
78 -
79 -  /* Track dynamic relocs copied for this symbol.  */
80 -  struct elf_dyn_relocs *dyn_relocs;
81 -};
82 -
83  /* ARC ELF linker hash table.  */
84  struct elf_arc_link_hash_table
85  {
86 @@ -301,28 +304,28 @@ elf_arc_link_hash_newfunc (struct bfd_hash_entry *entry,
87                            struct bfd_hash_table *table,
88                            const char *string)
89  {
90 +  struct elf_arc_link_hash_entry * ret =
91 +    (struct elf_arc_link_hash_entry *) entry;
92 +
93    /* Allocate the structure if it has not already been allocated by a
94       subclass.  */
95 -  if (entry == NULL)
96 -    {
97 -      entry = (struct bfd_hash_entry *)
98 -         bfd_hash_allocate (table,
99 -                            sizeof (struct elf_arc_link_hash_entry));
100 -      if (entry == NULL)
101 -       return entry;
102 -    }
103 +  if (ret == NULL)
104 +    ret = (struct elf_arc_link_hash_entry *)
105 +       bfd_hash_allocate (table, sizeof (struct elf_arc_link_hash_entry));
106 +  if (ret == NULL)
107 +    return (struct bfd_hash_entry *) ret;
108  
109    /* Call the allocation method of the superclass.  */
110 -  entry = _bfd_elf_link_hash_newfunc (entry, table, string);
111 -  if (entry != NULL)
112 +  ret = ((struct elf_arc_link_hash_entry *)
113 +        _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
114 +                                    table, string));
115 +  if (ret != NULL)
116      {
117 -      struct elf_arc_link_hash_entry *eh;
118 -
119 -      eh = (struct elf_arc_link_hash_entry *) entry;
120 -      eh->dyn_relocs = NULL;
121 +      ret->dyn_relocs = NULL;
122 +      ret->got_ents = NULL;
123      }
124  
125 -  return entry;
126 +  return (struct bfd_hash_entry *) ret;
127  }
128  
129  /* Destroy an ARC ELF linker hash table.  */
130 @@ -352,11 +355,6 @@ arc_elf_link_hash_table_create (bfd *abfd)
131        return NULL;
132      }
133  
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;
138 -
139    ret->elf.root.hash_table_free = elf_arc_link_hash_table_free;
140  
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)
145           {
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;
154 +
155 +           if (ah->got_ents == 0 && ah_old->got_ents != ah->got_ents)
156 +             ah->got_ents = ah_old->got_ents;
157           }
158  
159           /* TODO: Need to validate what was the intention.  */
160 @@ -1636,6 +1638,8 @@ elf_arc_relocate_section (bfd *                     output_bfd,
161  
162               if (is_reloc_for_GOT (howto) && !bfd_link_pic (info))
163                 {
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.  */
168                   bfd_vma relocation =
169 @@ -1645,8 +1649,8 @@ elf_arc_relocate_section (bfd *                     output_bfd,
170                          + reloc_data.sym_section->output_section->vma)
171                       : 0);
172  
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);
179                 }
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];
183  
184 +
185        switch (r_type)
186         {
187           case R_ARC_32:
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,
196                                      output_bfd,
197                                      info,
198                                      h);
199 -- 
200 2.14.4
201