diff options
author | Alan Modra <amodra@gmail.com> | 2022-10-26 11:28:08 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-10-26 15:36:14 +1030 |
commit | b8d97d38574639d539aa4dfecc2fb5b532c32c5d (patch) | |
tree | 9e7b8479136d01032fcb4a72af2482b279b204f9 /bfd/som.c | |
parent | 2f6ba62ed3825afa0d995e23d5bfe2fd8258bd00 (diff) | |
download | fsf-binutils-gdb-b8d97d38574639d539aa4dfecc2fb5b532c32c5d.zip fsf-binutils-gdb-b8d97d38574639d539aa4dfecc2fb5b532c32c5d.tar.gz fsf-binutils-gdb-b8d97d38574639d539aa4dfecc2fb5b532c32c5d.tar.bz2 |
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.
Diffstat (limited to 'bfd/som.c')
-rw-r--r-- | bfd/som.c | 582 |
1 files changed, 287 insertions, 295 deletions
@@ -635,267 +635,268 @@ static const int comp3_opcodes[] = #define R_SHORT_PCREL_MODE 0x3e #endif -#define SOM_HOWTO(TYPE, NAME) \ - HOWTO(TYPE, 0, 0, 32, false, 0, 0, hppa_som_reloc, NAME, false, 0, 0, false) +#define SOM_HOWTO(SIZE, TYPE) \ + HOWTO(TYPE, 0, SIZE, 32, false, 0, 0, hppa_som_reloc, \ + #TYPE, false, 0, 0, false) static reloc_howto_type som_hppa_howto_table[] = { - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), - SOM_HOWTO (R_ZEROES, "R_ZEROES"), - SOM_HOWTO (R_ZEROES, "R_ZEROES"), - SOM_HOWTO (R_UNINIT, "R_UNINIT"), - SOM_HOWTO (R_UNINIT, "R_UNINIT"), - SOM_HOWTO (R_RELOCATION, "R_RELOCATION"), - SOM_HOWTO (R_DATA_ONE_SYMBOL, "R_DATA_ONE_SYMBOL"), - SOM_HOWTO (R_DATA_ONE_SYMBOL, "R_DATA_ONE_SYMBOL"), - SOM_HOWTO (R_DATA_PLABEL, "R_DATA_PLABEL"), - SOM_HOWTO (R_DATA_PLABEL, "R_DATA_PLABEL"), - SOM_HOWTO (R_SPACE_REF, "R_SPACE_REF"), - SOM_HOWTO (R_REPEATED_INIT, "REPEATED_INIT"), - SOM_HOWTO (R_REPEATED_INIT, "REPEATED_INIT"), - SOM_HOWTO (R_REPEATED_INIT, "REPEATED_INIT"), - SOM_HOWTO (R_REPEATED_INIT, "REPEATED_INIT"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_PCREL_CALL, "R_PCREL_CALL"), - SOM_HOWTO (R_SHORT_PCREL_MODE, "R_SHORT_PCREL_MODE"), - SOM_HOWTO (R_LONG_PCREL_MODE, "R_LONG_PCREL_MODE"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_ABS_CALL, "R_ABS_CALL"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"), - SOM_HOWTO (R_DATA_GPREL, "R_DATA_GPREL"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_DLT_REL, "R_DLT_REL"), - SOM_HOWTO (R_DLT_REL, "R_DLT_REL"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_CODE_ONE_SYMBOL, "R_CODE_ONE_SYMBOL"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_MILLI_REL, "R_MILLI_REL"), - SOM_HOWTO (R_MILLI_REL, "R_MILLI_REL"), - SOM_HOWTO (R_CODE_PLABEL, "R_CODE_PLABEL"), - SOM_HOWTO (R_CODE_PLABEL, "R_CODE_PLABEL"), - SOM_HOWTO (R_BREAKPOINT, "R_BREAKPOINT"), - SOM_HOWTO (R_ENTRY, "R_ENTRY"), - SOM_HOWTO (R_ENTRY, "R_ENTRY"), - SOM_HOWTO (R_ALT_ENTRY, "R_ALT_ENTRY"), - SOM_HOWTO (R_EXIT, "R_EXIT"), - SOM_HOWTO (R_BEGIN_TRY, "R_BEGIN_TRY"), - SOM_HOWTO (R_END_TRY, "R_END_TRY"), - SOM_HOWTO (R_END_TRY, "R_END_TRY"), - SOM_HOWTO (R_END_TRY, "R_END_TRY"), - SOM_HOWTO (R_BEGIN_BRTAB, "R_BEGIN_BRTAB"), - SOM_HOWTO (R_END_BRTAB, "R_END_BRTAB"), - SOM_HOWTO (R_STATEMENT, "R_STATEMENT"), - SOM_HOWTO (R_STATEMENT, "R_STATEMENT"), - SOM_HOWTO (R_STATEMENT, "R_STATEMENT"), - SOM_HOWTO (R_DATA_EXPR, "R_DATA_EXPR"), - SOM_HOWTO (R_CODE_EXPR, "R_CODE_EXPR"), - SOM_HOWTO (R_FSEL, "R_FSEL"), - SOM_HOWTO (R_LSEL, "R_LSEL"), - SOM_HOWTO (R_RSEL, "R_RSEL"), - SOM_HOWTO (R_N_MODE, "R_N_MODE"), - SOM_HOWTO (R_S_MODE, "R_S_MODE"), - SOM_HOWTO (R_D_MODE, "R_D_MODE"), - SOM_HOWTO (R_R_MODE, "R_R_MODE"), - SOM_HOWTO (R_DATA_OVERRIDE, "R_DATA_OVERRIDE"), - SOM_HOWTO (R_DATA_OVERRIDE, "R_DATA_OVERRIDE"), - SOM_HOWTO (R_DATA_OVERRIDE, "R_DATA_OVERRIDE"), - SOM_HOWTO (R_DATA_OVERRIDE, "R_DATA_OVERRIDE"), - SOM_HOWTO (R_DATA_OVERRIDE, "R_DATA_OVERRIDE"), - SOM_HOWTO (R_TRANSLATED, "R_TRANSLATED"), - SOM_HOWTO (R_AUX_UNWIND, "R_AUX_UNWIND"), - SOM_HOWTO (R_COMP1, "R_COMP1"), - SOM_HOWTO (R_COMP2, "R_COMP2"), - SOM_HOWTO (R_COMP3, "R_COMP3"), - SOM_HOWTO (R_PREV_FIXUP, "R_PREV_FIXUP"), - SOM_HOWTO (R_PREV_FIXUP, "R_PREV_FIXUP"), - SOM_HOWTO (R_PREV_FIXUP, "R_PREV_FIXUP"), - SOM_HOWTO (R_PREV_FIXUP, "R_PREV_FIXUP"), - SOM_HOWTO (R_SEC_STMT, "R_SEC_STMT"), - SOM_HOWTO (R_N0SEL, "R_N0SEL"), - SOM_HOWTO (R_N1SEL, "R_N1SEL"), - SOM_HOWTO (R_LINETAB, "R_LINETAB"), - SOM_HOWTO (R_LINETAB_ESC, "R_LINETAB_ESC"), - SOM_HOWTO (R_LTP_OVERRIDE, "R_LTP_OVERRIDE"), - SOM_HOWTO (R_COMMENT, "R_COMMENT"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED"), - SOM_HOWTO (R_RESERVED, "R_RESERVED") + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_NO_RELOCATION), + SOM_HOWTO (0, R_ZEROES), + SOM_HOWTO (0, R_ZEROES), + SOM_HOWTO (0, R_UNINIT), + SOM_HOWTO (0, R_UNINIT), + SOM_HOWTO (4, R_RELOCATION), + SOM_HOWTO (4, R_DATA_ONE_SYMBOL), + SOM_HOWTO (4, R_DATA_ONE_SYMBOL), + SOM_HOWTO (4, R_DATA_PLABEL), + SOM_HOWTO (4, R_DATA_PLABEL), + SOM_HOWTO (4, R_SPACE_REF), + SOM_HOWTO (0, R_REPEATED_INIT), + SOM_HOWTO (0, R_REPEATED_INIT), + SOM_HOWTO (0, R_REPEATED_INIT), + SOM_HOWTO (0, R_REPEATED_INIT), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (4, R_PCREL_CALL), + SOM_HOWTO (0, R_SHORT_PCREL_MODE), + SOM_HOWTO (0, R_LONG_PCREL_MODE), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (4, R_ABS_CALL), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DP_RELATIVE), + SOM_HOWTO (4, R_DATA_GPREL), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (4, R_DLT_REL), + SOM_HOWTO (4, R_DLT_REL), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (4, R_CODE_ONE_SYMBOL), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (4, R_MILLI_REL), + SOM_HOWTO (4, R_MILLI_REL), + SOM_HOWTO (4, R_CODE_PLABEL), + SOM_HOWTO (4, R_CODE_PLABEL), + SOM_HOWTO (4, R_BREAKPOINT), + SOM_HOWTO (0, R_ENTRY), + SOM_HOWTO (0, R_ENTRY), + SOM_HOWTO (0, R_ALT_ENTRY), + SOM_HOWTO (0, R_EXIT), + SOM_HOWTO (0, R_BEGIN_TRY), + SOM_HOWTO (0, R_END_TRY), + SOM_HOWTO (0, R_END_TRY), + SOM_HOWTO (0, R_END_TRY), + SOM_HOWTO (0, R_BEGIN_BRTAB), + SOM_HOWTO (0, R_END_BRTAB), + SOM_HOWTO (0, R_STATEMENT), + SOM_HOWTO (0, R_STATEMENT), + SOM_HOWTO (0, R_STATEMENT), + SOM_HOWTO (4, R_DATA_EXPR), + SOM_HOWTO (4, R_CODE_EXPR), + SOM_HOWTO (0, R_FSEL), + SOM_HOWTO (0, R_LSEL), + SOM_HOWTO (0, R_RSEL), + SOM_HOWTO (0, R_N_MODE), + SOM_HOWTO (0, R_S_MODE), + SOM_HOWTO (0, R_D_MODE), + SOM_HOWTO (0, R_R_MODE), + SOM_HOWTO (0, R_DATA_OVERRIDE), + SOM_HOWTO (0, R_DATA_OVERRIDE), + SOM_HOWTO (0, R_DATA_OVERRIDE), + SOM_HOWTO (0, R_DATA_OVERRIDE), + SOM_HOWTO (0, R_DATA_OVERRIDE), + SOM_HOWTO (0, R_TRANSLATED), + SOM_HOWTO (0, R_AUX_UNWIND), + SOM_HOWTO (0, R_COMP1), + SOM_HOWTO (0, R_COMP2), + SOM_HOWTO (0, R_COMP3), + SOM_HOWTO (0, R_PREV_FIXUP), + SOM_HOWTO (0, R_PREV_FIXUP), + SOM_HOWTO (0, R_PREV_FIXUP), + SOM_HOWTO (0, R_PREV_FIXUP), + SOM_HOWTO (0, R_SEC_STMT), + SOM_HOWTO (0, R_N0SEL), + SOM_HOWTO (0, R_N1SEL), + SOM_HOWTO (0, R_LINETAB), + SOM_HOWTO (0, R_LINETAB_ESC), + SOM_HOWTO (0, R_LTP_OVERRIDE), + SOM_HOWTO (0, R_COMMENT), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED), + SOM_HOWTO (0, R_RESERVED) }; /* Initialize the SOM relocation queue. By definition the queue holds @@ -2943,7 +2944,7 @@ som_write_fixups (bfd *abfd, subsection != NULL; subsection = subsection->next) { - int reloc_offset; + unsigned int reloc_offset; unsigned int current_rounding_mode; #ifndef NO_PCREL_MODES unsigned int current_call_mode; @@ -2994,6 +2995,31 @@ som_write_fixups (bfd *abfd, unsigned int skip; int sym_num; + if (bfd_reloc->address < reloc_offset) + { + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB(%pA+%#" PRIx64 "): " + "%s relocation offset out of order"), + abfd, subsection, (uint64_t) bfd_reloc->address, + bfd_reloc->howto->name); + bfd_set_error (bfd_error_bad_value); + return false; + } + if (!bfd_reloc_offset_in_range (bfd_reloc->howto, + abfd, subsection, + bfd_reloc->address)) + { + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB(%pA+%#" PRIx64 "): " + "%s relocation offset out of range"), + abfd, subsection, (uint64_t) bfd_reloc->address, + bfd_reloc->howto->name); + bfd_set_error (bfd_error_bad_value); + return false; + } + /* Get the symbol number. Remember it's stored in a special place for section symbols. */ if ((*bfd_reloc->sym_ptr_ptr)->flags & BSF_SECTION_SYM) @@ -3026,42 +3052,8 @@ som_write_fixups (bfd *abfd, p = som_reloc_skip (abfd, skip, p, &subspace_reloc_size, reloc_queue); - /* Update reloc_offset for the next iteration. - - Many relocations do not consume input bytes. They - are markers, or set state necessary to perform some - later relocation. */ - switch (bfd_reloc->howto->type) - { - case R_ENTRY: - case R_ALT_ENTRY: - case R_EXIT: - case R_N_MODE: - case R_S_MODE: - case R_D_MODE: - case R_R_MODE: - case R_FSEL: - case R_LSEL: - case R_RSEL: - case R_COMP1: - case R_COMP2: - case R_BEGIN_BRTAB: - case R_END_BRTAB: - case R_BEGIN_TRY: - case R_END_TRY: - case R_N0SEL: - case R_N1SEL: -#ifndef NO_PCREL_MODES - case R_SHORT_PCREL_MODE: - case R_LONG_PCREL_MODE: -#endif - reloc_offset = bfd_reloc->address; - break; - - default: - reloc_offset = bfd_reloc->address + 4; - break; - } + /* Update reloc_offset for the next iteration. */ + reloc_offset = bfd_reloc->address + bfd_reloc->howto->size; /* Now the actual relocation we care about. */ switch (bfd_reloc->howto->type) |