/* 32-bit ELF support for S+core.
- Copyright (C) 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2009-2021 Free Software Foundation, Inc.
Contributed by
together, and then referenced via the gp pointer, which yields
faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */
-static asection score_elf_scom_section;
-static asymbol score_elf_scom_symbol;
-static asymbol * score_elf_scom_symbol_ptr;
+static asection score_elf_scom_section;
+static const asymbol score_elf_scom_symbol =
+ GLOBAL_SYM_INIT (".scommon", &score_elf_scom_section);
+static asection score_elf_scom_section =
+ BFD_FAKE_SECTION (score_elf_scom_section, &score_elf_scom_symbol,
+ ".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
static bfd_reloc_status_type
score_elf_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
bfd *output_bfd, char **error_message)
{
if ((symbol->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (symbol))
- || bfd_is_com_section (bfd_get_section (symbol)))
+ || bfd_is_und_section (bfd_asymbol_section (symbol))
+ || bfd_is_com_section (bfd_asymbol_section (symbol)))
/* The relocation is against a global symbol. */
return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
input_section, output_bfd,
| SEC_LINKER_CREATED
| SEC_READONLY));
if (sreloc == NULL
- || ! bfd_set_section_alignment (dynobj, sreloc,
- SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
+ || !bfd_set_section_alignment (sreloc,
+ SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
return NULL;
}
return sreloc;
struct elf_link_hash_entry *h;
struct bfd_link_hash_entry *bh;
struct score_got_info *g;
- bfd_size_type amt;
+ size_t amt;
/* This function may be called more than once. */
s = score_elf_got_section (abfd, TRUE);
s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
elf_hash_table (info)->sgot = s;
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, 4))
+ || !bfd_set_section_alignment (s, 4))
return FALSE;
/* Define the symbol _GLOBAL_OFFSET_TABLE_. We don't do this in the
/* Score backend functions. */
-void
+bfd_boolean
s7_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc)
r_type = ELF32_R_TYPE (elf_reloc->r_info);
if (r_type >= ARRAY_SIZE (elf32_score_howto_table))
- bfd_reloc->howto = NULL;
- else
- bfd_reloc->howto = &elf32_score_howto_table[r_type];
+ return FALSE;
+
+ bfd_reloc->howto = &elf32_score_howto_table[r_type];
+ return TRUE;
}
/* Relocate an score ELF section. */
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
- s7_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel);
+ if (! s7_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel))
+ continue;
howto = bfd_reloc.howto;
h = NULL;
}
else if (!bfd_link_relocatable (info))
{
- (*info->callbacks->undefined_symbol)
- (info, h->root.root.root.string, input_bfd,
- input_section, rel->r_offset,
- (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
+ info->callbacks->undefined_symbol
+ (info, h->root.root.root.string, input_bfd, input_section,
+ rel->r_offset,
+ (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
|| ELF_ST_VISIBILITY (h->root.other));
- relocation = 0;
+ relocation = 0;
}
}
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: Malformed reloc detected for section %A"), abfd, sec);
+ (_("%pB: malformed reloc detected for section %pA"), abfd, sec);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: CALL15 reloc at %#Lx not against global symbol"),
- abfd, rel->r_offset);
+ (_("%pB: CALL15 reloc at %#" PRIx64 " not against global symbol"),
+ abfd, (uint64_t) rel->r_offset);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
/* Fall through. */
case SHN_SCORE_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;
break;
}
break;
/* Fall through. */
case SHN_SCORE_SCOMMON:
- if (score_elf_scom_section.name == NULL)
- {
- /* Initialize the small common section. */
- score_elf_scom_section.name = ".scommon";
- score_elf_scom_section.flags = SEC_IS_COMMON;
- score_elf_scom_section.output_section = &score_elf_scom_section;
- score_elf_scom_section.symbol = &score_elf_scom_symbol;
- score_elf_scom_section.symbol_ptr_ptr = &score_elf_scom_symbol_ptr;
- score_elf_scom_symbol.name = ".scommon";
- score_elf_scom_symbol.flags = BSF_SECTION_SYM;
- score_elf_scom_symbol.section = &score_elf_scom_section;
- score_elf_scom_symbol_ptr = &score_elf_scom_symbol;
- }
asym->section = &score_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size;
break;
asection *sec,
int *retval)
{
- if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
+ if (strcmp (bfd_section_name (sec), ".scommon") == 0)
{
*retval = SHN_SCORE_SCOMMON;
return TRUE;
/* 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 (CONST_STRNEQ (name, ".rel"))
{
the linker now does not create empty output sections. */
if (s->output_section != NULL
&& strcmp (name,
- bfd_get_section_name (s->output_section->owner,
- s->output_section)) == 0)
+ bfd_section_name (s->output_section)) == 0)
s->flags |= SEC_EXCLUDE;
}
else
assert a DT_TEXTREL entry rather than testing whether
there exists a relocation to a read only section or
not. */
- outname = bfd_get_section_name (output_bfd, s->output_section);
+ outname = bfd_section_name (s->output_section);
target = bfd_get_section_by_name (output_bfd, outname + 4);
if ((target != NULL
&& (target->flags & SEC_READONLY) != 0
s = bfd_get_linker_section (abfd, ".dynamic");
if (s != NULL)
{
- if (!bfd_set_section_flags (abfd, s, flags))
+ if (!bfd_set_section_flags (s, flags))
return FALSE;
}
s = bfd_make_section_anyway_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
flags | SEC_CODE);
if (s == NULL
- || !bfd_set_section_alignment (abfd, s, 2))
+ || !bfd_set_section_alignment (s, 2))
return FALSE;
}
{
const char *name;
- name = bfd_get_section_name (abfd, sec);
+ name = bfd_section_name (sec);
if (strcmp (name, ".got") == 0
|| strcmp (name, ".srdata") == 0
{
if (hdr->bfd_section != NULL)
{
- const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
+ const char *name = bfd_section_name (hdr->bfd_section);
if (strcmp (name, ".sdata") == 0)
{
if (!_bfd_generic_verify_endian_match (ibfd, info))
return FALSE;
+ /* FIXME: What should be checked when linking shared libraries? */
+ if ((ibfd->flags & DYNAMIC) != 0)
+ return TRUE;
+
in_flags = elf_elfheader (ibfd)->e_flags;
out_flags = elf_elfheader (obfd)->e_flags;
if (((in_flags & EF_SCORE_PIC) != 0) != ((out_flags & EF_SCORE_PIC) != 0))
{
- _bfd_error_handler (_("%B: warning: linking PIC files with non-PIC files"), ibfd);
+ _bfd_error_handler (_("%pB: warning: linking PIC files with non-PIC files"), ibfd);
}
/* Maybe dependency fix compatibility should be checked here. */
s7_elf32_score_new_section_hook (bfd *abfd, asection *sec)
{
struct _score_elf_section_data *sdata;
- bfd_size_type amt = sizeof (*sdata);
+ size_t amt = sizeof (*sdata);
sdata = bfd_zalloc (abfd, amt);
if (sdata == NULL)
return _bfd_elf_new_section_hook (abfd, sec);
}
-#define elf_backend_omit_section_dynsym \
- ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true_any)
+#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all