[PATCH] S390: Use fPIC to avoid R_390_GOT12 relocation in gcrt1.o with march=z900.
Stefan Liebler
stli@linux.vnet.ibm.com
Wed Apr 27 09:06:00 GMT 2016
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20160427_Use_fPIC.patch
Type: text/x-patch
Size: 555 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160427/1b0d016e/attachment.bin>
More information about the Libc-alpha
mailing list