z8 and z80 coff_reloc16_extra_cases sanity checks

* reloc16.c (bfd_coff_reloc16_get_relocated_section_contents):
	Use size_t variables.  Sanity check reloc address.  Handle
	errors from bfd_coff_reloc16_extra_cases.
	* coffcode.h (_bfd_coff_reloc16_extra_cases): Return bool, take
	size_t* args.
	(dummy_reloc16_extra_cases): Adjust to suit.  Don't abort.
	* coff-z80.c (extra_case): Sanity check reloc address.  Return
	errors.  Tidy formatting.  Use bfd_signed_vma temp var to
	check for reloc overflow.  Don't abort on unexpected reloc type,
	instead print an error and return false.
	* coff-z8k.c (extra_case): Likewise.
	* libcoff.h: Regenerate.
This commit is contained in:
Alan Modra
2023-03-07 22:21:28 +10:30
parent b9ee26d9ca
commit d64c8f7181
5 changed files with 179 additions and 129 deletions

View File

@@ -1495,9 +1495,9 @@ Special entry points for gdb to swap in coff symbol table parts:
. (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
. combined_entry_type *, unsigned int);
.
. void (*_bfd_coff_reloc16_extra_cases)
. bool (*_bfd_coff_reloc16_extra_cases)
. (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
. bfd_byte *, unsigned int *, unsigned int *);
. bfd_byte *, size_t *, size_t *);
.
. int (*_bfd_coff_reloc16_estimate)
. (bfd *, asection *, arelent *, unsigned int,
@@ -5331,18 +5331,16 @@ dummy_reloc16_estimate (bfd *abfd ATTRIBUTE_UNUSED,
#define coff_reloc16_extra_cases dummy_reloc16_extra_cases
/* This works even if abort is not declared in any header file. */
static void
static bool
dummy_reloc16_extra_cases (bfd *abfd ATTRIBUTE_UNUSED,
struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
struct bfd_link_order *link_order ATTRIBUTE_UNUSED,
arelent *reloc ATTRIBUTE_UNUSED,
bfd_byte *data ATTRIBUTE_UNUSED,
unsigned int *src_ptr ATTRIBUTE_UNUSED,
unsigned int *dst_ptr ATTRIBUTE_UNUSED)
size_t *src_ptr ATTRIBUTE_UNUSED,
size_t *dst_ptr ATTRIBUTE_UNUSED)
{
abort ();
return false;
}
#endif