/* CRIS-specific support for 32-bit ELF.
- Copyright (C) 2000-2019 Free Software Foundation, Inc.
+ Copyright (C) 2000-2020 Free Software Foundation, Inc.
Contributed by Axis Communications AB.
Written by Hans-Peter Nilsson, based on elf32-fr30.c
PIC and shlib bits based primarily on elf32-m68k.c and elf32-i386.c.
/* Get the CRIS ELF linker hash table from a link_info structure. */
#define elf_cris_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == CRIS_ELF_DATA ? ((struct elf_cris_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == CRIS_ELF_DATA) \
+ ? (struct elf_cris_link_hash_table *) (p)->hash : NULL)
/* Get the CRIS ELF linker hash entry from a regular hash entry (the
"parent class"). The .root reference is just a simple type
elf_cris_link_hash_table_create (bfd *abfd)
{
struct elf_cris_link_hash_table *ret;
- bfd_size_type amt = sizeof (struct elf_cris_link_hash_table);
+ size_t amt = sizeof (struct elf_cris_link_hash_table);
ret = ((struct elf_cris_link_hash_table *) bfd_zmalloc (amt));
if (ret == (struct elf_cris_link_hash_table *) NULL)
/* No need to do anything if we're not creating a shared object. */
if (! bfd_link_pic (info)
- || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
+ || (h != NULL && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)))
break;
/* We may need to create a reloc section in the dynobj and made room
struct elf_cris_link_hash_table * htab;
bfd *dynobj;
asection *s;
- bfd_boolean plt;
bfd_boolean relocs;
htab = elf_cris_hash_table (info);
/* The check_relocs and adjust_dynamic_symbol entry points have
determined the sizes of the various dynamic sections. Allocate
memory for them. */
- plt = FALSE;
relocs = FALSE;
for (s = dynobj->sections; s != NULL; s = s->next)
{
if (strcmp (name, ".plt") == 0)
{
- /* Remember whether there is a PLT. */
- plt = s->size != 0;
+ ;
}
else if (strcmp (name, ".got.plt") == 0)
{
return FALSE;
}
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in elf_cris_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_pic (info))
- {
- if (!add_dynamic_entry (DT_DEBUG, 0))
- return FALSE;
- }
-
- if (plt)
- {
- 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))
- return FALSE;
- }
-
- if (relocs)
- {
- 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 ((info->flags & DF_TEXTREL) != 0)
- {
- if (!add_dynamic_entry (DT_TEXTREL, 0))
- return FALSE;
- info->flags |= DF_TEXTREL;
- }
- }
-#undef add_dynamic_entry
-
- return TRUE;
+ return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs);
}
/* This function is called via elf_cris_link_hash_traverse if we are