/* ft32-specific support for 32-bit ELF.
- Copyright (C) 2013-2017 Free Software Foundation, Inc.
+ Copyright (C) 2013-2019 Free Software Foundation, Inc.
Copied from elf32-moxie.c which is..
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
4, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
- "R_FT32_SC0", /* name */
+ "R_FT32_SC0", /* name */
FALSE, /* partial_inplace */
0x00000000, /* src_mask */
0x00000000, /* dst_mask */
7, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
- "R_FT32_SC1", /* name */
+ "R_FT32_SC1", /* name */
TRUE, /* partial_inplace */
0x07ffff80, /* src_mask */
0x07ffff80, /* dst_mask */
0x00000000, /* src_mask */
0x00007fff, /* dst_mask */
FALSE), /* pcrel_offset */
- HOWTO (R_FT32_DIFF32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (R_FT32_DIFF32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
bfd_elf_ft32_diff_reloc, /* special_function */
- "R_FT32_DIFF32", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffff, /* dst_mask */
- FALSE), /* pcrel_offset */
+ "R_FT32_DIFF32", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
};
\f
\f
static const struct ft32_reloc_map ft32_reloc_map [] =
{
- { BFD_RELOC_NONE, R_FT32_NONE },
- { BFD_RELOC_32, R_FT32_32 },
- { BFD_RELOC_16, R_FT32_16 },
- { BFD_RELOC_8, R_FT32_8 },
- { BFD_RELOC_FT32_10, R_FT32_10 },
- { BFD_RELOC_FT32_20, R_FT32_20 },
- { BFD_RELOC_FT32_17, R_FT32_17 },
- { BFD_RELOC_FT32_18, R_FT32_18 },
- { BFD_RELOC_FT32_RELAX, R_FT32_RELAX },
- { BFD_RELOC_FT32_SC0, R_FT32_SC0 },
- { BFD_RELOC_FT32_SC1, R_FT32_SC1 },
- { BFD_RELOC_FT32_15, R_FT32_15 },
- { BFD_RELOC_FT32_DIFF32, R_FT32_DIFF32 },
+ { BFD_RELOC_NONE, R_FT32_NONE },
+ { BFD_RELOC_32, R_FT32_32 },
+ { BFD_RELOC_16, R_FT32_16 },
+ { BFD_RELOC_8, R_FT32_8 },
+ { BFD_RELOC_FT32_10, R_FT32_10 },
+ { BFD_RELOC_FT32_20, R_FT32_20 },
+ { BFD_RELOC_FT32_17, R_FT32_17 },
+ { BFD_RELOC_FT32_18, R_FT32_18 },
+ { BFD_RELOC_FT32_RELAX, R_FT32_RELAX },
+ { BFD_RELOC_FT32_SC0, R_FT32_SC0 },
+ { BFD_RELOC_FT32_SC1, R_FT32_SC1 },
+ { BFD_RELOC_FT32_15, R_FT32_15 },
+ { BFD_RELOC_FT32_DIFF32, R_FT32_DIFF32 },
};
/* Perform a diff relocation. Nothing to do, as the difference value is
/* Set the howto pointer for an FT32 ELF reloc. */
-static void
-ft32_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+ft32_info_to_howto_rela (bfd *abfd,
arelent *cache_ptr,
Elf_Internal_Rela *dst)
{
unsigned int r_type;
r_type = ELF32_R_TYPE (dst->r_info);
- BFD_ASSERT (r_type < (unsigned int) R_FT32_max);
+ if (r_type >= (unsigned int) R_FT32_max)
+ {
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+ abfd, r_type);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+
cache_ptr->howto = & ft32_elf_howto_table [r_type];
+ return cache_ptr->howto != NULL;
}
/* Relocate an FT32 ELF section.
name = bfd_elf_string_from_elf_section
(input_bfd, symtab_hdr->sh_link, sym->st_name);
- name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+ name = name == NULL ? bfd_section_name (sec) : name;
}
else
{
static bfd_boolean
ft32_reloc_shortable
- (bfd * abfd,
- asection * sec,
- Elf_Internal_Sym * isymbuf ATTRIBUTE_UNUSED,
- bfd_byte * contents,
- bfd_vma pc ATTRIBUTE_UNUSED,
+ (bfd * abfd,
+ asection * sec,
+ Elf_Internal_Sym * isymbuf ATTRIBUTE_UNUSED,
+ bfd_byte * contents,
+ bfd_vma pc ATTRIBUTE_UNUSED,
Elf_Internal_Rela * irel,
- unsigned int * sc)
+ unsigned int * sc)
{
Elf_Internal_Shdr *symtab_hdr ATTRIBUTE_UNUSED;
bfd_vma symval;
if (elf32_ft32_is_diff_reloc (irel))
{
if (!elf32_ft32_adjust_diff_reloc_value (abfd, isec, irel,
- symval,
- shrinked_insn_address,
- count))
- return FALSE;
+ symval,
+ shrinked_insn_address,
+ count))
+ return FALSE;
}
else
{
printf
("Relocation's addend needed to be fixed \n");
- if (!elf32_ft32_adjust_reloc_if_spans_insn (abfd, isec,
- irel, symval,
- shrinked_insn_address,
- shrink_boundary,
- count))
- return FALSE;
+ if (!elf32_ft32_adjust_reloc_if_spans_insn (abfd, isec,
+ irel, symval,
+ shrinked_insn_address,
+ shrink_boundary,
+ count))
+ return FALSE;
}
}
/* else reference symbol is absolute. No adjustment needed. */
struct elf_link_hash_entry *sym_hash = *sym_hashes;
/* The '--wrap SYMBOL' option is causing a pain when the object file,
- containing the definition of __wrap_SYMBOL, includes a direct
- call to SYMBOL as well. Since both __wrap_SYMBOL and SYMBOL reference
- the same symbol (which is __wrap_SYMBOL), but still exist as two
- different symbols in 'sym_hashes', we don't want to adjust
- the global symbol __wrap_SYMBOL twice.
- This check is only relevant when symbols are being wrapped. */
+ containing the definition of __wrap_SYMBOL, includes a direct
+ call to SYMBOL as well. Since both __wrap_SYMBOL and SYMBOL reference
+ the same symbol (which is __wrap_SYMBOL), but still exist as two
+ different symbols in 'sym_hashes', we don't want to adjust
+ the global symbol __wrap_SYMBOL twice.
+ This check is only relevant when symbols are being wrapped. */
if (link_info->wrap_hash != NULL)
{
struct elf_link_hash_entry **cur_sym_hashes;
if (sym_sec == sec)
{
symval += sym_sec->output_section->vma
- + sym_sec->output_offset;
+ + sym_sec->output_offset;
if (debug_relax)
printf ("0x%x: Address of anchor symbol: 0x%x "
static bfd_boolean
ft32_elf_relax_section
- (bfd * abfd,
- asection * sec,
+ (bfd * abfd,
+ asection * sec,
struct bfd_link_info * link_info,
- bfd_boolean * again)
+ bfd_boolean * again)
{
Elf_Internal_Rela * free_relocs = NULL;
Elf_Internal_Rela * internal_relocs;
Elf_Internal_Rela * irelend;
Elf_Internal_Rela * irel;
- bfd_byte * contents = NULL;
+ bfd_byte * contents = NULL;
Elf_Internal_Shdr * symtab_hdr;
Elf_Internal_Sym * isymbuf = NULL;
if (ELF32_R_TYPE (irel->r_info) == R_FT32_18)
{
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
- R_FT32_SC0);
+ R_FT32_SC0);
}
else
{
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
- R_FT32_NONE);
+ R_FT32_NONE);
}
if (ELF32_R_TYPE (irel_next->r_info) == R_FT32_18)