[lld] 6cf2443 - [lld-macho][easy] Fix segment max protection
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 10 12:19:45 PST 2020
Author: Jez Ng
Date: 2020-11-10T12:19:28-08:00
New Revision: 6cf244327b0da1f0b5c40015dd19d5cb2bdd5e93
URL: https://github.com/llvm/llvm-project/commit/6cf244327b0da1f0b5c40015dd19d5cb2bdd5e93
DIFF: https://github.com/llvm/llvm-project/commit/6cf244327b0da1f0b5c40015dd19d5cb2bdd5e93.diff
LOG: [lld-macho][easy] Fix segment max protection
We should have maxprot == initprot for all non-i386 architectures, which
is what ld64 does.
Reviewed By: #lld-macho, compnerd
Differential Revision: https://reviews.llvm.org/D89420
Added:
Modified:
lld/MachO/OutputSegment.cpp
lld/test/MachO/segments.s
Removed:
################################################################################
diff --git a/lld/MachO/OutputSegment.cpp b/lld/MachO/OutputSegment.cpp
index 07e45901581b..a13f9f8252e4 100644
--- a/lld/MachO/OutputSegment.cpp
+++ b/lld/MachO/OutputSegment.cpp
@@ -31,9 +31,9 @@ static uint32_t initProt(StringRef name) {
}
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
diff erent maxProt requirements");
+ return initProt(name);
}
size_t OutputSegment::numNonHiddenSections() const {
diff --git a/lld/test/MachO/segments.s b/lld/test/MachO/segments.s
index 07ddcaee33ff..4b57f79d1ee8 100644
--- a/lld/test/MachO/segments.s
+++ b/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
More information about the llvm-commits
mailing list