[compiler-rt] fix the module map of main executable on darwin platforms (PR #107227)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 05:13:22 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (pudge62)

<details>
<summary>Changes</summary>

In the executable image on Darwin platforms, there is a `__PAGEZERO` segment with a size of 0. When calculating the module map, this segment must be skipped to avoid errors. The previous implementation inaccurately calculated the executable image's range, starting the address at `0 + slide`.

---
Full diff: https://github.com/llvm/llvm-project/pull/107227.diff


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp (+2-1) 


``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp
index b44e016a0e5bc6..d13bc8e6ea261c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp
@@ -433,7 +433,8 @@ void MemoryMappingLayout::DumpListOfModules(
   MemoryMappedSegmentData data;
   segment.data_ = &data;
   while (Next(&segment)) {
-    if (segment.filename[0] == '\0') continue;
+    // skip the __PAGEZERO segment, its vmsize is 0
+    if (segment.filename[0] == '\0' || (segment.start == segment.end)) continue;
     LoadedModule *cur_module = nullptr;
     if (!modules->empty() &&
         0 == internal_strcmp(segment.filename, modules->back().full_name())) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/107227


More information about the llvm-commits mailing list