S/390: Issue error for overflowing relocs.
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Thu, 5 Jan 2017 18:53:14 +0000 (19:53 +0100)
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Sat, 7 Jan 2017 21:03:07 +0000 (22:03 +0100)
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.

bfd/elf64-s390.c

index bbfcd2e68737ed695031c45812de0946063acc2f..edc9b861ea54a505f82146adcd8ec853457beb72 100644 (file)
@@ -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.  */