Skip to content
Snippets Groups Projects
Commit 4ad37a32 authored by Ben Gamari's avatar Ben Gamari Committed by Marge Bot
Browse files

rts: Handle zero-sized mappings in MachO linker

As noted in #16701, it is possible that we will find that an object has
no segments needing to be mapped. Previously this would result in mmap
being called for a zero-length mapping, which would fail. We now simply
skip the mmap call in this case; the rest of the logic just works.
parent ade53ce2
No related branches found
No related tags found
No related merge requests found
Pipeline #6231 failed
......@@ -1122,8 +1122,12 @@ ocBuildSegments_MachO(ObjectCode *oc)
n_activeSegments++;
}
mem = mmapForLinker(size_compound, MAP_ANON, -1, 0);
if (NULL == mem) return 0;
// N.B. it's possible that there is nothing mappable in an object. In this
// case we avoid the mmap call since it would fail. See #16701.
if (size_compound > 0) {
mem = mmapForLinker(size_compound, MAP_ANON, -1, 0);
if (NULL == mem) return 0;
}
IF_DEBUG(linker, debugBelch("ocBuildSegments: allocating %d segments\n", n_activeSegments));
segments = (Segment*)stgCallocBytes(n_activeSegments, sizeof(Segment),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment