[clang] a77d1f6 - [Driver] Change Linux::isPIEDefault to true for all Android versions

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 11 00:12:11 PST 2021


Author: Fangrui Song
Date: 2021-11-11T00:12:07-08:00
New Revision: a77d1f68a0020089378a8f8ef347a48e015ab641

URL: https://github.com/llvm/llvm-project/commit/a77d1f68a0020089378a8f8ef347a48e015ab641
DIFF: https://github.com/llvm/llvm-project/commit/a77d1f68a0020089378a8f8ef347a48e015ab641.diff

LOG: [Driver] Change Linux::isPIEDefault to true for all Android versions

Currently any API level>=16 uses default PIE.
If API level<16 is too old to be supported, we can clean up some code.

Reviewed By: danalbert

Differential Revision: https://reviews.llvm.org/D113370

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Linux.cpp
    clang/test/Driver/android-pie.c
    clang/test/Driver/fsanitize.c
    clang/test/Driver/pic.c
    clang/test/Driver/sanitizer-ld.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index d02c3af28257..7e5939f8f118 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -663,8 +663,8 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
 }
 
 bool Linux::isPIEDefault() const {
-  return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
-          getTriple().isMusl() || getSanitizerArgs().requiresPIE();
+  return getTriple().isAndroid() || getTriple().isMusl() ||
+         getSanitizerArgs().requiresPIE();
 }
 
 bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {

diff  --git a/clang/test/Driver/android-pie.c b/clang/test/Driver/android-pie.c
index 052c0bcb4064..c006b90891e8 100644
--- a/clang/test/Driver/android-pie.c
+++ b/clang/test/Driver/android-pie.c
@@ -2,30 +2,18 @@
 // PIE: "-pie"
 
 // RUN: %clang %s -### -o %t.o 2>&1 --target=arm-linux-androideabi \
-// RUN:   | FileCheck --check-prefix=NO-PIE %s
+// RUN:   | FileCheck --check-prefix=PIE %s
 // RUN: %clang %s -### -o %t.o 2>&1 --target=arm-linux-android \
-// RUN:   | FileCheck --check-prefix=NO-PIE %s
-// RUN: %clang %s -### -o %t.o 2>&1 --target=arm-linux-android14 \
-// RUN:   | FileCheck --check-prefix=NO-PIE %s
-// RUN: %clang %s -### -o %t.o 2>&1 --target=arm-linux-android16 \
 // RUN:   | FileCheck --check-prefix=PIE %s
 // RUN: %clang %s -### -o %t.o 2>&1 --target=arm-linux-android24 \
 // RUN:   | FileCheck --check-prefix=PIE %s
 
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mipsel-linux-android \
-// RUN:   | FileCheck --check-prefix=NO-PIE %s
-// RUN: %clang %s -### -o %t.o 2>&1 --target=mipsel-linux-android14 \
-// RUN:   | FileCheck --check-prefix=NO-PIE %s
-// RUN: %clang %s -### -o %t.o 2>&1 --target=mipsel-linux-android16 \
 // RUN:   | FileCheck --check-prefix=PIE %s
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mipsel-linux-android24 \
 // RUN:   | FileCheck --check-prefix=PIE %s
 
 // RUN: %clang %s -### -o %t.o 2>&1 --target=i686-linux-android \
-// RUN:   | FileCheck --check-prefix=NO-PIE %s
-// RUN: %clang %s -### -o %t.o 2>&1 --target=i686-linux-android14 \
-// RUN:   | FileCheck --check-prefix=NO-PIE %s
-// RUN: %clang %s -### -o %t.o 2>&1 --target=i686-linux-android16 \
 // RUN:   | FileCheck --check-prefix=PIE %s
 // RUN: %clang %s -### -o %t.o 2>&1 --target=i686-linux-android24 \
 // RUN:   | FileCheck --check-prefix=PIE %s
@@ -53,8 +41,6 @@
 // Override toolchain default setting.
 // RUN: %clang %s -### -o %t.o 2>&1 -pie --target=arm-linux-androideabi \
 // RUN:   | FileCheck --check-prefix=PIE %s
-// RUN: %clang %s -### -o %t.o 2>&1 -pie --target=arm-linux-androideabi14 \
-// RUN:   | FileCheck --check-prefix=PIE %s
 // RUN: %clang %s -### -o %t.o 2>&1 -no-pie -pie --target=arm-linux-androideabi24 \
 // RUN:   | FileCheck --check-prefix=PIE %s
 

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index b7d61abe7ec5..a6b5776c9e70 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -348,7 +348,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE
 // RUN: %clang -target x86_64-unknown-freebsd -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
 // RUN: %clang -target aarch64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
-// RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIC-NO-PIE
+// RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
 // RUN: %clang -target arm-linux-androideabi24 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
 // RUN: %clang -target aarch64-linux-android -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIE
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE

diff  --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index 6f8d6cc75c00..acb0bad022f4 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -267,30 +267,12 @@
 //
 // On Android PIC is enabled by default, and PIE is enabled by default starting
 // with API16.
-// RUN: %clang -c %s -target i686-linux-android -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
-// RUN: %clang -c %s -target i686-linux-android14 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
-// RUN: %clang -c %s -target i686-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
 // RUN: %clang -c %s -target i686-linux-android24 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
 //
-// RUN: %clang -c %s -target arm-linux-androideabi -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
-// RUN: %clang -c %s -target arm-linux-androideabi14 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
-// RUN: %clang -c %s -target arm-linux-androideabi16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
 // RUN: %clang -c %s -target arm-linux-androideabi24 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
 //
-// RUN: %clang -c %s -target mipsel-linux-android -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
-// RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
-// RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
@@ -305,10 +287,6 @@
 // Default value of PIE can be overwritten, even on 64-bit targets.
 // RUN: %clang -c %s -target arm-linux-androideabi -fPIE -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
-// RUN: %clang -c %s -target i686-linux-android14 -fPIE -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
-// RUN: %clang -c %s -target i686-linux-android16 -fno-PIE -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 // RUN: %clang -c %s -target aarch64-linux-android -fno-PIE -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 // RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \

diff  --git a/clang/test/Driver/sanitizer-ld.c b/clang/test/Driver/sanitizer-ld.c
index 5e89552345f6..d62e19fd4021 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -148,8 +148,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-ANDROID %s
 //
 // CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-ASAN-ANDROID: "-pie"
 // CHECK-ASAN-ANDROID-NOT: "-lc"
-// CHECK-ASAN-ANDROID-NOT: "-pie"
 // CHECK-ASAN-ANDROID-NOT: "-lpthread"
 // CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
 // CHECK-ASAN-ANDROID-NOT: "-lpthread"
@@ -171,8 +171,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-ANDROID %s
 //
 // CHECK-UBSAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-UBSAN-ANDROID: "-pie"
 // CHECK-UBSAN-ANDROID-NOT: "-lc"
-// CHECK-UBSAN-ANDROID-NOT: "-pie"
 // CHECK-UBSAN-ANDROID-NOT: "-lpthread"
 // CHECK-UBSAN-ANDROID: libclang_rt.ubsan_standalone-arm-android.so"
 // CHECK-UBSAN-ANDROID-NOT: "-lpthread"
@@ -195,8 +195,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-ANDROID-X86 %s
 //
 // CHECK-ASAN-ANDROID-X86: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-ASAN-ANDROID-X86: "-pie"
 // CHECK-ASAN-ANDROID-X86-NOT: "-lc"
-// CHECK-ASAN-ANDROID-X86-NOT: "-pie"
 // CHECK-ASAN-ANDROID-X86-NOT: "-lpthread"
 // CHECK-ASAN-ANDROID-X86: libclang_rt.asan-i686-android.so"
 // CHECK-ASAN-ANDROID-X86-NOT: "-lpthread"


        


More information about the cfe-commits mailing list