This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_28-branch] S/390: Issue error for overflowing relocs.
- From: Andreas Krebbel <krebbel at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 23 Feb 2017 17:37:09 -0000
- Subject: [binutils-gdb/binutils-2_28-branch] S/390: Issue error for overflowing relocs.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=844be12fa6bf90850d71c8210d0bad9b07c5f422
commit 844be12fa6bf90850d71c8210d0bad9b07c5f422
Author: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
Date: Thu Jan 5 19:53:14 2017 +0100
S/390: Issue error for overflowing relocs.
Building PIE executable from non-PIC code results in broken binaries.
With this patch the problem is detected at link-time.
bfd/ChangeLog:
2017-01-07 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* elf64-s390.c (elf_s390_relocate_section): Issue error for
non-PLT relocs of shared libary symbol in exectuable.
Diff:
---
bfd/elf64-s390.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index bbfcd2e..edc9b86 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -2701,6 +2701,18 @@ elf_s390_relocate_section (bfd *output_bfd,
case R_390_PC32:
case R_390_PC32DBL:
case R_390_PC64:
+ if (h != NULL
+ && bfd_link_pie (info)
+ && !h->def_regular)
+ {
+ _bfd_error_handler (_("%B: `%s' non-PLT reloc for symbol defined "
+ "in shared library and accessed "
+ "from executable "
+ "(rebuild file with -fPIC ?)"),
+ input_bfd, h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
/* The target of these relocs are instruction operands
residing in read-only sections. We cannot emit a runtime
reloc for it. */