summaryrefslogtreecommitdiff
path: root/user/llvm6/more-secure-plt.patch
blob: 1cc08a9a8f25f0daae9c570f31f1bc7c348a3ad5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff --git a/lib/Target/PowerPC/PPCSubtarget.cpp b/lib/Target/PowerPC/PPCSubtarget.cpp
index c0cbfd779cb..5d7a021c3e2 100644
--- a/lib/Target/PowerPC/PPCSubtarget.cpp
+++ b/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -106,6 +106,7 @@
   HasFloat128 = false;
   IsISA3_0 = false;
   UseLongCalls = false;
+  SecurePlt = false;
 
   HasPOPCNTD = POPCNTD_Unavailable;
 }
@@ -136,6 +137,10 @@
   if (isDarwin())
     HasLazyResolverStubs = true;
 
+  // Set up musl-specific properties.
+  if (TargetTriple.getEnvironment() == Triple::Musl)
+    SecurePlt = true;
+
   // QPX requires a 32-byte aligned stack. Note that we need to do this if
   // we're compiling for a BG/Q system regardless of whether or not QPX
   // is enabled because external functions will assume this alignment.
diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
index c583fba8cab..6a9eedf89c5 100644
--- a/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -222,6 +222,10 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT,
   if (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le)
     return Reloc::PIC_;
 
+  // musl needs SecurePlt, which depends on PIC.
+  if (TT.getEnvironment() == Triple::Musl)
+    return Reloc::PIC_;
+
   // 32-bit is static by default.
   return Reloc::Static;
 }