/* 32-bit ELF support for TI C6X
- Copyright (C) 2010-2020 Free Software Foundation, Inc.
+ Copyright (C) 2010-2021 Free Software Foundation, Inc.
Contributed by Joseph Myers <joseph@codesourcery.com>
Bernd Schmidt <bernds@codesourcery.com>
/* C6X specific command line arguments. */
struct elf32_tic6x_params params;
- /* Small local sym cache. */
- struct sym_cache sym_cache;
-
/* The output BFD, for convenience. */
bfd *obfd;
faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */
static asection tic6x_elf_scom_section;
-static asymbol tic6x_elf_scom_symbol;
-static asymbol *tic6x_elf_scom_symbol_ptr;
+static const asymbol tic6x_elf_scom_symbol =
+ GLOBAL_SYM_INIT (".scommon", &tic6x_elf_scom_section);
+static asection tic6x_elf_scom_section =
+ BFD_FAKE_SECTION (tic6x_elf_scom_section, &tic6x_elf_scom_symbol,
+ ".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
static reloc_howto_type elf32_tic6x_howto_table[] =
{
if (r_symndx < symtab_hdr->sh_info)
{
/* A local symbol. */
- isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+ isym = bfd_sym_from_r_symndx (&htab->elf.sym_cache,
abfd, r_symndx);
if (isym == NULL)
return FALSE;
{
case SHN_TIC6X_SCOMMON:
*secp = bfd_make_section_old_way (abfd, ".scommon");
- (*secp)->flags |= SEC_IS_COMMON;
+ (*secp)->flags |= SEC_IS_COMMON | SEC_SMALL_DATA;
*valp = sym->st_size;
bfd_set_section_alignment (*secp, bfd_log2 (sym->st_value));
break;
switch (elfsym->internal_elf_sym.st_shndx)
{
case SHN_TIC6X_SCOMMON:
- if (tic6x_elf_scom_section.name == NULL)
- {
- /* Initialize the small common section. */
- tic6x_elf_scom_section.name = ".scommon";
- tic6x_elf_scom_section.flags = SEC_IS_COMMON;
- tic6x_elf_scom_section.output_section = &tic6x_elf_scom_section;
- tic6x_elf_scom_section.symbol = &tic6x_elf_scom_symbol;
- tic6x_elf_scom_section.symbol_ptr_ptr = &tic6x_elf_scom_symbol_ptr;
- tic6x_elf_scom_symbol.name = ".scommon";
- tic6x_elf_scom_symbol.flags = BSF_SECTION_SYM;
- tic6x_elf_scom_symbol.section = &tic6x_elf_scom_section;
- tic6x_elf_scom_symbol_ptr = &tic6x_elf_scom_symbol;
- }
asym->section = &tic6x_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size;
break;
return TRUE;
}
-/* Set DF_TEXTREL if we find any dynamic relocs that apply to
- read-only sections. */
-
-static bfd_boolean
-maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p)
-{
- asection *sec;
-
- if (h->root.type == bfd_link_hash_indirect)
- return TRUE;
-
- sec = _bfd_elf_readonly_dynrelocs (h);
- if (sec != NULL)
- {
- struct bfd_link_info *info = (struct bfd_link_info *) info_p;
-
- info->flags |= DF_TEXTREL;
- info->callbacks->minfo
- (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"),
- sec->owner, h->root.root.string, sec);
-
- /* Not an error, just cut short the traversal. */
- return FALSE;
- }
- return TRUE;
-}
-
/* Set the sizes of the dynamic sections. */
static bfd_boolean
#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 (!_bfd_elf_add_dynamic_tags (output_bfd, info, relocs))
+ return FALSE;
if (!add_dynamic_entry (DT_C6000_DSBT_BASE, 0)
|| !add_dynamic_entry (DT_C6000_DSBT_SIZE, htab->params.dsbt_size)
htab->params.dsbt_index))
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))
- 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 any dynamic relocs apply to a read-only section,
- then we need a DT_TEXTREL entry. */
- if ((info->flags & DF_TEXTREL) == 0)
- elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info);
-
- if ((info->flags & DF_TEXTREL) != 0)
- {
- if (!add_dynamic_entry (DT_TEXTREL, 0))
- return FALSE;
- }
- }
}
#undef add_dynamic_entry
return TRUE;
}
+#define elf32_bed elf32_tic6x_bed
+
#define TARGET_LITTLE_SYM tic6x_elf32_le_vec
#define TARGET_LITTLE_NAME "elf32-tic6x-le"
#define TARGET_BIG_SYM tic6x_elf32_be_vec