summaryrefslogtreecommitdiff
path: root/bfd/elf-s390-common.c
diff options
context:
space:
mode:
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>2015-03-14 11:45:05 +0100
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>2015-03-14 11:45:05 +0100
commitb9005ba76ee501a809f2657b04bb2f2590829fa3 (patch)
treead58cef6850906fa36b98d762878ebe3ebc8284d /bfd/elf-s390-common.c
parent5cddc23a3a0b855858e8eca93d6dd90aec00d914 (diff)
S/390: Disable relocation sort against code sections.
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.
Diffstat (limited to 'bfd/elf-s390-common.c')
-rw-r--r--bfd/elf-s390-common.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/bfd/elf-s390-common.c b/bfd/elf-s390-common.c
index 6fd1027296..462da16e12 100644
--- a/bfd/elf-s390-common.c
+++ b/bfd/elf-s390-common.c
@@ -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;
+}