]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
s390: Add r_offset check to the weak undef change
authorAndreas Krebbel <krebbel@linux.ibm.com>
Tue, 27 Feb 2024 14:24:06 +0000 (15:24 +0100)
committerAndreas Krebbel <krebbel@linux.ibm.com>
Tue, 27 Feb 2024 14:24:14 +0000 (15:24 +0100)
Since we are accessing up to 2 bytes before the relocation target we
should better make sure there are actually 2 bytes before it.

ChangeLog:

* bfd/elf64-s390.c (elf_s390_relocate_section): Make sure
rel->r_offset is large enough.

bfd/elf64-s390.c

index 74ac0180bf8eb526240a9760b5e87637b72978e5..beaf3e907436e5a02a2024f948a9b0b4d0300e0a 100644 (file)
@@ -2486,7 +2486,8 @@ elf_s390_relocate_section (bfd *output_bfd,
              && !h->root.linker_def
              && (bfd_link_executable (info)
                  || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
-             && r_type == R_390_PC32DBL)
+             && r_type == R_390_PC32DBL
+             && rel->r_offset >= 2)
            {
              void *insn_start = contents + rel->r_offset - 2;
              uint16_t op = bfd_get_16 (input_bfd, insn_start) & 0xff0f;