LIEF
LIEF copied to clipboard
adding SegmentCommand breaks dyld assumption for Mach-O
Describe the bug adding SegmentCommand breaks dyld assumption for Mach-O, modified Mach-O can not be executed.
To Reproduce
- add SegmentCommand breaks dyld assumption for Mach-O
- execute it.
result:
dyld: malformed mach-o image: __LINKEDIT must be last segment
Expected behavior Modified binary should be executed normally.
Cause and Fix
__LINKEDIT should be moved to the end of Mach-O file.
reference: https://github.com/opensource-apple/dyld/blob/3f928f32597888c5eac6003b9199d972d49857b5/src/ImageLoaderMachO.cpp#L285