Blame SOURCES/binutils-rh872148.patch

f5d709
From binutils-return-84754-listarch-binutils=sources dot redhat dot com at sourceware dot org Tue Sep 09 07:53:21 2014
f5d709
Return-Path: <binutils-return-84754-listarch-binutils=sources dot redhat dot com at sourceware dot org>
f5d709
Delivered-To: listarch-binutils at sources dot redhat dot com
f5d709
Received: (qmail 32519 invoked by alias); 9 Sep 2014 07:53:21 -0000
f5d709
Mailing-List: contact binutils-help at sourceware dot org; run by ezmlm
f5d709
Precedence: bulk
f5d709
List-Id: <binutils.sourceware.org>
f5d709
List-Subscribe: <mailto:binutils-subscribe at sourceware dot org>
f5d709
List-Archive: <http://sourceware.org/ml/binutils/>
f5d709
List-Post: <mailto:binutils at sourceware dot org>
f5d709
List-Help: <mailto:binutils-help at sourceware dot org>, <http://sourceware dot org/ml/#faqs>
f5d709
Sender: binutils-owner at sourceware dot org
f5d709
Delivered-To: mailing list binutils at sourceware dot org
f5d709
Received: (qmail 32506 invoked by uid 89); 9 Sep 2014 07:53:20 -0000
f5d709
Authentication-Results: sourceware.org; auth=none
f5d709
X-Virus-Found: No
f5d709
X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2
f5d709
X-HELO: e06smtp17.uk.ibm.com
f5d709
Received: from e06smtp17.uk.ibm.com (HELO e06smtp17.uk.ibm.com) (195.75.94.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 09 Sep 2014 07:53:13 +0000
f5d709
Received: from /spool/local	by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted	for <binutils@sourceware.org> from <krebbel@linux.vnet.ibm.com>;	Tue, 9 Sep 2014 08:53:10 +0100
f5d709
Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14)	by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted;	Tue, 9 Sep 2014 08:53:07 +0100
f5d709
Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194])	by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 27FA52190043	for <binutils@sourceware.org>; Tue,  9 Sep 2014 08:52:47 +0100 (BST)
f5d709
Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250])	by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s897r6Gc45220048	for <binutils@sourceware.org>; Tue, 9 Sep 2014 07:53:06 GMT
f5d709
Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1])	by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s897r6bk006416	for <binutils@sourceware.org>; Tue, 9 Sep 2014 01:53:06 -0600
f5d709
Received: from bart (dyn-9-152-212-108.boeblingen.de.ibm.com [9.152.212.108])	by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id s897r59h006331	for <binutils@sourceware.org>; Tue, 9 Sep 2014 01:53:05 -0600
f5d709
Received: by bart (sSMTP sendmail emulation); Tue, 09 Sep 2014 09:53:05 +0200
f5d709
Date: Tue, 9 Sep 2014 09:53:05 +0200
f5d709
From: Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>
f5d709
To: binutils at sourceware dot org
f5d709
Subject: [PATCH] S/390: Avoid TLS_LE* -> TLS_TPOFF translation for PIE
f5d709
Message-ID: <20140909075305.GA8292@maggie>
f5d709
MIME-Version: 1.0
f5d709
Content-Type: text/plain; charset=us-ascii
f5d709
Content-Disposition: inline
f5d709
User-Agent: Mutt/1.5.21 (2010-09-15)
f5d709
X-TM-AS-MML: disable
f5d709
X-Content-Scanned: Fidelis XPS MAILER
f5d709
x-cbid: 14090907-0542-0000-0000-000000A8E687
f5d709
f5d709
Hi,
f5d709
f5d709
for S/390 there is code which is supposed to handle non-pic objects
f5d709
being linked to a shared lib.  For TLS this code replaces the TLS_LE*
f5d709
relocs with a runtime reloc.  The code is triggered by the `shared`
f5d709
flag and therefore also for PIE.  But for PIE no runtime reloc is
f5d709
needed since the TLS offsets are always link-time computable.
f5d709
f5d709
(Btw. for s390x that special handling is anyway rather questionable
f5d709
since non-pic code will not work in a shared lib for various other
f5d709
reasons.)
f5d709
f5d709
Fixed with the attached patch.
f5d709
f5d709
No regressions on s390 and s390x.
f5d709
f5d709
bfd/
f5d709
f5d709
2014-09-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
f5d709
f5d709
	* elf32-s390.c: Don't replace R_390_TLS_LE32 with R_390_TLS_TPOFF
f5d709
	for PIE.
f5d709
	* elf64-s390.c: Don't replace R_390_TLS_LE64 with R_390_TLS_TPOFF
f5d709
	for PIE.
f5d709
f5d709
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
f5d709
index 11c726f..ebcb028 100644
f5d709
--- a/bfd/elf32-s390.c
f5d709
+++ b/bfd/elf32-s390.c
f5d709
@@ -1250,6 +1250,12 @@ elf_s390_check_relocs (bfd *abfd,
f5d709
 	  /* Fall through.  */
f5d709
 
f5d709
 	case R_390_TLS_LE32:
f5d709
+	  /* For static linking and executables this reloc will be
f5d709
+	     calculated at linktime otherwise a TLS_TPOFF runtime
f5d709
+	     reloc will be generated.  */
f5d709
+	  if (r_type == R_390_TLS_LE32 && info->pie)
f5d709
+	    break;
f5d709
+
f5d709
 	  if (!info->shared)
f5d709
 	    break;
f5d709
 	  info->flags |= DF_STATIC_TLS;
f5d709
@@ -3104,7 +3110,7 @@ elf_s390_relocate_section (bfd *output_bfd,
f5d709
 	  break;
f5d709
 
f5d709
 	case R_390_TLS_LE32:
f5d709
-	  if (info->shared)
f5d709
+	  if (info->shared && !info->pie)
f5d709
 	    {
f5d709
 	      /* Linking a shared library with non-fpic code requires
f5d709
 		 a R_390_TLS_TPOFF relocation.  */
f5d709
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
f5d709
index d7b2f08..b2f1aa5 100644
f5d709
--- a/bfd/elf64-s390.c
f5d709
+++ b/bfd/elf64-s390.c
f5d709
@@ -1183,6 +1183,12 @@ elf_s390_check_relocs (bfd *abfd,
f5d709
 	  /* Fall through */
f5d709
 
f5d709
 	case R_390_TLS_LE64:
f5d709
+	  /* For static linking and executables this reloc will be
f5d709
+	     calculated at linktime otherwise a TLS_TPOFF runtime
f5d709
+	     reloc will be generated.  */
f5d709
+	  if (r_type == R_390_TLS_LE64 && info->pie)
f5d709
+	    break;
f5d709
+
f5d709
 	  if (!info->shared)
f5d709
 	    break;
f5d709
 	  info->flags |= DF_STATIC_TLS;
f5d709
@@ -3074,7 +3080,7 @@ elf_s390_relocate_section (bfd *output_bfd,
f5d709
 	  break;
f5d709
 
f5d709
 	case R_390_TLS_LE64:
f5d709
-	  if (info->shared)
f5d709
+	  if (info->shared && !info->pie)
f5d709
 	    {
f5d709
 	      /* Linking a shared library with non-fpic code requires
f5d709
 		 a R_390_TLS_TPOFF relocation.  */
f5d709