Hello,

This patch fixes missing flags when compiling with -static-pie on mips. I
made these modifications based on the previously submitted static pie patch
for arm as well as the working code for aarch64.

I tested with a host of mips-elf and checked with mips-sim. This patch was
also tested and used with uclibc-ng to generate static pie elfs.

This is my first patch for gcc, so please let me know if there is anything
I missed.



Signed-off-by: linted <lin...@users.noreply.github.com>
---
 gcc/config/mips/gnu-user.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h
index 6aad7192e69..b1c665b7f37 100644
--- a/gcc/config/mips/gnu-user.h
+++ b/gcc/config/mips/gnu-user.h
@@ -56,11 +56,12 @@ along with GCC; see the file COPYING3.  If not see
 #define GNU_USER_TARGET_LINK_SPEC "\
   %{G*} %{EB} %{EL} %{mips*} %{shared} \
   %{!shared: \
-    %{!static: \
+    %{!static:%{!static-pie: \
       %{rdynamic:-export-dynamic} \
       %{mabi=n32: -dynamic-linker " GNU_USER_DYNAMIC_LINKERN32 "} \
       %{mabi=64: -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
-      %{mabi=32: -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \
+      %{mabi=32: -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \
+    %{static-pie:-Bstatic -pie --no-dynamic-linker -z text} \
     %{static}} \
   %{mabi=n32:-m" GNU_USER_LINK_EMULATIONN32 "} \
   %{mabi=64:-m" GNU_USER_LINK_EMULATION64 "} \
-- 
2.34.1

Reply via email to