/* BFD back-end for Renesas Super-H COFF binaries.
- Copyright (C) 1993-2018 Free Software Foundation, Inc.
+ Copyright (C) 1993-2020 Free Software Foundation, Inc.
Contributed by Cygnus Support.
Written by Steve Chamberlain, <sac@cygnus.com>.
Relaxing code written by Ian Lance Taylor, <ian@cygnus.com>.
#define coff_bfd_reloc_name_lookup sh_coff_reloc_name_lookup
static reloc_howto_type *
-sh_coff_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+sh_coff_reloc_type_lookup (bfd *abfd,
bfd_reloc_code_real_type code)
{
unsigned int i;
if (sh_reloc_map[i].bfd_reloc_val == code)
return &sh_coff_howtos[(int) sh_reloc_map[i].shcoff_reloc_val];
- _bfd_error_handler (_("SH Error: unknown reloc type %d"), code);
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+ abfd, (unsigned int) code);
return NULL;
}
bfd * output_bfd,
char ** error_message ATTRIBUTE_UNUSED)
{
- unsigned long insn;
+ bfd_vma insn;
bfd_vma sym_value;
unsigned short r_type;
bfd_vma addr = reloc_entry->address;
#endif
insn = bfd_get_32 (abfd, hit_data);
insn += sym_value + reloc_entry->addend;
- bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
+ bfd_put_32 (abfd, insn, hit_data);
break;
#ifdef COFF_WITH_PE
case R_SH_IMAGEBASE:
insn = bfd_get_32 (abfd, hit_data);
insn += sym_value + reloc_entry->addend;
insn -= pe_data (input_section->output_section->owner)->pe_opthdr.ImageBase;
- bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
+ bfd_put_32 (abfd, insn, hit_data);
break;
#endif
case R_SH_PCDISP:
+ input_section->output_offset
+ addr
+ 4);
- sym_value += (insn & 0xfff) << 1;
- if (insn & 0x800)
- sym_value -= 0x1000;
- insn = (insn & 0xf000) | (sym_value & 0xfff);
- bfd_put_16 (abfd, (bfd_vma) insn, hit_data);
- if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000)
+ sym_value += (((insn & 0xfff) ^ 0x800) - 0x800) << 1;
+ insn = (insn & 0xf000) | ((sym_value >> 1) & 0xfff);
+ bfd_put_16 (abfd, insn, hit_data);
+ if (sym_value + 0x1000 >= 0x2000 || (sym_value & 1) != 0)
return bfd_reloc_overflow;
break;
default:
if (laddr >= sec->size)
{
/* xgettext: c-format */
- _bfd_error_handler (_("%B: %#Lx: warning: bad R_SH_USES offset"),
- abfd, irel->r_vaddr);
+ _bfd_error_handler
+ (_("%pB: %#" PRIx64 ": warning: bad R_SH_USES offset"),
+ abfd, (uint64_t) irel->r_vaddr);
continue;
}
insn = bfd_get_16 (abfd, contents + laddr);
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: %#Lx: warning: R_SH_USES points to unrecognized insn %#x"),
- abfd, irel->r_vaddr, insn);
+ (_("%pB: %#" PRIx64 ": warning: R_SH_USES points to unrecognized insn %#x"),
+ abfd, (uint64_t) irel->r_vaddr, insn);
continue;
}
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: %#Lx: warning: bad R_SH_USES load offset"),
- abfd, irel->r_vaddr);
+ (_("%pB: %#" PRIx64 ": warning: bad R_SH_USES load offset"),
+ abfd, (uint64_t) irel->r_vaddr);
continue;
}
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: %#Lx: warning: could not find expected reloc"),
- abfd, paddr);
+ (_("%pB: %#" PRIx64 ": warning: could not find expected reloc"),
+ abfd, (uint64_t) paddr);
continue;
}
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: %#Lx: warning: symbol in unexpected section"),
- abfd, paddr);
+ (_("%pB: %#" PRIx64 ": warning: symbol in unexpected section"),
+ abfd, (uint64_t) paddr);
continue;
}
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: %#Lx: warning: could not find expected COUNT reloc"),
- abfd, paddr);
+ (_("%pB: %#" PRIx64 ": warning: could not find expected COUNT reloc"),
+ abfd, (uint64_t) paddr);
continue;
}
if (irelcount->r_offset == 0)
{
/* xgettext: c-format */
- _bfd_error_handler (_("%B: %#Lx: warning: bad count"),
- abfd, paddr);
+ _bfd_error_handler (_("%pB: %#" PRIx64 ": warning: bad count"),
+ abfd, (uint64_t) paddr);
continue;
}
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: %#Lx: fatal: reloc overflow while relaxing"),
- abfd, irel->r_vaddr);
+ (_("%pB: %#" PRIx64 ": fatal: reloc overflow while relaxing"),
+ abfd, (uint64_t) irel->r_vaddr);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
|| obj_raw_syments (abfd) != NULL)
{
_bfd_error_handler
- (_("%B: fatal: generic symbols retrieved before relaxing"), abfd);
+ (_("%pB: fatal: generic symbols retrieved before relaxing"), abfd);
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: %#Lx: fatal: reloc overflow while relaxing"),
- abfd, irel->r_vaddr);
+ (_("%pB: %#" PRIx64 ": fatal: reloc overflow while relaxing"),
+ abfd, (uint64_t) irel->r_vaddr);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: illegal symbol index %ld in relocs"),
+ (_("%pB: illegal symbol index %ld in relocs"),
input_bfd, symndx);
bfd_set_error (bfd_error_bad_value);
return FALSE;