public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] arm: add -static-pie support
@ 2022-07-19 20:36 Lance Fredrickson
  2023-09-30 20:55 ` Ben Wolsieffer
  0 siblings, 1 reply; 2+ messages in thread
From: Lance Fredrickson @ 2022-07-19 20:36 UTC (permalink / raw)
  To: gcc-patches

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

This patch adds -static-pie support for the arm architecture. aarch64 
had the appropriate code for handling -static-pie, so this just mirrors 
the code found there.  Tested with uclibc-ng and musl c-standard 
libraries to produce static-pie binaries.

[-- Attachment #2: 0001-arm-add-static-pie-support.patch --]
[-- Type: text/plain, Size: 1110 bytes --]

From 56f0daba7bea5d64922c0f45a4fde360f39fb17e Mon Sep 17 00:00:00 2001
From: lancethepants <lancethepants@gmail.com>
Date: Tue, 19 Jul 2022 14:21:05 -0600
Subject: [PATCH] arm: add -static-pie support

The commit mirros code from aarch64 to handle -static-pie.
Tested with uclibc-ng and musl c-standard libraries.

Signed-off-by: Lance Fredrickson <lancethepants@gmail.com>
---
 gcc/config/arm/linux-elf.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
index df3da67c4f0..70f71b051a3 100644
--- a/gcc/config/arm/linux-elf.h
+++ b/gcc/config/arm/linux-elf.h
@@ -66,9 +66,10 @@
    %{static:-Bstatic} \
    %{shared:-shared} \
    %{symbolic:-Bsymbolic} \
-   %{!static: \
+   %{!static:%{!static-pie: \
      %{rdynamic:-export-dynamic} \
-     %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
+     %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}} \
+   %{static-pie:-Bstatic -pie --no-dynamic-linker -z text} \
    -X \
    %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
    SUBTARGET_EXTRA_LINK_SPEC
-- 
2.20.1


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

* Re: [PATCH] arm: add -static-pie support
  2022-07-19 20:36 [PATCH] arm: add -static-pie support Lance Fredrickson
@ 2023-09-30 20:55 ` Ben Wolsieffer
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Wolsieffer @ 2023-09-30 20:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: Lance Fredrickson

On Tue, Jul 19, 2022 at 02:21:05PM -0600, lancethepants wrote:
> The commit mirros code from aarch64 to handle -static-pie.
> Tested with uclibc-ng and musl c-standard libraries.
> 
> Signed-off-by: Lance Fredrickson <lancethepants@gmail.com>
> ---
>  gcc/config/arm/linux-elf.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
> index df3da67c4f0..70f71b051a3 100644
> --- a/gcc/config/arm/linux-elf.h
> +++ b/gcc/config/arm/linux-elf.h
> @@ -66,9 +66,10 @@
>     %{static:-Bstatic} \
>     %{shared:-shared} \
>     %{symbolic:-Bsymbolic} \
> -   %{!static: \
> +   %{!static:%{!static-pie: \
>       %{rdynamic:-export-dynamic} \
> -     %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
> +     %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}} \
> +   %{static-pie:-Bstatic -pie --no-dynamic-linker -z text} \
>     -X \
>     %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
>     SUBTARGET_EXTRA_LINK_SPEC

Hi,

This patch seems to have gotten a bit mangled when it was submitted,
so perhaps that's why it was ignored, but it would be great to get this
functionality in gcc.

In particular, systemd has begun relying on -static-pie for EFI
support, and has to implement workarounds (manually passing these flags
to the linker) for architectures that don't support -static-pie (see
[1], [2]).

Thanks, Ben

[1] https://github.com/NixOS/nixpkgs/pull/243242#issuecomment-1741835837
[2] https://github.com/systemd/systemd/issues/29381

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

end of thread, other threads:[~2023-09-30 20:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 20:36 [PATCH] arm: add -static-pie support Lance Fredrickson
2023-09-30 20:55 ` Ben Wolsieffer

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