Fix mach-o file vs segment size#124985
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses Mach-O validity issues in Crossgen2 composite R2R output by ensuring the first LC_SEGMENT_64 load command reports consistent segment sizes so Mach-O inspection tools (e.g., llvm-objdump, otool) don’t reject the file.
Changes:
- Updates Mach-O section layout logic to ensure the segment
vmsizeis not smaller than the segmentfilesize.
src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs
Outdated
Show resolved
Hide resolved
|
This doesn't look right. However, I admit that the calculation for |
|
I suppose the correct fix would look something like this: (on second thought, maybe the initial offset should be the aligned one, so maybe more like filipnavara@c48520c4d77) |
I took your second fix |
|
This is almost correct. I just forgot that now we also need to update the I can submit a full tested fix tomorrow unless you beat me to it. Sorry for the hassle and not catching this right away. |
Make sure that segment vmsize is never smaller than segment file size
Fixes #124982
cc: @filipnavara