Each second number is a number of consecutive variables (in objc_ivar_list) of the same type and each other second number is a distance between blocks of consecutive variables of the same type. A layout is a sequence of numbers from 1 to 15 ending with a zero byte. Then, based on the fields of raw_data strong and weak variable layouts, you can identify which class members are referred to by the object with strong references, and those with weak references, with the remaining variables being assigned by their values. Note that the list will also include synthesized variables (NSString _strongStringProperty and NSNumber _weakNumberProperty in this case). Well, let's see how the InspectedObject class from such InspectedObject.m is packed in a binary file: To some extent, this part is a code description taken from here. OK, now let's feed the InspecteObjc binary file to Hopper. Then, Show in Finder and Show Package Contents for InspectedObjc.app. The freshly baked app is now seen in the Products folder: In the file, define a class with all properties (see the code in the next section).Īdd it to a target and create a build. Well, let our app's name be InspectedObjc and, to keep it as compact as possible, let's use. While it is possible to create builds for a real device as well, you are strongly discouraged from doing this for an emulator since this would return a dramatically different binary file (because of a different architecture). We'll create builds (cmd+B) for an always-on Generic iOS Device: For the sake of convenience, let's leave arm64 architecture only in Build Settings. Create a Single View Application in Objective-C in Xcode. In this section we will code an app which we can study. To do this, select Hexadecimal mode with a soft button selector like this in the top: Getting prepared for Xcode Sometimes, looking at a non-parsed binary code gives results. Also, Hopper parses various entity names so you can search them (search line is in upper left part of the screen). In the assembler, you can double-click and jump to any address. To navigate through Hopper easily, you will find these two shortcuts extremely useful: Shift+S - a section list Mach-O files can be easily viewed with Hopper disassembler.You can download a trial version here. Find a brief overview here (Mach-O in Brief chapter). IOS app binary files are in Mach-O format. In addition to uint64 parameters, uint32 (32-bit) and uint16 (16-bit) parameters are also used, as well as int64 and int32 for relative pointers. In the case of your disassembly, the first part has been elided (left out as being an uninteresting housekeeping task) by the disassembler, but the second to last part (which undoes the first part) has not.Uint64 imp_addr // method implementation address} You might see something different due to using a different version of gcc or a different target. So what we have here is code to set up a stack frame (address 0-1), the assignment you have (4), setting up the return value (b), tearing down the frame (10) and then returning (11). So you'll get a much better idea of what is going on by using an actual disassembler to look at the actual disassembly code: $ gcc -c simple.cĤ: c7 45 fc 05 00 00 00 movl $0x5,-0x4(%rbp) In this case it looks like it has has elided the stack frame setup (the function prolog), but not the cleanup (function epilog). Looks like it is doing a particularly poor job of producing "disassembly pseudocode" (whatever that is - is it a disassembler or a decompliler? Can't decide)
0 Comments
Leave a Reply. |