S390: Use fPIC to avoid R_390_GOT12 relocation in gcrt1.o with march=z900.
Commit Message
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.
Comments
Stefan Liebler <stli@linux.vnet.ibm.com> writes:
> 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.
Alternatively, you could override -fpic only for gmon-start.os, to keep
a possible performance advantage for the rest.
Andreas.
On 04/27/2016 12:01 PM, Andreas Schwab wrote:
> Stefan Liebler <stli@linux.vnet.ibm.com> writes:
>
>> 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.
>
> Alternatively, you could override -fpic only for gmon-start.os, to keep
> a possible performance advantage for the rest.
>
> Andreas.
>
As it has no effect for newer architecture levels and
for older levels the effect is overall +/-0,
I would prefer the switch to -fPIC.
Bye
Stefan
Commited
Bye
Stefan
On 04/28/2016 08:49 AM, Stefan Liebler wrote:
> On 04/27/2016 12:01 PM, Andreas Schwab wrote:
>> Stefan Liebler <stli@linux.vnet.ibm.com> writes:
>>
>>> 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.
>>
>> Alternatively, you could override -fpic only for gmon-start.os, to keep
>> a possible performance advantage for the rest.
>>
>> Andreas.
>>
> As it has no effect for newer architecture levels and
> for older levels the effect is overall +/-0,
> I would prefer the switch to -fPIC.
>
> Bye
> Stefan
>
>
@@ -1,5 +1,3 @@
-pic-ccflag = -fpic
-
ifeq ($(subdir),gmon)
sysdep_routines += s390-mcount
endif
@@ -1,5 +1,3 @@
-pic-ccflag = -fpic
-
ifeq ($(subdir),gmon)
sysdep_routines += s390x-mcount
endif