public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default
@ 2022-08-25 21:01 Richard Henderson
  2022-08-26 12:32 ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 19+ messages in thread
From: Richard Henderson @ 2022-08-25 21:01 UTC (permalink / raw)
  To: libc-alpha; +Cc: carlos, fweimer

[ I never saw this arrive in the list archives.
  Trying again with my linaro address subscribed. ]

We should default to the larger code model, in order to support
larger applications built with -static -pie.  This should be
consistent with pic-ccflag, which defaults to -fPIC.

Remove the now redundant override from sysdeps/sparc/Makefile.
Note that -fno-pie and -fno-PIE have the same effect.

---

In the case of AArch64, the code changes are small but significant:

 0000000000000000 <__libc_init_first>:
    0:  a9bd7bfd        stp     x29, x30, [sp, #-48]!
-   4:  90000003        adrp    x3, 0 <_GLOBAL_OFFSET_TABLE_>
-                       4: R_AARCH64_ADR_PREL_PG_HI21   _GLOBAL_OFFSET_TABLE_
+   4:  90000003        adrp    x3, 0 <__environ>
+                       4: R_AARCH64_ADR_GOT_PAGE       __environ
    8:  90000004        adrp    x4, 0 <__libc_init_first>
                        8: R_AARCH64_ADR_PREL_PG_HI21   .bss
    c:  910003fd        mov     x29, sp
   10:  f9400063        ldr     x3, [x3]
-                       10: R_AARCH64_LD64_GOTPAGE_LO15 __environ
+                       10: R_AARCH64_LD64_GOT_LO12_NC  __environ

In the small model, we are constrained to 15 bits of GOT, with a
single shared base, _GLOBAL_OFFSET_TABLE_.  In the large model,
each symbol has a page + offset pair.  For small functions like
this, where there are no other variable references to share the
common GOT pointer, there is no actual code change.

r~
---
 Makeconfig             | 2 +-
 sysdeps/sparc/Makefile | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/Makeconfig b/Makeconfig
index e78cf220af..f8164a0025 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1052,7 +1052,7 @@ pic-ccflag = -fPIC
 PIC-ccflag = -fPIC
 endif
 # This can be changed by a sysdep makefile
-pie-ccflag = -fpie
+pie-ccflag = -fPIE
 no-pie-ccflag = -fno-pie
 # This one should always stay like this unless there is a very good reason.
 PIE-ccflag = -fPIE
diff --git a/sysdeps/sparc/Makefile b/sysdeps/sparc/Makefile
index 12c2c1b085..26b4a84606 100644
--- a/sysdeps/sparc/Makefile
+++ b/sysdeps/sparc/Makefile
@@ -1,9 +1,6 @@
 # The Sparc `long double' is a distinct type we support.
 long-double-fcts = yes
 
-pie-ccflag = -fPIE
-no-pie-ccflag = -fno-PIE
-
 ifeq ($(subdir),gmon)
 sysdep_routines += sparc-mcount
 endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 19+ messages in thread
* [RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default
@ 2022-08-26 18:39 Wilco Dijkstra
  2022-08-26 19:02 ` H.J. Lu
  0 siblings, 1 reply; 19+ messages in thread
From: Wilco Dijkstra @ 2022-08-26 18:39 UTC (permalink / raw)
  To: Adhemerval Zanella, richard.henderson; +Cc: 'GNU C Library'

Hi,

>> I recall that powerpc wanted to use -mcmodel=large, but it would require to
>> adjust a lot of assembly implementations.  Are we sure this change does not
>> trigger any regression with current glibc code?

I don't see significant differences in terms of codesize on AArch64, so the patch
is fine. As Richard mentioned, it often doesn't make any difference if a function
only uses a single global.

However this exposes a bug: it appears all symbols, including hidden symbols,
are always accessed via the GOT in libc.a even when they don't in libc.so. As a
result PIE code quality is actually worse than PIC... This affects libc_single_threaded
and many uses of internal arrays etc.

So it looks like we should not ignore hidden when building for PIE.

Cheers,
Wilco

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

end of thread, other threads:[~2022-09-20 22:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25 21:01 [RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default Richard Henderson
2022-08-26 12:32 ` Adhemerval Zanella Netto
2022-08-26 17:29   ` Richard Henderson
2022-08-26 18:39 Wilco Dijkstra
2022-08-26 19:02 ` H.J. Lu
2022-08-26 19:45   ` Richard Henderson
2022-08-26 20:11     ` H.J. Lu
2022-08-29 11:49       ` Wilco Dijkstra
2022-08-29 13:10         ` Florian Weimer
2022-08-29 15:27           ` Wilco Dijkstra
2022-08-29 15:27             ` Wilco Dijkstra
2022-08-29 19:43             ` H.J. Lu
2022-08-29 19:57               ` Fangrui Song
2022-09-05  8:58                 ` Wilco Dijkstra
2022-09-15 21:45                   ` Fangrui Song
2022-09-20 13:59                     ` Wilco Dijkstra
2022-09-20 14:12                       ` Florian Weimer
2022-09-20 16:00                         ` Wilco Dijkstra
2022-09-20 22:02                           ` Fangrui Song

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).