[PATCH] D89420: [lld-macho][easy] Fix segment max protection
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 14 12:48:07 PDT 2020
int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
int3 requested review of this revision.
We should have maxprot == initprot for all non-i386 architectures, which
is what ld64 does.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89420
Files:
lld/MachO/OutputSegment.cpp
lld/test/MachO/segments.s
Index: lld/test/MachO/segments.s
===================================================================
--- lld/test/MachO/segments.s
+++ lld/test/MachO/segments.s
@@ -28,7 +28,7 @@
## dyld3 assumes that the __TEXT segment starts from the file header
# CHECK-NEXT: fileoff: 0
# CHECK-NEXT: filesize:
-# CHECK-NEXT: maxprot: rwx
+# CHECK-NEXT: maxprot: r-x
# CHECK-NEXT: initprot: r-x
# CHECK-NEXT: nsects: 1
# CHECK-NEXT: flags: 0x0
@@ -46,7 +46,7 @@
# CHECK-NEXT: vmsize:
# CHECK-NEXT: fileoff: [[#%u, LINKEDIT_OFF:]]
# CHECK-NEXT: filesize: [[#%u, LINKEDIT_SIZE:]]
-# CHECK-NEXT: maxprot: rwx
+# CHECK-NEXT: maxprot: r--
# CHECK-NEXT: initprot: r--
# CHECK-NOT: Cmd: LC_SEGMENT_64
Index: lld/MachO/OutputSegment.cpp
===================================================================
--- lld/MachO/OutputSegment.cpp
+++ lld/MachO/OutputSegment.cpp
@@ -31,9 +31,9 @@
}
static uint32_t maxProt(StringRef name) {
- if (name == segment_names::pageZero)
- return 0;
- return VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE;
+ assert(config->arch != AK_i386 &&
+ "TODO: i386 has different maxProt requirements");
+ return initProt(name);
}
size_t OutputSegment::numNonHiddenSections() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89420.298224.patch
Type: text/x-patch
Size: 1236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201014/cc909442/attachment.bin>
More information about the llvm-commits
mailing list