som.c reloc sanity checking
authorAlan Modra <amodra@gmail.com>
Wed, 26 Oct 2022 00:58:08 +0000 (11:28 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 26 Oct 2022 05:06:14 +0000 (15:36 +1030)
commitb8d97d38574639d539aa4dfecc2fb5b532c32c5d
tree9e7b8479136d01032fcb4a72af2482b279b204f9
parent2f6ba62ed3825afa0d995e23d5bfe2fd8258bd00
som.c reloc sanity checking

This patch checks that relocations emitted in som_write_fixups have
offsets that are monotonic and within a section.  To do that properly
using bfd_reloc_offset_in_range it is necessary to set the reloc howto
size field, which isn't used otherwise by the som backend.  Note that
the sizes used are not exactly those in the old sizing switch
statement deleted from som_write_fixups, but all relocs handled by the
main switch statement there get the same size.  Most unhandled relocs
get a zero size (exceptions being R_RELOCATION, R_SPACE_REF,
R_MILLI_REL, R_BREAKPOINT which all involve writing one word according
to my SOM reference).  I figure it doesn't matter since any unhandled
reloc is converted to 0xff R_RESERVED, and a default of zero is better
for a "don't know" reloc.

Besides tidying the code, stringizing name from type in SOM_HOWTO
fixes R_REPEATED_INIT name.

* som.c (SOM_HOWTO): Add SIZE arg, delete NAME.  Stringize type
to name.
(som_hppa_howto_table): Update with sizes.
(som_write_fixups): Delete sizing switch statement.  Sanity check
bfd_reloc address against subsection size.
bfd/som.c