aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/elf64-s390.c18
-rw-r--r--ld/testsuite/ld-s390/reloccheck-1.d3
-rw-r--r--ld/testsuite/ld-s390/reloccheck-1.s14
3 files changed, 35 insertions, 0 deletions
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index c1ed3d6..fa44971 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -3056,6 +3056,24 @@ elf_s390_relocate_section (bfd *output_bfd,
|| r_type == R_390_PLT24DBL)
rel->r_offset--;
+ /* Issue an error if the right shift implied by the relocation
+ would drop bits from the symbol value. */
+ if (howto->rightshift
+ && (relocation & (((bfd_vma)1 << howto->rightshift) - 1)))
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB(%pA+%#" PRIx64 "): "
+ "misaligned symbol `%s' (%#" PRIx64 ") for relocation %s"),
+ input_bfd,
+ input_section,
+ (uint64_t) rel->r_offset,
+ h->root.root.string,
+ (uint64_t)relocation,
+ howto->name);
+ return false;
+ }
+
if (r_type == R_390_20
|| r_type == R_390_GOT20
|| r_type == R_390_GOTPLT20
diff --git a/ld/testsuite/ld-s390/reloccheck-1.d b/ld/testsuite/ld-s390/reloccheck-1.d
new file mode 100644
index 0000000..4696dcb
--- /dev/null
+++ b/ld/testsuite/ld-s390/reloccheck-1.d
@@ -0,0 +1,3 @@
+#as: -m64 -mzarch -march=z900
+#ld: -m elf64_s390 -e start -static
+#error: .*misaligned symbol.*
diff --git a/ld/testsuite/ld-s390/reloccheck-1.s b/ld/testsuite/ld-s390/reloccheck-1.s
new file mode 100644
index 0000000..6c932bd
--- /dev/null
+++ b/ld/testsuite/ld-s390/reloccheck-1.s
@@ -0,0 +1,14 @@
+ .machinemode zarch
+ .machine "z900"
+.text
+ .align 8
+.globl start
+ .type start, @function
+start:
+ larl %r1, test
+.globl test
+.data
+ .align 4
+ .byte 23
+test:
+ .zero 4