/* FRV-specific support for 32-bit ELF.
- Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ Copyright (C) 2002-2020 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
#include "elf/frv.h"
#include "dwarf2.h"
#include "hashtab.h"
+#include "libiberty.h"
/* Forward declarations. */
/* Set the howto pointer for an FRV ELF reloc. */
-static void
+static bfd_boolean
frv_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
arelent *cache_ptr,
Elf_Internal_Rela *dst)
break;
default:
- if (r_type >= (unsigned int) R_FRV_max)
+ if (r_type >= ARRAY_SIZE (elf32_frv_howto_table))
{
/* xgettext:c-format */
- _bfd_error_handler (_("%B: invalid FRV reloc number: %d"), abfd, r_type);
- r_type = 0;
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+ abfd, r_type);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
}
cache_ptr->howto = & elf32_frv_howto_table [r_type];
break;
}
+ return TRUE;
}
/* Set the howto pointer for an FRV ELF REL reloc. */
-static void
+
+static bfd_boolean
frvfdpic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
arelent *cache_ptr, Elf_Internal_Rela *dst)
{
default:
cache_ptr->howto = NULL;
- break;
+ return FALSE;
}
+ return TRUE;
}
\f
/* Perform a single relocation. By default we use the standard BFD
name = bfd_elf_string_from_elf_section
(input_bfd, symtab_hdr->sh_link, sym->st_name);
if (name == NULL || name[0] == 0)
- name = bfd_section_name (input_bfd, sec);
+ name = bfd_section_name (sec);
}
else
{
if (addend)
{
info->callbacks->einfo
- (_("%H: R_FRV_FUNCDESC references dynamic symbol"
+ (_("%H: %s references dynamic symbol"
" with nonzero addend\n"),
- input_bfd, input_section, rel->r_offset);
+ input_bfd, input_section, rel->r_offset,
+ "R_FRV_FUNCDESC");
return FALSE;
}
dynindx = h->dynindx;
&& (!h || FRVFDPIC_FUNCDESC_LOCAL (info, h)))
{
addend += frvfdpic_got_section (info)->output_section->vma;
- if ((bfd_get_section_flags (output_bfd,
- input_section->output_section)
+ if ((bfd_section_flags (input_section->output_section)
& (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
{
bfd_vma offset;
picrel);
}
}
- else if ((bfd_get_section_flags (output_bfd,
- input_section->output_section)
+ else if ((bfd_section_flags (input_section->output_section)
& (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
{
bfd_vma offset;
if (addend && r_type == R_FRV_FUNCDESC_VALUE)
{
info->callbacks->einfo
- (_("%H: R_FRV_FUNCDESC_VALUE"
- " references dynamic symbol with nonzero addend\n"),
- input_bfd, input_section, rel->r_offset);
+ (_("%H: %s references dynamic symbol"
+ " with nonzero addend\n"),
+ input_bfd, input_section, rel->r_offset,
+ "R_FRV_FUNCDESC_VALUE");
return FALSE;
}
dynindx = h->dynindx;
if (osec)
addend += osec->output_section->vma;
if (IS_FDPIC (input_bfd)
- && (bfd_get_section_flags (output_bfd,
- input_section->output_section)
+ && (bfd_section_flags (input_section->output_section)
& (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
{
if (_frvfdpic_osec_readonly_p (output_bfd,
}
else
{
- if ((bfd_get_section_flags (output_bfd,
- input_section->output_section)
+ if ((bfd_section_flags (input_section->output_section)
& (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
{
bfd_vma offset;
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, ptralign))
+ || !bfd_set_section_alignment (s, ptralign))
return FALSE;
if (bed->want_got_sym)
(flags | SEC_READONLY));
elf_hash_table (info)->srelgot = s;
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, 2))
+ || !bfd_set_section_alignment (s, 2))
return FALSE;
/* Machine-specific. */
s = bfd_make_section_anyway_with_flags (abfd, ".rofixup",
(flags | SEC_READONLY));
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, 2))
+ || !bfd_set_section_alignment (s, 2))
return FALSE;
frvfdpic_gotfixup_section (info) = s;
s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+ || !bfd_set_section_alignment (s, bed->plt_alignment))
return FALSE;
/* FRV-specific: remember it. */
frvfdpic_plt_section (info) = s;
s = bfd_make_section_anyway_with_flags (abfd, ".rel.plt",
flags | SEC_READONLY);
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+ || !bfd_set_section_alignment (s, bed->s->log_file_align))
return FALSE;
/* FRV-specific: remember it. */
frvfdpic_pltrel_section (info) = s;
? ".rela.bss" : ".rel.bss"),
flags | SEC_READONLY);
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+ || !bfd_set_section_alignment (s, bed->s->log_file_align))
return FALSE;
}
}
case R_FRV_FUNCDESC_VALUE:
picrel->relocsfdv++;
- if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
+ if (bfd_section_flags (sec) & SEC_ALLOC)
picrel->relocs32--;
/* Fall through. */
break;
picrel->sym = 1;
- if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
+ if (bfd_section_flags (sec) & SEC_ALLOC)
picrel->relocs32++;
break;
/* This relocation describes which C++ vtable entries are actually
used. Record for later use during GC. */
case R_FRV_GNU_VTENTRY:
- BFD_ASSERT (h != NULL);
- if (h != NULL
- && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
return FALSE;
break;
default:
bad_reloc:
- info->callbacks->einfo
- /* xgettext:c-format */
- (_("%B: unsupported relocation type %i\n"),
- abfd, ELF32_R_TYPE (rel->r_info));
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+ abfd, (unsigned int) ELF32_R_TYPE (rel->r_info));
return FALSE;
}
}
error = TRUE;
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: compiled with %s and linked with modules"
+ (_("%pB: compiled with %s and linked with modules"
" that use non-pic relocations"),
ibfd, (new_flags & EF_FRV_BIGPIC) ? "-fPIC" : "-fpic");
#endif
error = TRUE;
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: compiled with %s and linked with modules compiled with %s"),
+ (_("%pB: compiled with %s and linked with modules compiled with %s"),
ibfd, new_opt, old_opt);
}
error = TRUE;
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: uses different unknown e_flags (%#x) fields"
+ (_("%pB: uses different unknown e_flags (%#x) fields"
" than previous modules (%#x)"),
ibfd, new_partial, old_partial);
}
error = TRUE;
if (IS_FDPIC (obfd))
_bfd_error_handler
- (_("%B: cannot link non-fdpic object file into fdpic executable"),
+ (_("%pB: cannot link non-fdpic object file into fdpic executable"),
ibfd);
else
_bfd_error_handler
- (_("%B: cannot link fdpic object file into non-fdpic executable"),
+ (_("%pB: cannot link fdpic object file into non-fdpic executable"),
ibfd);
}