]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
S/390: Disable relocation sort against code sections.
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Sat, 14 Mar 2015 10:45:05 +0000 (11:45 +0100)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 24 Aug 2017 12:46:50 +0000 (09:46 -0300)
When downgrading from GD to IE model we rewrite the call to
__tls_get_offset to a 64 bit load instruction. This relies on the fact
that the additional relocation for the call target has already been
executed when doing the rewrite.

   f1018:       e3 20 d0 00 00 04       lg      %r2,0(%r13)
   f101e:       c0 e5 00 00 00 00       brasl   %r14,f101e <__res_init+0x1e>
                        f101e: R_390_TLS_GDCALL __libc_resp
                        f1020: R_390_PLT32DBL   __tls_get_offset+0x2

0000000f1020  39f6c00000014 R_390_PLT32DBL    0000000000000000 __tls_get_offset + 2
0000000f101e  3afb700000026 R_390_TLS_GDCALL  0000000000000008 __libc_resp + 0

Due to the reloc sorting the order changed an the PLT32DBL reloc is
executed after the rewrite and overwrites part of the load instruction
with garbage.

bfd/
2015-03-14  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* elf-s390-common.c (elf_s390_elf_sort_relocs_p): Don't sort
relocs against code sections.
* elf32-s390.c: Define elf_backend_sort_relocs_p.
* elf64-s390.c: Likewise.

bfd/ChangeLog
bfd/elf-s390-common.c
bfd/elf32-s390.c
bfd/elf64-s390.c

index ef3042ed1c545f8abd1e66630cc1fe649e2a91d7..b1dcab20abc7bc67d04f26ec36e0388375011232 100644 (file)
@@ -1,6 +1,12 @@
 2015-03-18  Alan Modra  <amodra@gmail.com>
 
        Apply from master
+       2015-03-14  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+       * elf-s390-common.c (elf_s390_elf_sort_relocs_p): Don't sort
+       relocs against code sections.
+       * elf32-s390.c: Define elf_backend_sort_relocs_p.
+       * elf64-s390.c: Likewise.
+
        2015-03-11  Alan Modra  <amodra@gmail.com>
        * elf32-ppc.c (ppc_elf_get_synthetic_symtab): Examine stubs in
        reverse order.  Account for larger size of __tls_get_addr_opt stub.
index c74883cde273bcfb1e2154267f6d1f59bd1ea46b..3b0922b348c9677534f60eb752f906c3ca86b2ee 100644 (file)
@@ -242,3 +242,15 @@ elf_s390_add_symbol_hook (bfd *abfd,
 
   return TRUE;
 }
+
+/* Whether to sort relocs output by ld -r or ld --emit-relocs, by
+   r_offset.  Don't do so for code sections.  We want to keep ordering
+   of GDCALL / PLT32DBL for TLS optimizations as is.  On the other
+   hand, elf-eh-frame.c processing requires .eh_frame relocs to be
+   sorted.  */
+
+static bfd_boolean
+elf_s390_elf_sort_relocs_p (asection *sec)
+{
+  return (sec->flags & SEC_CODE) == 0;
+}
index 07e594f295787b0f26e879c2c21cff1b61375103..73df41a69fbc99e7f1ed9c2486ee82f5b34bb552 100644 (file)
@@ -4028,6 +4028,7 @@ elf32_s390_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 #define elf_backend_grok_prstatus            elf_s390_grok_prstatus
 #define elf_backend_plt_sym_val                      elf_s390_plt_sym_val
 #define elf_backend_add_symbol_hook           elf_s390_add_symbol_hook
+#define elf_backend_sort_relocs_p             elf_s390_elf_sort_relocs_p
 
 #define bfd_elf32_mkobject             elf_s390_mkobject
 #define elf_backend_object_p           elf_s390_object_p
index 9a874f2b7499eed770c4292a68a8d136901d5874..1e68afb21c660e1e1c20a93057c769658672ff8b 100644 (file)
@@ -3840,6 +3840,7 @@ const struct elf_size_info s390_elf64_size_info =
 #define elf_backend_init_index_section       _bfd_elf_init_1_index_section
 #define elf_backend_plt_sym_val                      elf_s390_plt_sym_val
 #define elf_backend_add_symbol_hook           elf_s390_add_symbol_hook
+#define elf_backend_sort_relocs_p             elf_s390_elf_sort_relocs_p
 
 #define bfd_elf64_mkobject             elf_s390_mkobject
 #define elf_backend_object_p           elf_s390_object_p