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.
From 56f0daba7bea5d64922c0f45a4fde360f39fb17e Mon Sep 17 00:00:00 2001
From: lancethepants <lancethepa...@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 <lancethepa...@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

Reply via email to