summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rules.mak3
-rw-r--r--ldso/ldso/powerpc/dl-startup.h4
-rw-r--r--libc/sysdeps/linux/powerpc/crt1.S4
3 files changed, 10 insertions, 1 deletions
diff --git a/Rules.mak b/Rules.mak
index 1fa09be23..c789aefd3 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -483,9 +483,10 @@ ifeq ($(TARGET_ARCH),powerpc)
PICFLAG:=-fpic
PIEFLAG_NAME:=-fpie
PPC_HAS_REL16:=$(shell printf "\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha\n" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n)
+ PPC_HAS_SECUREPLT:=$(shell $(CC) --verbose 2>&1 | grep -- --enable-secureplt > /dev/null && echo -n y || echo -n n)
+ CPU_CFLAGS-$(PPC_HAS_SECUREPLT) += -DPPC_HAS_SECUREPLT
CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16
CPU_CFLAGS-$(CONFIG_E500) += "-D__NO_MATH_INLINES"
-
endif
ifeq ($(TARGET_ARCH),bfin)
diff --git a/ldso/ldso/powerpc/dl-startup.h b/ldso/ldso/powerpc/dl-startup.h
index 8b2a517e2..8503350c5 100644
--- a/ldso/ldso/powerpc/dl-startup.h
+++ b/ldso/ldso/powerpc/dl-startup.h
@@ -26,6 +26,10 @@ __asm__(
" bl _GLOBAL_OFFSET_TABLE_-4@local\n" /* Put our GOT pointer in r31, */
" mflr 31\n"
#endif
+/* I'm quite sure this piece of code is always compiled as PIC but let's be sure */
+#if defined(PPC_HAS_SECUREPLT) && defined(__PIC__)
+ " mr 30,31\n"
+#endif
" addi 1,1,16\n" /* Restore SP */
" lwz 7,_dl_skip_args@got(31)\n" /* load EA of _dl_skip_args */
" lwz 7,0(7)\n" /* Load word from _dl_skip_args */
diff --git a/libc/sysdeps/linux/powerpc/crt1.S b/libc/sysdeps/linux/powerpc/crt1.S
index 27bfc5a5a..3f5d056c0 100644
--- a/libc/sysdeps/linux/powerpc/crt1.S
+++ b/libc/sysdeps/linux/powerpc/crt1.S
@@ -57,6 +57,10 @@ _start:
bl _GLOBAL_OFFSET_TABLE_-4@local
mflr r31
# endif
+ /* in PIC/PIE, plt stubs need r30 to point to the GOT if using secure-plt */
+# ifdef PPC_HAS_SECUREPLT
+ mr 30,31
+# endif
#endif
/* Set up the small data pointer in r13. */
#ifdef __PIC__