From 4863cddb5079ce34007c5bebc0315b8eddb9ef6d Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 13 May 2021 10:11:20 +0930 Subject: [PATCH] PR27858, global-buffer-overflow PR 27858 * elf32-sh.c (sh_elf_info_to_howto): Correct check for last valid reloc howto. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-sh.c | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 0e4ccd8d0a0..fcb692bdb35 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2021-05-13 Alan Modra + + PR 27858 + * elf32-sh.c (sh_elf_info_to_howto): Correct check for last valid + reloc howto. + 2021-05-12 Luis Machado * elf-bfd.h (elfcore_write_aarch_mte): New prototype. diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index dae248f50e6..fe2ffc9cb19 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -426,13 +426,12 @@ sh_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) r = ELF32_R_TYPE (dst->r_info); - if (r >= R_SH_max + if (r >= R_SH_FIRST_INVALID_RELOC_6 || (r >= R_SH_FIRST_INVALID_RELOC && r <= R_SH_LAST_INVALID_RELOC) || (r >= R_SH_FIRST_INVALID_RELOC_2 && r <= R_SH_LAST_INVALID_RELOC_2) || (r >= R_SH_FIRST_INVALID_RELOC_3 && r <= R_SH_LAST_INVALID_RELOC_3) || (r >= R_SH_FIRST_INVALID_RELOC_4 && r <= R_SH_LAST_INVALID_RELOC_4) - || (r >= R_SH_FIRST_INVALID_RELOC_5 && r <= R_SH_LAST_INVALID_RELOC_5) - || (r >= R_SH_FIRST_INVALID_RELOC_6 && r <= R_SH_LAST_INVALID_RELOC_6)) + || (r >= R_SH_FIRST_INVALID_RELOC_5 && r <= R_SH_LAST_INVALID_RELOC_5)) { /* xgettext:c-format */ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), -- 2.30.2