[PATCH] D48795: [AArch64] Add support for SHF_ARM_PURECODE.
Ivan Lozano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 29 15:11:14 PDT 2018
ivanlozano created this revision.
ivanlozano added reviewers: srhines, eugenis, peter.smith, echristo.
Herald added subscribers: llvm-commits, chrib, kristof.beyls, arichardson, emaste.
Herald added a reviewer: javed.absar.
Herald added a reviewer: espindola.
Adds support for the execute-only section flag SFH_ARM_PURECODE on AArch64 targets.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D48795
Files:
ELF/OutputSections.cpp
test/ELF/aarch64-execute-only.s
Index: test/ELF/aarch64-execute-only.s
===================================================================
--- /dev/null
+++ test/ELF/aarch64-execute-only.s
@@ -0,0 +1,40 @@
+// REQUIRES: aarch64
+
+// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o
+// RUN: ld.lld %t.o -o %t.so -shared
+// RUN: llvm-readelf -l %t.so | FileCheck %s
+
+// RUN: ld.lld %t.o %t.o -o %t.so -shared
+// RUN: llvm-readelf -l %t.so | FileCheck %s
+
+// RUN: echo ".section .foo,\"ax\"; \
+// RUN: br lr" > %t.s
+// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %t.s -o %t2.o
+// RUN: ld.lld %t.o %t2.o -o %t.so -shared
+// RUN: llvm-readelf -l %t.so | FileCheck --check-prefix=DIFF %s
+
+// CHECK-NOT: LOAD
+// CHECK: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000245 0x000245 R 0x10000
+// CHECK: LOAD 0x010000 0x0000000000010000 0x0000000000010000 0x{{.*}} 0x{{.*}} R E 0x10000
+// CHECK: LOAD 0x020000 0x0000000000020000 0x0000000000020000 0x{{.*}} 0x{{.*}} E 0x10000
+// CHECK: LOAD 0x030000 0x0000000000030000 0x0000000000030000 0x000070 0x000070 RW 0x10000
+// CHECK-NOT: LOAD
+
+// CHECK: 01 .dynsym .gnu.hash .hash .dynstr
+// CHECK: 02 .text
+// CHECK: 03 .foo
+// CHECK: 04 .dynamic
+
+// DIFF-NOT: LOAD
+// DIFF: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x00020d 0x00020d R 0x10000
+// DIFF: LOAD 0x010000 0x0000000000010000 0x0000000000010000 0x00000c 0x00000c R E 0x10000
+// DIFF: LOAD 0x020000 0x0000000000020000 0x0000000000020000 0x000070 0x000070 RW 0x10000
+// DIFF-NOT: LOAD
+
+// DIFF: 01 .dynsym .gnu.hash .hash .dynstr
+// DIFF: 02 .text .foo
+// DIFF: 03 .dynamic
+
+ br lr
+ .section .foo,"axy"
+ br lr
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -43,7 +43,8 @@
uint32_t OutputSection::getPhdrFlags() const {
uint32_t Ret = 0;
- if (Config->EMachine != EM_ARM || !(Flags & SHF_ARM_PURECODE))
+ if ((Config->EMachine != EM_ARM && Config->EMachine != EM_AARCH64 ) ||
+ !(Flags & SHF_ARM_PURECODE))
Ret |= PF_R;
if (Flags & SHF_WRITE)
Ret |= PF_W;
@@ -114,7 +115,8 @@
IS->Parent = this;
uint64_t AndMask =
- Config->EMachine == EM_ARM ? (uint64_t)SHF_ARM_PURECODE : 0;
+ (Config->EMachine == EM_ARM ||
+ Config->EMachine == EM_AARCH64) ? (uint64_t)SHF_ARM_PURECODE : 0;
uint64_t OrMask = ~AndMask;
uint64_t AndFlags = (Flags & IS->Flags) & AndMask;
uint64_t OrFlags = (Flags | IS->Flags) & OrMask;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48795.153590.patch
Type: text/x-patch
Size: 2687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180629/243abd3c/attachment.bin>
More information about the llvm-commits
mailing list