aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-s390.c
diff options
context:
space:
mode:
authorAndreas Krebbel <krebbel@linux.ibm.com>2024-02-27 15:24:06 +0100
committerAndreas Krebbel <krebbel@linux.ibm.com>2024-02-27 15:24:14 +0100
commitf1c4160786e08cf0ec4c89c5c0466deab0855ab8 (patch)
tree89997b22c132eb778fc3a9485481fe7a9a3905a2 /bfd/elf64-s390.c
parent5998b4a287772756e33d311a570df080a4f6e051 (diff)
downloadbinutils-f1c4160786e08cf0ec4c89c5c0466deab0855ab8.zip
binutils-f1c4160786e08cf0ec4c89c5c0466deab0855ab8.tar.gz
binutils-f1c4160786e08cf0ec4c89c5c0466deab0855ab8.tar.bz2
s390: Add r_offset check to the weak undef change
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.
Diffstat (limited to 'bfd/elf64-s390.c')
-rw-r--r--bfd/elf64-s390.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 74ac018..beaf3e9 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -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;