LIEF icon indicating copy to clipboard operation
LIEF copied to clipboard

adding SegmentCommand breaks dyld assumption for Mach-O

Open sleicasper opened this issue 5 years ago • 0 comments

Describe the bug adding SegmentCommand breaks dyld assumption for Mach-O, modified Mach-O can not be executed.

To Reproduce

  1. add SegmentCommand breaks dyld assumption for Mach-O
  2. 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

sleicasper avatar Mar 24 '20 05:03 sleicasper