{
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 elf_link_hash_table elf;
- /* Small local sym to section mapping cache. */
- struct sym_cache sym_sec;
-
/* TLS Local Dynamic GOT Entry */
union {
bfd_signed_vma refcount;
/* Get the ELF linker hash table from a link_info structure. */
-#define elf32_mb_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == MICROBLAZE_ELF_DATA ? ((struct elf32_mb_link_hash_table *) ((p)->hash)) : NULL)
+#define elf32_mb_hash_table(p) \
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == MICROBLAZE_ELF_DATA) \
+ ? (struct elf32_mb_link_hash_table *) (p)->hash : NULL)
/* Create an entry in a microblaze ELF linker hash table. */
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)
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.
Elf_Internal_Sym *isym;
void *vpp;
- isym = bfd_sym_from_r_symndx (&htab->sym_sec,
+ isym = bfd_sym_from_r_symndx (&htab->elf.sym_cache,
abfd, r_symndx);
if (isym == NULL)
return FALSE;
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;
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);
return FALSE;
}
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in microblaze_elf_finish_dynamic_sections, but we
- must add the entries now so that we get the correct size for
- the .dynamic section. The DT_DEBUG entry is filled in by the
- dynamic linker and used by the debugger. */
-#define add_dynamic_entry(TAG, VAL) \
- _bfd_elf_add_dynamic_entry (info, TAG, VAL)
-
- if (bfd_link_executable (info))
- {
- if (!add_dynamic_entry (DT_DEBUG, 0))
- return FALSE;
- }
-
- if (!add_dynamic_entry (DT_RELA, 0)
- || !add_dynamic_entry (DT_RELASZ, 0)
- || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
- return FALSE;
-
- if (htab->elf.splt->size != 0)
- {
- if (!add_dynamic_entry (DT_PLTGOT, 0)
- || !add_dynamic_entry (DT_PLTRELSZ, 0)
- || !add_dynamic_entry (DT_PLTREL, DT_RELA)
- || !add_dynamic_entry (DT_JMPREL, 0)
- || !add_dynamic_entry (DT_BIND_NOW, 1))
- return FALSE;
- }
-
- if (info->flags & DF_TEXTREL)
- {
- if (!add_dynamic_entry (DT_TEXTREL, 0))
- return FALSE;
- }
- }
-#undef add_dynamic_entry
- return TRUE;
+ /* ??? Force DF_BIND_NOW? */
+ info->flags |= DF_BIND_NOW;
+ return _bfd_elf_add_dynamic_tags (output_bfd, info, TRUE);
}
/* Finish up dynamic symbol handling. We set the contents of various
put into .sbss. */
*secp = bfd_make_section_old_way (abfd, ".sbss");
if (*secp == NULL
- || !bfd_set_section_flags (*secp, SEC_IS_COMMON))
+ || !bfd_set_section_flags (*secp, SEC_IS_COMMON | SEC_SMALL_DATA))
return FALSE;
*valp = sym->st_size;