public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] S390: Use fPIC to avoid R_390_GOT12 relocation in gcrt1.o with march=z900.
@ 2016-04-27  9:06 Stefan Liebler
  2016-04-27 10:01 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Liebler @ 2016-04-27  9:06 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]

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.

[-- Attachment #2: 20160427_Use_fPIC.patch --]
[-- Type: text/x-patch, Size: 555 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-11 13:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-27  9:06 [PATCH] S390: Use fPIC to avoid R_390_GOT12 relocation in gcrt1.o with march=z900 Stefan Liebler
2016-04-27 10:01 ` Andreas Schwab
2016-04-28  6:49   ` Stefan Liebler
2016-05-11 13:55     ` Stefan Liebler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).