[compiler-rt] [sanitizer-common] [Darwin] Fix overlapping dyld segment addresses (PR #166005)

Dan Blackwell via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 4 04:06:28 PST 2025


================
@@ -255,23 +256,21 @@ static bool NextSegmentLoad(MemoryMappedSegment *segment,
   layout_data->current_load_cmd_count--;
   if (((const load_command *)lc)->cmd == kLCSegment) {
     const SegmentCommand* sc = (const SegmentCommand *)lc;
-    uptr base_virt_addr, addr_mask;
+    if (strncmp(sc->segname, "__LINKEDIT", sizeof("__LINKEDIT")) == 0) {
+      // The LINKEDIT sections alias, so we ignore these sections to
+      // ensure our mappings are disjoint.
+      return false;
+    }
+
+    uptr base_virt_addr;
     if (layout_data->current_image == kDyldImageIdx) {
----------------
DanBlackwell wrote:

NIT: this is a single-statement if-else body now so can omit braces.

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


More information about the llvm-commits mailing list