aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-microblaze.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf32-microblaze.c')
-rw-r--r--bfd/elf32-microblaze.c75
1 files changed, 31 insertions, 44 deletions
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index 3307a91..f1bea56 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -678,26 +678,6 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
return _bfd_elf_is_local_label_name (abfd, name);
}
-/* The microblaze linker (like many others) needs to keep track of
- the number of relocs that it decides to copy as dynamic relocs in
- check_relocs for each symbol. This is so that it can later discard
- them if they are found to be unnecessary. We store the information
- in a field extending the regular ELF linker hash table. */
-
-struct elf32_mb_dyn_relocs
-{
- struct elf32_mb_dyn_relocs *next;
-
- /* The input section of the reloc. */
- asection *sec;
-
- /* Total number of relocs copied for the input section. */
- bfd_size_type count;
-
- /* Number of pc-relative relocs copied for the input section. */
- bfd_size_type pc_count;
-};
-
/* ELF linker hash entry. */
struct elf32_mb_link_hash_entry
@@ -705,7 +685,7 @@ struct elf32_mb_link_hash_entry
struct elf_link_hash_entry elf;
/* Track dynamic relocs copied for this symbol. */
- struct elf32_mb_dyn_relocs *dyn_relocs;
+ struct elf_dyn_relocs *dyn_relocs;
/* TLS Reference Types for the symbol; Updated by check_relocs */
#define TLS_GD 1 /* GD reloc. */
@@ -2429,8 +2409,8 @@ microblaze_elf_check_relocs (bfd * abfd,
&& (h->root.type == bfd_link_hash_defweak
|| !h->def_regular)))
{
- struct elf32_mb_dyn_relocs *p;
- struct elf32_mb_dyn_relocs **head;
+ struct elf_dyn_relocs *p;
+ struct elf_dyn_relocs **head;
/* When creating a shared object, we must copy these
relocs into the output file. We create a reloc
@@ -2474,14 +2454,14 @@ microblaze_elf_check_relocs (bfd * abfd,
return FALSE;
vpp = &elf_section_data (s)->local_dynrel;
- head = (struct elf32_mb_dyn_relocs **) vpp;
+ head = (struct elf_dyn_relocs **) vpp;
}
p = *head;
if (p == NULL || p->sec != sec)
{
bfd_size_type amt = sizeof *p;
- p = ((struct elf32_mb_dyn_relocs *)
+ p = ((struct elf_dyn_relocs *)
bfd_alloc (htab->elf.dynobj, amt));
if (p == NULL)
return FALSE;
@@ -2520,8 +2500,8 @@ microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info,
{
if (edir->dyn_relocs != NULL)
{
- struct elf32_mb_dyn_relocs **pp;
- struct elf32_mb_dyn_relocs *p;
+ struct elf_dyn_relocs **pp;
+ struct elf_dyn_relocs *p;
if (ind->root.type == bfd_link_hash_indirect)
abort ();
@@ -2530,7 +2510,7 @@ microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info,
list. Merge any entries against the same section. */
for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
{
- struct elf32_mb_dyn_relocs *q;
+ struct elf_dyn_relocs *q;
for (q = edir->dyn_relocs; q != NULL; q = q->next)
if (q->sec == p->sec)
@@ -2555,13 +2535,28 @@ microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info,
_bfd_elf_link_hash_copy_indirect (info, dir, ind);
}
+/* Find dynamic relocs for H that apply to read-only sections. */
+
+static asection *
+readonly_dynrelocs (struct elf_link_hash_entry *h)
+{
+ struct elf_dyn_relocs *p;
+
+ for (p = elf32_mb_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
+ {
+ asection *s = p->sec->output_section;
+
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ return p->sec;
+ }
+ return NULL;
+}
+
static bfd_boolean
microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
struct elf32_mb_link_hash_table *htab;
- struct elf32_mb_link_hash_entry * eh;
- struct elf32_mb_dyn_relocs *p;
asection *s, *srel;
unsigned int power_of_two;
@@ -2633,17 +2628,9 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
return TRUE;
}
- eh = (struct elf32_mb_link_hash_entry *) h;
- for (p = eh->dyn_relocs; p != NULL; p = p->next)
- {
- s = p->sec->output_section;
- if (s != NULL && (s->flags & SEC_READONLY) != 0)
- break;
- }
-
- /* If we didn't find any dynamic relocs in read-only sections, then
+ /* If we don't find any dynamic relocs in read-only sections, then
we'll be keeping the dynamic relocs and avoiding the copy reloc. */
- if (p == NULL)
+ if (!readonly_dynrelocs (h))
{
h->non_got_ref = 0;
return TRUE;
@@ -2710,7 +2697,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
struct bfd_link_info *info;
struct elf32_mb_link_hash_table *htab;
struct elf32_mb_link_hash_entry *eh;
- struct elf32_mb_dyn_relocs *p;
+ struct elf_dyn_relocs *p;
if (h->root.type == bfd_link_hash_indirect)
return TRUE;
@@ -2843,7 +2830,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
&& (h->forced_local
|| info->symbolic))
{
- struct elf32_mb_dyn_relocs **pp;
+ struct elf_dyn_relocs **pp;
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
{
@@ -2935,9 +2922,9 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
for (s = ibfd->sections; s != NULL; s = s->next)
{
- struct elf32_mb_dyn_relocs *p;
+ struct elf_dyn_relocs *p;
- for (p = ((struct elf32_mb_dyn_relocs *)
+ for (p = ((struct elf_dyn_relocs *)
elf_section_data (s)->local_dynrel);
p != NULL;
p = p->next)