/* Xilinx MicroBlaze-specific support for 32-bit ELF
- Copyright (C) 2009-2019 Free Software Foundation, Inc.
+ Copyright (C) 2009-2020 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
{
struct elf_link_hash_entry elf;
- /* Track dynamic relocs copied for this symbol. */
- struct elf_dyn_relocs *dyn_relocs;
-
/* TLS Reference Types for the symbol; Updated by check_relocs */
#define TLS_GD 1 /* GD reloc. */
#define TLS_LD 2 /* LD reloc. */
struct elf32_mb_link_hash_entry *eh;
eh = (struct elf32_mb_link_hash_entry *) entry;
- eh->dyn_relocs = NULL;
eh->tls_mask = 0;
}
microblaze_elf_link_hash_table_create (bfd *abfd)
{
struct elf32_mb_link_hash_table *ret;
- bfd_size_type amt = sizeof (struct elf32_mb_link_hash_table);
+ size_t amt = sizeof (struct elf32_mb_link_hash_table);
ret = (struct elf32_mb_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
/* Only relocate if the symbol is defined. */
if (sec)
{
- name = bfd_get_section_name (sec->owner, sec);
+ name = bfd_section_name (sec);
if (strcmp (name, ".sdata2") == 0
|| strcmp (name, ".sbss2") == 0)
/* Only relocate if the symbol is defined. */
if (sec)
{
- name = bfd_get_section_name (sec->owner, sec);
+ name = bfd_section_name (sec);
if (strcmp (name, ".sdata") == 0
|| strcmp (name, ".sbss") == 0)
name = (bfd_elf_string_from_elf_section
(input_bfd, symtab_hdr->sh_link, sym->st_name));
if (name == NULL || *name == '\0')
- name = bfd_section_name (input_bfd, sec);
+ name = bfd_section_name (sec);
}
if (errmsg != NULL)
symtab_hdr->contents = (bfd_byte *) isymbuf;
}
- if (free_relocs != NULL)
- {
- free (free_relocs);
- free_relocs = NULL;
- }
+ free (free_relocs);
+ free_relocs = NULL;
if (free_contents != NULL)
{
return TRUE;
error_return:
- if (free_relocs != NULL)
- free (free_relocs);
- if (free_contents != NULL)
- free (free_contents);
- if (sec->relax != NULL)
- {
- free (sec->relax);
- sec->relax = NULL;
- sec->relax_count = 0;
- }
+ free (free_relocs);
+ free (free_contents);
+ free (sec->relax);
+ sec->relax = NULL;
+ sec->relax_count = 0;
return FALSE;
}
/* If this is a global symbol, we count the number of
relocations we need for this symbol. */
if (h != NULL)
- head = &((struct elf32_mb_link_hash_entry *) h)->dyn_relocs;
+ head = &h->dyn_relocs;
else
{
/* Track dynamic relocs needed for local syms too.
p = *head;
if (p == NULL || p->sec != sec)
{
- bfd_size_type amt = sizeof *p;
+ size_t amt = sizeof *p;
p = ((struct elf_dyn_relocs *)
bfd_alloc (htab->elf.dynobj, amt));
if (p == NULL)
edir = (struct elf32_mb_link_hash_entry *) dir;
eind = (struct elf32_mb_link_hash_entry *) ind;
- if (eind->dyn_relocs != NULL)
- {
- if (edir->dyn_relocs != NULL)
- {
- struct elf_dyn_relocs **pp;
- struct elf_dyn_relocs *p;
-
- if (ind->root.type == bfd_link_hash_indirect)
- abort ();
-
- /* Add reloc counts against the weak sym to the strong sym
- list. Merge any entries against the same section. */
- for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
- {
- struct elf_dyn_relocs *q;
-
- for (q = edir->dyn_relocs; q != NULL; q = q->next)
- if (q->sec == p->sec)
- {
- q->pc_count += p->pc_count;
- q->count += p->count;
- *pp = p->next;
- break;
- }
- if (q == NULL)
- pp = &p->next;
- }
- *pp = edir->dyn_relocs;
- }
-
- edir->dyn_relocs = eind->dyn_relocs;
- eind->dyn_relocs = NULL;
- }
-
edir->tls_mask |= eind->tls_mask;
_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)
/* 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 (!readonly_dynrelocs (h))
+ if (!_bfd_elf_readonly_dynrelocs (h))
{
h->non_got_ref = 0;
return TRUE;
s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
if (power_of_two > s->alignment_power)
{
- if (!bfd_set_section_alignment (s->owner, s, power_of_two))
+ if (!bfd_set_section_alignment (s, power_of_two))
return FALSE;
}
else
h->got.offset = (bfd_vma) -1;
- if (eh->dyn_relocs == NULL)
+ if (h->dyn_relocs == NULL)
return TRUE;
/* In the shared -Bsymbolic case, discard space allocated for
{
struct elf_dyn_relocs **pp;
- for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+ for (pp = &h->dyn_relocs; (p = *pp) != NULL; )
{
p->count -= p->pc_count;
p->pc_count = 0;
}
}
else if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
- eh->dyn_relocs = NULL;
+ h->dyn_relocs = NULL;
}
else
{
goto keep;
}
- eh->dyn_relocs = NULL;
+ h->dyn_relocs = NULL;
keep: ;
}
/* Finally, allocate space. */
- for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ for (p = h->dyn_relocs; p != NULL; p = p->next)
{
asection *sreloc = elf_section_data (p->sec)->sreloc;
sreloc->size += p->count * sizeof (Elf32_External_Rela);
/* It's OK to base decisions on the section name, because none
of the dynobj section names depend upon the input files. */
- name = bfd_get_section_name (dynobj, s);
+ name = bfd_section_name (s);
if (strncmp (name, ".rela", 5) == 0)
{
memset (splt->contents, 0, PLT_ENTRY_SIZE);
bfd_put_32 (output_bfd, (bfd_vma) 0x80000000 /* nop. */,
splt->contents + splt->size - 4);
- }
- elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+ if (splt->output_section != bfd_abs_section_ptr)
+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+ }
}
/* Set the first entry in the global offset table to the address of
put into .sbss. */
*secp = bfd_make_section_old_way (abfd, ".sbss");
if (*secp == NULL
- || ! bfd_set_section_flags (abfd, *secp, SEC_IS_COMMON))
+ || !bfd_set_section_flags (*secp, SEC_IS_COMMON))
return FALSE;
*valp = sym->st_size;