From patchwork Wed Apr 27 09:06:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 11903 Received: (qmail 70631 invoked by alias); 27 Apr 2016 09:06:18 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 69760 invoked by uid 89); 27 Apr 2016 09:06:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2088 X-HELO: plane.gmane.org To: libc-alpha@sourceware.org From: Stefan Liebler Subject: [PATCH] S390: Use fPIC to avoid R_390_GOT12 relocation in gcrt1.o with march=z900. Date: Wed, 27 Apr 2016 11:06:05 +0200 Lines: 81 Message-ID: Mime-Version: 1.0 X-Mozilla-News-Host: news://news.gmane.org:119 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Hi, if glibc is build with -march=z900 | -march=z990, the startup file gcrt1.o (used if you link with gcc -pg) contains R_390_GOT12 | R_390_GOT20 relocations. Thus, an entry in the GOT can be addressed relative to the GOT pointer with a 12 | 20 bit displacement value. The startup files should not contain R_390_GOT12, R_390_GOT20 relocations, but R_390_GOTENT ones. According to the s390-Makefiles, -fpic is used. This patch removes the overrides of pic-ccflag and the default pic-ccflag = -fPIC in Makeconfig is used instead to get the R_390_GOTENT relocations in gcrt1.o. GCC with -fpic and newer cpu-architecture levels already produces R_390_GOTENT relocations. Thus there is no issue on most distributions. As far as i know, debian uses -march=z900 and thus is involved. If build with -fPIC and -march=z900, the code differs: In cases where GOT is accessed multiple times in a function, an additional larl ...@GOTENT is needed for each access: -fpic /* r12 is loaded once at begin of function. */ larl %r12,_GLOBAL_OFFSET_TABLE_ lg %r1,gl1@GOT(%r12) lg %r1,gl2@GOT(%r12) -fPIC larl %r3,gl1@GOTENT lg %r3,0(%r3) larl %r1,gl2@GOTENT lg %r1,0(%r1) On the other side, there exist cases, where r12 does not need to be loaded due to -fPIC, which then avoids the need to save/restore r12 at begin / end of function at all. Bye Stefan ChangeLog: * sysdeps/s390/s390-32/Makefile (pic-ccflag): Remove. * sysdeps/s390/s390-64/Makefile: Likewise. diff --git a/sysdeps/s390/s390-32/Makefile b/sysdeps/s390/s390-32/Makefile index 057862d..a07f298 100644 --- a/sysdeps/s390/s390-32/Makefile +++ b/sysdeps/s390/s390-32/Makefile @@ -1,5 +1,3 @@ -pic-ccflag = -fpic - ifeq ($(subdir),gmon) sysdep_routines += s390-mcount endif diff --git a/sysdeps/s390/s390-64/Makefile b/sysdeps/s390/s390-64/Makefile index ce4f0c5..5909d1f 100644 --- a/sysdeps/s390/s390-64/Makefile +++ b/sysdeps/s390/s390-64/Makefile @@ -1,5 +1,3 @@ -pic-ccflag = -fpic - ifeq ($(subdir),gmon) sysdep_routines += s390x-mcount endif