From: Richard Henderson <richard.henderson@linaro.org>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
libc-alpha@sourceware.org
Cc: fweimer@redhat.com
Subject: Re: [RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default
Date: Fri, 26 Aug 2022 10:29:32 -0700 [thread overview]
Message-ID: <bead8ab1-aef0-0b12-640f-17efe61a77d4@linaro.org> (raw)
In-Reply-To: <43f24a1f-6237-2f45-ec0e-2fea9367f0b3@linaro.org>
On 8/26/22 05:32, Adhemerval Zanella Netto wrote:
>
>
> On 25/08/22 18:01, Richard Henderson via Libc-alpha wrote:
>> [ 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~
>
> 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?
Ah, the resend is missing some detail I included in the original:
> For s390x, I would expect changes similar to c64a10e54441, and
> an eventual similar bug report if this were left unchanged.
>
> For x86, ppc64 and riscv64, -fpie & -fPIE are identical.
For ppc64 specifically, I audited gcc/config/rs6000/ for references to flag_pic, and the
only changes between -fpic and -fPIC are for 32-bit ABI_V4.
More generally, our assembly is already set up for -fPIC, which is the pic-ccflag default;
the difference for -fPIE is only in the selection of external vs local binding.
For aarch64, I've audited uses of the adrp instruction in sysdeps/, and they are what I'd
expect, e.g.
aarch64/start.S: adrp x0, :got:main
and there are no instances of '_GLOBAL_OFFSET_TABLE_', which is indicative of -fpic.
For s390, I've similarly audited uses of the larl instruction:
s390/s390-64/start.S: larl %r2,main@GOTENT # load pointer to main
r~
next prev parent reply other threads:[~2022-08-26 17:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 21:01 Richard Henderson
2022-08-26 12:32 ` Adhemerval Zanella Netto
2022-08-26 17:29 ` Richard Henderson [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bead8ab1-aef0-0b12-640f-17efe61a77d4@linaro.org \
--to=richard.henderson@linaro.org \
--cc=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).