[PATCH] D95492: Pack relocations for Android when possible.
Dan Albert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 26 16:48:44 PST 2021
danalbert created this revision.
danalbert added reviewers: rprichard, srhines, rahulchaudhry.
danalbert added a project: clang.
danalbert requested review of this revision.
First supported by API 28.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95492
Files:
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-ld.c
Index: clang/test/Driver/linux-ld.c
===================================================================
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1103,6 +1103,22 @@
// CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
// CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
+// Check that we pass --pack-dyn-relocs=relr for API 28+ and not before.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android27 \
+// RUN: | FileCheck --check-prefix=CHECK-ANDROID-RELR-27 %s
+// CHECK-ANDROID-RELR-27: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=android+relr"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN: | FileCheck --check-prefix=CHECK-ANDROID-RELR-28 %s
+// CHECK-ANDROID-RELR-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-28: "--use-android-relr-tags"
+// CHECK-ANDROID-RELR-28: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-28-NOT: "--pack-dyn-relocs=android+relr"
+
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=armv7-linux-android21 \
// RUN: | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -245,6 +245,17 @@
ExtraOpts.push_back("--no-rosegment");
}
+ if (Triple.isAndroid() && !Triple.isAndroidVersionLT(28)) {
+ // Android supports relr packing starting with API 28 and had its own flavor
+ // (--pack-dyn-relocs=android) starting in API 23. It's possible to use both
+ // with --pack-dyn-relocs=android+relr, but we need to gather some data on
+ // the impact of that form before we can know if it's a good default.
+ //
+ // On the other hand, relr should always be an improvement.
+ ExtraOpts.push_back("--use-android-relr-tags");
+ ExtraOpts.push_back("--pack-dyn-relocs=relr");
+ }
+
// Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
// from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95492.319439.patch
Type: text/x-patch
Size: 2283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210127/4894e51b/attachment.bin>
More information about the cfe-commits
mailing list