MaskRay created this revision.
MaskRay added reviewers: danalbert, srhines.
Herald added a subscriber: danielkiss.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113370

Files:
  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

Index: clang/test/Driver/sanitizer-ld.c
===================================================================
--- clang/test/Driver/sanitizer-ld.c
+++ 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"
Index: clang/test/Driver/pic.c
===================================================================
--- clang/test/Driver/pic.c
+++ 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 \
Index: clang/test/Driver/fsanitize.c
===================================================================
--- clang/test/Driver/fsanitize.c
+++ 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
Index: clang/test/Driver/android-pie.c
===================================================================
--- clang/test/Driver/android-pie.c
+++ 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
 
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -663,8 +663,8 @@
 }
 
 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 {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D113370: [Driver] Cha... Fangrui Song via Phabricator via cfe-commits

Reply via email to