I have an i386 mach-o binary that I am patching using a utility I'm writing. The operation that is causing this problem is the overwriting of an external jump pointer. My tool finds the external (_printf, for example, though I am using an objective-c function), notes the actual function pointer, and then overwrites the jump to go to a new buffer of memory (.text, so executable) wherein the original jump pointer is used after some tricks.I don't have much mach-o experience, but this seems very strange. Running the program normally (./blah) gives Segmentation fault: 11, but running it under LLDB (lldb; target create ./blah; process launch) actually runs it (at least for a bit).First I get the warning:[Layout] Detected missing constraints for <private>.  It cannot be placed because there are not enough constraints to fully define the size and origin. Add the missing constraints, or set translatesAutoresizingMaskIntoConstraints=YES and constraints will be generated for you. If this view is laid out manually on macOS 10.12 and later, you may choose to not call [super layout] from your override. Set a breakpoint on DETECTED_MISSING_CONSTRAINTS to debug. This error will only be logged once.But it does run. Then it returns at some point with code 45 (0x2D). I may breakpoint all the common exit functions but I doubt they're being called. I have confirmed my patch works (during the time it runs it calls the function a few times; no stack pointer difference before and after, only eax modified) and that it doesn't take up too much space (many more zeroes left as padding).So, I am very confused. For reference, this is the sort of external I am talking about (from IDA):_printf         proc nearjmp     ds:_printf_ptrendpMy utility would overwrite that specific jump but, without modifying anything important, later go to the pointer. Please note that I am not yet messing with the actual segments. The new jump location is a buffer of zeroes defined in .text with asm (clang). Any ideas?
Modified mach-o binary seg fault 11, starts under LLDB
assembly;x86;mach o