This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] S390: Use fPIC to avoid R_390_GOT12 relocation in gcrt1.o with march=z900.


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]