OCaml 4.14.0 rebuild: ocaml-ctypes 0.20.1-1
[arch-packages.git] / clang13 / trunk / enable-SSP-and-PIE-by-default.patch
blob31241be70424f26919ad67fd3c57e2c1ddabbe6e
1 From 683787b5c5c075f53a95f4d85f76302111c89914 Mon Sep 17 00:00:00 2001
2 From: Evangelos Foutras <evangelos@foutrelis.com>
3 Date: Sat, 23 Oct 2021 05:08:48 +0300
4 Subject: [PATCH] Enable SSP and PIE by default
6 This is a minimal set of changes needed to make clang use SSP and PIE by
7 default on Arch Linux. Tests that were easy to adjust have been changed
8 accordingly; only test/Driver/linux-ld.c has been marked as "expected
9 failure" due to the number of changes it would require (mostly replacing
10 crtbegin.o with crtbeginS.o).
12 Doing so is needed in order to align clang with the new default GCC
13 behavior in Arch which generates PIE executables by default and also
14 defaults to -fstack-protector-strong. It is not meant to be a long term
15 solution, but a simple temporary fix.
17 Hopefully these changes will be obsoleted by the introduction upstream
18 of a compile-time option (https://bugs.llvm.org/show_bug.cgi?id=13410)
19 ---
20 clang/lib/Driver/ToolChains/Linux.cpp | 10 ++++++++--
21 clang/lib/Driver/ToolChains/Linux.h | 5 +++++
22 clang/test/Driver/cross-linux.c | 16 ++++++++--------
23 clang/test/Driver/env.c | 2 +-
24 clang/test/Driver/fsanitize.c | 14 +++++++-------
25 clang/test/Driver/gcc-toolchain.cpp | 6 +++---
26 clang/test/Driver/hexagon-toolchain-elf.c | 2 +-
27 clang/test/Driver/hip-fpie-option.hip | 4 ++--
28 clang/test/Driver/linux-as.c | 4 ++--
29 clang/test/Driver/linux-ld.c | 2 ++
30 clang/test/Driver/ppc-abi.c | 18 +++++++++++-------
31 clang/test/Driver/riscv32-toolchain.c | 4 ++--
32 clang/test/Driver/riscv64-toolchain.c | 4 ++--
33 clang/test/Driver/stack-protector.c | 4 ++--
34 14 files changed, 56 insertions(+), 39 deletions(-)
36 diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
37 index c9360fc67165..2b60460e6604 100644
38 --- a/clang/lib/Driver/ToolChains/Linux.cpp
39 +++ b/clang/lib/Driver/ToolChains/Linux.cpp
40 @@ -652,8 +652,14 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
43 bool Linux::isPIEDefault() const {
44 - return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
45 - getTriple().isMusl() || getSanitizerArgs().requiresPIE();
46 + const bool IsMips = getTriple().isMIPS();
47 + const bool IsAndroid = getTriple().isAndroid();
49 + if (IsMips || IsAndroid)
50 + return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
51 + getTriple().isMusl() || getSanitizerArgs().requiresPIE();
53 + return true;
56 bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {
57 diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
58 index 169a37c44072..a6458092462e 100644
59 --- a/clang/lib/Driver/ToolChains/Linux.h
60 +++ b/clang/lib/Driver/ToolChains/Linux.h
61 @@ -10,6 +10,7 @@
62 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LINUX_H
64 #include "Gnu.h"
65 +#include "clang/Basic/LangOptions.h"
66 #include "clang/Driver/ToolChain.h"
68 namespace clang {
69 @@ -46,6 +47,10 @@ public:
70 bool isPIEDefault() const override;
71 bool isNoExecStackDefault() const override;
72 bool IsMathErrnoDefault() const override;
73 + LangOptions::StackProtectorMode
74 + GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
75 + return LangOptions::SSPStrong;
76 + }
77 SanitizerMask getSupportedSanitizers() const override;
78 void addProfileRTLibs(const llvm::opt::ArgList &Args,
79 llvm::opt::ArgStringList &CmdArgs) const override;
80 diff --git a/clang/test/Driver/cross-linux.c b/clang/test/Driver/cross-linux.c
81 index 59f5a97d2d9d..8d0e9e724aa0 100644
82 --- a/clang/test/Driver/cross-linux.c
83 +++ b/clang/test/Driver/cross-linux.c
84 @@ -43,8 +43,8 @@
85 // CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
86 // CHECK-MULTI32-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
87 // CHECK-MULTI32-I386: "-m" "elf_i386"
88 -// CHECK-MULTI32-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0]]{{/|\\\\}}crtbegin.o"
89 -// CHECK-MULTI32-I386: "-L[[gcc_install]]"
90 +// CHECK-MULTI32-I386: "crti.o" "crtbeginS.o"
91 +// CHECK-MULTI32-I386: "-L[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0]]"
92 // CHECK-MULTI32-I386: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib32"
93 // CHECK-MULTI32-I386: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
94 // CHECK-MULTI32-I386: "-L[[sysroot]]/lib"
95 @@ -61,8 +61,8 @@
96 // CHECK-MULTI32-X86-64: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
97 // CHECK-MULTI32-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
98 // CHECK-MULTI32-X86-64: "-m" "elf_x86_64"
99 -// CHECK-MULTI32-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0]]/64{{/|\\\\}}crtbegin.o"
100 -// CHECK-MULTI32-X86-64: "-L[[gcc_install]]/64"
101 +// CHECK-MULTI32-X86-64: "crti.o" "crtbeginS.o"
102 +// CHECK-MULTI32-X86-64: "-L[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/10.2.0]]/64"
103 // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib64"
104 // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
105 // CHECK-MULTI32-X86-64: "-L[[sysroot]]/lib"
106 @@ -79,8 +79,8 @@
107 // CHECK-MULTI64-I386: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
108 // CHECK-MULTI64-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
109 // CHECK-MULTI64-I386: "-m" "elf_i386"
110 -// CHECK-MULTI64-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0]]/32{{/|\\\\}}crtbegin.o"
111 -// CHECK-MULTI64-I386: "-L[[gcc_install]]/32"
112 +// CHECK-MULTI64-I386: "crti.o" "crtbeginS.o"
113 +// CHECK-MULTI64-I386: "-L[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0]]/32"
114 // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib32"
115 // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
116 // CHECK-MULTI64-I386: "-L[[sysroot]]/lib"
117 @@ -97,8 +97,8 @@
118 // CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
119 // CHECK-MULTI64-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
120 // CHECK-MULTI64-X86-64: "-m" "elf_x86_64"
121 -// CHECK-MULTI64-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0]]{{/|\\\\}}crtbegin.o"
122 -// CHECK-MULTI64-X86-64: "-L[[gcc_install]]"
123 +// CHECK-MULTI64-X86-64: "crti.o" "crtbeginS.o"
124 +// CHECK-MULTI64-X86-64: "-L[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/10.2.0]]"
125 // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib64"
126 // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
127 // CHECK-MULTI64-X86-64: "-L[[sysroot]]/lib"
128 diff --git a/clang/test/Driver/env.c b/clang/test/Driver/env.c
129 index e9b86cbcf428..47f304c0420d 100644
130 --- a/clang/test/Driver/env.c
131 +++ b/clang/test/Driver/env.c
132 @@ -22,7 +22,7 @@
134 // CHECK-LD-32-NOT: warning:
135 // CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
136 -// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/10.2.0{{/|\\\\}}crtbegin.o"
137 +// CHECK-LD-32: "crtbeginS.o"
138 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/10.2.0"
139 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/10.2.0/../../../../i386-unknown-linux/lib"
140 // CHECK-LD-32: "-L[[SYSROOT]]/lib"
141 diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
142 index b7d61abe7ec5..461b69b0ac15 100644
143 --- a/clang/test/Driver/fsanitize.c
144 +++ b/clang/test/Driver/fsanitize.c
145 @@ -344,15 +344,15 @@
146 // RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-sanitize=vptr -fsanitize=undefined,address %s -### 2>&1
147 // OK
149 -// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
150 -// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
151 +// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
152 +// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
153 // RUN: %clang -target x86_64-unknown-freebsd -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
154 // RUN: %clang -target aarch64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
155 // RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIC-NO-PIE
156 // RUN: %clang -target arm-linux-androideabi24 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
157 // RUN: %clang -target aarch64-linux-android -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
158 -// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
159 -// RUN: %clang -target i386-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
160 +// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
161 +// RUN: %clang -target i386-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
163 // CHECK-NO-PIE-NOT: "-pie"
164 // CHECK-NO-PIE: "-mrelocation-model" "static"
165 @@ -687,12 +687,12 @@
166 // RUN: %clang -fno-sanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NOSP
167 // NOSP-NOT: "-fsanitize=safe-stack"
169 -// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
170 +// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
171 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP-ASAN
172 // RUN: %clang -target x86_64-linux-gnu -fstack-protector -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
173 // RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SP
174 -// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
175 -// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
176 +// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
177 +// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP
178 // RUN: %clang -target i386-contiki-unknown -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP
179 // NO-SP-NOT: stack-protector
180 // NO-SP: "-fsanitize=safe-stack"
181 diff --git a/clang/test/Driver/gcc-toolchain.cpp b/clang/test/Driver/gcc-toolchain.cpp
182 index 7cdba0841b8c..655457d62bf8 100644
183 --- a/clang/test/Driver/gcc-toolchain.cpp
184 +++ b/clang/test/Driver/gcc-toolchain.cpp
185 @@ -23,7 +23,7 @@
186 // the same precise formatting of the path as the '-internal-system' flags
187 // above, so we just blanket wildcard match the 'crtbegin.o'.
188 // CHECK: "{{[^"]*}}ld{{(.exe)?}}"
189 -// CHECK-SAME: "{{[^"]*}}/usr/lib/gcc/x86_64-linux-gnu/4.8{{/|\\\\}}crtbegin.o"
190 +// CHECK-SAME: "crtbeginS.o"
191 // CHECK-SAME: "-L[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8"
192 /// On x86_64, there is an extra usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu but we should not test it.
194 @@ -35,5 +35,5 @@
195 // RUN: --target=aarch64-suse-linux -B%S/Inputs/opensuse_42.2_aarch64_tree/usr | \
196 // RUN: FileCheck %s --check-prefix=NO_AARCH64
198 -// AARCH64: Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crt1.o"
199 -// NO_AARCH64-NOT: Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crt1.o"
200 +// AARCH64: Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crti.o"
201 +// NO_AARCH64-NOT: Inputs{{[^"]+}}aarch64-suse-linux/{{[^"]+}}crti.o"
202 diff --git a/clang/test/Driver/hexagon-toolchain-elf.c b/clang/test/Driver/hexagon-toolchain-elf.c
203 index cc11f9fcba9e..1fe8b5db587b 100644
204 --- a/clang/test/Driver/hexagon-toolchain-elf.c
205 +++ b/clang/test/Driver/hexagon-toolchain-elf.c
206 @@ -487,7 +487,7 @@
207 // RUN: %s 2>&1 \
208 // RUN: | FileCheck -check-prefix=CHECK042 %s
209 // CHECK042: "-cc1"
210 -// CHECK042: "-mrelocation-model" "static"
211 +// CHECK042: "-mrelocation-model" "pic"
212 // CHECK042: "-mllvm" "-hexagon-small-data-threshold=8"
213 // CHECK042-NEXT: llvm-mc
214 // CHECK042: "-gpsize=8"
215 diff --git a/clang/test/Driver/hip-fpie-option.hip b/clang/test/Driver/hip-fpie-option.hip
216 index 2e296a099dea..86915f1c8c25 100644
217 --- a/clang/test/Driver/hip-fpie-option.hip
218 +++ b/clang/test/Driver/hip-fpie-option.hip
219 @@ -5,11 +5,11 @@
221 // RUN: %clang -### -target x86_64-unknown-linux-gnu \
222 // RUN: --offload-arch=gfx906 %s -nogpulib -nogpuinc \
223 -// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
224 +// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
226 // RUN: %clang -### -target x86_64-unknown-linux-gnu \
227 // RUN: -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
228 -// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
229 +// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
231 // RUN: %clang -### -target x86_64-unknown-linux-gnu \
232 // RUN: --offload-arch=gfx906 %s -nogpulib -nogpuinc \
233 diff --git a/clang/test/Driver/linux-as.c b/clang/test/Driver/linux-as.c
234 index 0959bd7ba0a1..4056a672b6f9 100644
235 --- a/clang/test/Driver/linux-as.c
236 +++ b/clang/test/Driver/linux-as.c
237 @@ -164,7 +164,7 @@
238 // CHECK-PPC-NO-MCPU-NOT: as{{.*}} "-mcpu=invalid-cpu"
240 // RUN: %clang -target sparc64-linux -mcpu=invalid-cpu -### \
241 -// RUN: -no-integrated-as -c %s 2>&1 \
242 +// RUN: -no-integrated-as -fno-pic -c %s 2>&1 \
243 // RUN: | FileCheck -check-prefix=CHECK-SPARCV9 %s
244 // CHECK-SPARCV9: as
245 // CHECK-SPARCV9: -64
246 @@ -173,7 +173,7 @@
247 // CHECK-SPARCV9: -o
249 // RUN: %clang -target sparc64-linux -mcpu=invalid-cpu -### \
250 -// RUN: -no-integrated-as -fpic -c %s 2>&1 \
251 +// RUN: -no-integrated-as -c %s 2>&1 \
252 // RUN: | FileCheck -check-prefix=CHECK-SPARCV9PIC %s
253 // CHECK-SPARCV9PIC: as
254 // CHECK-SPARCV9PIC: -64
255 diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
256 index cc505588331b..c7f81d2c5e49 100644
257 --- a/clang/test/Driver/linux-ld.c
258 +++ b/clang/test/Driver/linux-ld.c
259 @@ -1,4 +1,6 @@
260 // UNSUPPORTED: system-windows
261 +// XFAIL: linux
263 // General tests that ld invocations on Linux targets sane. Note that we use
264 // sysroot to make these tests independent of the host system.
266 diff --git a/clang/test/Driver/ppc-abi.c b/clang/test/Driver/ppc-abi.c
267 index a74a19953ca2..0452661ba5a7 100644
268 --- a/clang/test/Driver/ppc-abi.c
269 +++ b/clang/test/Driver/ppc-abi.c
270 @@ -1,20 +1,20 @@
271 // Check passing PowerPC ABI options to the backend.
273 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
274 -// RUN: | FileCheck -check-prefix=CHECK-ELFv1 %s
275 +// RUN: | FileCheck -check-prefix=CHECK-ELFv1-PIE %s
276 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
277 -// RUN: -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1 %s
278 +// RUN: -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-PIE %s
279 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
280 -// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-BE %s
281 +// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-BE-PIE %s
283 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
284 -// RUN: | FileCheck -check-prefix=CHECK-ELFv2 %s
285 +// RUN: | FileCheck -check-prefix=CHECK-ELFv2-PIE %s
286 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
287 // RUN: -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-LE %s
288 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
289 -// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s
290 +// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-PIE %s
291 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
292 -// RUN: -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
293 +// RUN: -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2-PIE %s
295 // RUN: %clang -target powerpc64-unknown-freebsd11 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s
296 // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s
297 @@ -26,10 +26,14 @@
299 // CHECK-ELFv1: "-mrelocation-model" "static"
300 // CHECK-ELFv1: "-target-abi" "elfv1"
301 -// CHECK-ELFv1-LE: "-mrelocation-model" "static"
302 +// CHECK-ELFv1-PIE: "-mrelocation-model" "pic" "-pic-level" "2"
303 +// CHECK-ELFv1-PIE: "-target-abi" "elfv1"
304 +// CHECK-ELFv1-LE: "-mrelocation-model" "pic" "-pic-level" "2"
305 // CHECK-ELFv1-LE: "-target-abi" "elfv1"
306 // CHECK-ELFv2: "-mrelocation-model" "static"
307 // CHECK-ELFv2: "-target-abi" "elfv2"
308 +// CHECK-ELFv2-PIE: "-mrelocation-model" "pic" "-pic-level" "2"
309 +// CHECK-ELFv2-PIE: "-target-abi" "elfv2"
310 // CHECK-ELFv2-BE: "-mrelocation-model" "static"
311 // CHECK-ELFv2-BE: "-target-abi" "elfv2"
312 // CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"
313 diff --git a/clang/test/Driver/riscv32-toolchain.c b/clang/test/Driver/riscv32-toolchain.c
314 index a5852f5f3997..233d9ef003cf 100644
315 --- a/clang/test/Driver/riscv32-toolchain.c
316 +++ b/clang/test/Driver/riscv32-toolchain.c
317 @@ -84,7 +84,7 @@
318 // C-RV32-LINUX-MULTI-ILP32: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
319 // C-RV32-LINUX-MULTI-ILP32: "-m" "elf32lriscv"
320 // C-RV32-LINUX-MULTI-ILP32: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32.so.1"
321 -// C-RV32-LINUX-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32{{/|\\\\}}crtbegin.o"
322 +// C-RV32-LINUX-MULTI-ILP32: "crtbeginS.o"
323 // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32"
324 // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32"
325 // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32"
326 @@ -99,7 +99,7 @@
327 // C-RV32-LINUX-MULTI-ILP32D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
328 // C-RV32-LINUX-MULTI-ILP32D: "-m" "elf32lriscv"
329 // C-RV32-LINUX-MULTI-ILP32D: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32d.so.1"
330 -// C-RV32-LINUX-MULTI-ILP32D: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32d{{/|\\\\}}crtbegin.o"
331 +// C-RV32-LINUX-MULTI-ILP32D: "crtbeginS.o"
332 // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32d"
333 // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32d"
334 // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32d"
335 diff --git a/clang/test/Driver/riscv64-toolchain.c b/clang/test/Driver/riscv64-toolchain.c
336 index e727f20bb601..a801e5eee462 100644
337 --- a/clang/test/Driver/riscv64-toolchain.c
338 +++ b/clang/test/Driver/riscv64-toolchain.c
339 @@ -84,7 +84,7 @@
340 // C-RV64-LINUX-MULTI-LP64: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
341 // C-RV64-LINUX-MULTI-LP64: "-m" "elf64lriscv"
342 // C-RV64-LINUX-MULTI-LP64: "-dynamic-linker" "/lib/ld-linux-riscv64-lp64.so.1"
343 -// C-RV64-LINUX-MULTI-LP64: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64{{/|\\\\}}crtbegin.o"
344 +// C-RV64-LINUX-MULTI-LP64: "crtbeginS.o"
345 // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64"
346 // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib64/lp64"
347 // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64"
348 @@ -99,7 +99,7 @@
349 // C-RV64-LINUX-MULTI-LP64D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot"
350 // C-RV64-LINUX-MULTI-LP64D: "-m" "elf64lriscv"
351 // C-RV64-LINUX-MULTI-LP64D: "-dynamic-linker" "/lib/ld-linux-riscv64-lp64d.so.1"
352 -// C-RV64-LINUX-MULTI-LP64D: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64d{{/|\\\\}}crtbegin.o"
353 +// C-RV64-LINUX-MULTI-LP64D: "crtbeginS.o"
354 // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64d"
355 // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib64/lp64d"
356 // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64d"
357 diff --git a/clang/test/Driver/stack-protector.c b/clang/test/Driver/stack-protector.c
358 index a3e40b50eed8..dfffe0d6cf85 100644
359 --- a/clang/test/Driver/stack-protector.c
360 +++ b/clang/test/Driver/stack-protector.c
361 @@ -3,11 +3,11 @@
362 // NOSSP-NOT: "-stack-protector-buffer-size"
364 // RUN: %clang -target i386-unknown-linux -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP
365 -// SSP: "-stack-protector" "1"
366 +// SSP: "-stack-protector" "2"
367 // SSP-NOT: "-stack-protector-buffer-size"
369 // RUN: %clang -target i386-unknown-linux -fstack-protector --param ssp-buffer-size=16 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-BUF
370 -// SSP-BUF: "-stack-protector" "1"
371 +// SSP-BUF: "-stack-protector" "2"
372 // SSP-BUF: "-stack-protector-buffer-size" "16"
374 // RUN: %clang -target i386-pc-openbsd -### %s 2>&1 | FileCheck %s -check-prefix=OPENBSD