/* 32-bit ELF support for S+core.
- Copyright (C) 2006-2016 Free Software Foundation, Inc.
+ Copyright (C) 2006-2017 Free Software Foundation, Inc.
Contributed by
Brain.lin (brain.lin@sunplusct.com)
Mei Ligang (ligang@sunnorth.com.cn)
score3_bfd_getl48 (const void *p)
{
const bfd_byte *addr = p;
- unsigned long long v;
-
- v = (unsigned long long) addr[4];
- v |= (unsigned long long) addr[5] << 8;
- v |= (unsigned long long) addr[2] << 16;
- v |= (unsigned long long) addr[3] << 24;
- v |= (unsigned long long) addr[0] << 32;
- v |= (unsigned long long) addr[1] << 40;
+ bfd_uint64_t v;
+
+ v = (bfd_uint64_t) addr[4];
+ v |= (bfd_uint64_t) addr[5] << 8;
+ v |= (bfd_uint64_t) addr[2] << 16;
+ v |= (bfd_uint64_t) addr[3] << 24;
+ v |= (bfd_uint64_t) addr[0] << 32;
+ v |= (bfd_uint64_t) addr[1] << 40;
return v;
}
/* We have to use an alignment of 2**4 here because this is hardcoded
in the function stub generation and in the linker script. */
s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
- if (s == NULL
+ elf_hash_table (info)->sgot = s;
+ if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 4))
return FALSE;
h->non_elf = 0;
h->def_regular = 1;
h->type = STT_OBJECT;
+ elf_hash_table (info)->hgot = h;
if (bfd_link_pic (info) && ! bfd_elf_link_record_dynamic_symbol (info, h))
return FALSE;
{
(*loc)->gotidx = -1;
/* We didn't allocate enough space in the GOT. */
- (*_bfd_error_handler)
+ _bfd_error_handler
(_("not enough GOT space for local GOT entries"));
bfd_set_error (bfd_error_bad_value);
return NULL;
{
const Elf_Internal_Rela *relend;
const Elf_Internal_Rela *lo16_rel;
- const struct elf_backend_data *bed;
bfd_vma lo_value = 0;
- bed = get_elf_backend_data (output_bfd);
- relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
+ relend = relocs + input_section->reloc_count;
lo16_rel = score_elf_next_relocation (input_bfd, R_SCORE_GOT_LO16, rel, relend);
if ((local_p) && (lo16_rel != NULL))
{
}
else if (!bfd_link_relocatable (info))
{
- if (! ((*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)
- || ELF_ST_VISIBILITY (h->root.other))))
- return bfd_reloc_undefined;
+ (*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)
+ || ELF_ST_VISIBILITY (h->root.other));
relocation = 0;
}
}
/* If the overflowing reloc was to an undefined symbol,
we have already printed one error message and there
is no point complaining again. */
- if (((!h) || (h->root.root.type != bfd_link_hash_undefined))
- && (!((*info->callbacks->reloc_overflow)
- (info, NULL, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset))))
- return FALSE;
+ if (!h || h->root.root.type != bfd_link_hash_undefined)
+ (*info->callbacks->reloc_overflow)
+ (info, NULL, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset);
break;
case bfd_reloc_undefined:
- if (!((*info->callbacks->undefined_symbol)
- (info, name, input_bfd, input_section, rel->r_offset, TRUE)))
- return FALSE;
+ (*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section, rel->r_offset, TRUE);
break;
case bfd_reloc_outofrange:
default:
msg = _("internal error: unknown error");
- /* fall through */
+ /* Fall through. */
common_error:
- if (!((*info->callbacks->warning)
- (info, msg, name, input_bfd, input_section, rel->r_offset)))
- return FALSE;
+ (*info->callbacks->warning) (info, msg, name, input_bfd,
+ input_section, rel->r_offset);
break;
}
}
asection *sec,
const Elf_Internal_Rela *relocs)
{
- const char *name;
bfd *dynobj;
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes;
const Elf_Internal_Rela *rel_end;
asection *sgot;
asection *sreloc;
- const struct elf_backend_data *bed;
if (bfd_link_relocatable (info))
return TRUE;
sym_hashes = elf_sym_hashes (abfd);
extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
- name = bfd_get_section_name (abfd, sec);
-
if (dynobj == NULL)
{
sgot = NULL;
}
sreloc = NULL;
- bed = get_elf_backend_data (abfd);
- rel_end = relocs + sec->reloc_count * bed->s->int_rels_per_ext_rel;
+ rel_end = relocs + sec->reloc_count;
for (rel = relocs; rel < rel_end; ++rel)
{
unsigned long r_symndx;
}
else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
{
- (*_bfd_error_handler) (_("%s: Malformed reloc detected for section %s"), abfd, name);
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%B: Malformed reloc detected for section %A"), abfd, sec);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
/* PR15323, ref flags aren't set for references in the
same object. */
- h->root.non_ir_ref = 1;
+ h->root.non_ir_ref_regular = 1;
}
}
case R_SCORE_CALL15:
if (h == NULL)
{
- (*_bfd_error_handler)
- (_("%B: CALL15 reloc at 0x%lx not against global symbol"),
- abfd, (unsigned long) rel->r_offset);
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%B: CALL15 reloc at %#Lx not against global symbol"),
+ abfd, rel->r_offset);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
/* Make sure we know what is going on here. */
BFD_ASSERT (dynobj != NULL
&& (h->needs_plt
- || h->u.weakdef != NULL
+ || h->is_weakalias
|| (h->def_dynamic && h->ref_regular && !h->def_regular)));
/* If this symbol is defined in a dynamic object, we need to copy
/* If this is a weak symbol, and there is a real definition, the
processor independent code will have arranged for us to see the
real definition first, and we can just use the same value. */
- if (h->u.weakdef != NULL)
+ if (h->is_weakalias)
{
- BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
- || h->u.weakdef->root.type == bfd_link_hash_defweak);
- h->root.u.def.section = h->u.weakdef->root.u.def.section;
- h->root.u.def.value = h->u.weakdef->root.u.def.value;
+ struct elf_link_hash_entry *def = weakdef (h);
+ BFD_ASSERT (def->root.type == bfd_link_hash_defined);
+ h->root.u.def.section = def->root.u.def.section;
+ h->root.u.def.value = def->root.u.def.value;
return TRUE;
}
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (!bfd_link_pic (info) && !info->nointerp)
+ if (bfd_link_executable (info) && !info->nointerp)
{
s = bfd_get_linker_section (dynobj, ".interp");
BFD_ASSERT (s != NULL);
break;
case DT_PLTGOT:
- name = ".got";
- s = bfd_get_linker_section (dynobj, name);
+ s = elf_hash_table (info)->sgot;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
}
/* In case if we don't have global got symbols we default
to setting DT_SCORE_GOTSYM to the same value as
- DT_SCORE_SYMTABNO, so we just fall through. */
+ DT_SCORE_SYMTABNO. */
+ /* Fall through. */
case DT_SCORE_SYMTABNO:
name = ".dynsym";
}
static bfd_boolean
-s3_elf32_score_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+s3_elf32_score_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
{
+ bfd *obfd = info->output_bfd;
flagword in_flags;
flagword out_flags;
- if (!_bfd_generic_verify_endian_match (ibfd, obfd))
+ if (!_bfd_generic_verify_endian_match (ibfd, info))
return FALSE;
in_flags = elf_elfheader (ibfd)->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
+ (_("%B: warning: linking PIC files with non-PIC files"), ibfd);
/* FIXME: Maybe dependency fix compatibility should be checked here. */
}
static bfd_boolean
-elf32_score_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+elf32_score_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
{
- if (bfd_get_mach (obfd) == bfd_mach_score3)
- return s3_elf32_score_merge_private_bfd_data (ibfd, obfd);
+ if (bfd_get_mach (info->output_bfd) == bfd_mach_score3)
+ return s3_elf32_score_merge_private_bfd_data (ibfd, info);
else
- return s7_elf32_score_merge_private_bfd_data (ibfd, obfd);
+ return s7_elf32_score_merge_private_bfd_data (ibfd, info);
}
static bfd_boolean