问题描述
'otool' 显示的方法的实现地址不断得到 1 个字节的偏移量.
I'm constantly getting 1 byte offset for implementation address of method shown by 'otool'.
例如,'otool -o' 给出 0xe99d5,但 'otool -tvV' 给出:
For an example 'otool -o' gives 0xe99d5 but 'otool -tvV' gives:
+[NSError(SomeCategory) someMethod]:
000e99d4 b590 push {r4, r7, lr}
000e99d6 f6441184 movw r1, 0x4984
000e99da af01 add r7, sp, #4
000e99dc f2c0010a movt r1, 0xa
So 方法从 0xe99d4 开始.0xe99d5 看起来不对,没有对齐.我相信 'otool' 工作正常,我不了解实现的某些方面.如何解释输出?
So method starts at 0xe99d4. 0xe99d5 looks wrong, not aligned.I believe that 'otool' works fine and I don't understand some aspects of implementation.How to interpret the output ?
推荐答案
现代 ARM 内核有两种类型的指令集.最初的一种称为 arm
模式,其中每条指令长度为四个字节,较新的一种称为 thumb2
(您可以猜到它已经通过了一些迭代),其中指令可以是两个或者四字节长(引入的原因是代码密度).
Modern ARM cores has two types of instruction sets. Original one is called arm
mode where each instruction is four bytes long and newer one is called thumb2
(as you can guess it has already passed some iterations) where instructions can be two or four bytes long (the reason for the introduction is code density).
CPU 在进行分支时可以改变模式,通知 CPU 使用的指令集的方式是设置要跳转的指令地址中的最低有效位.如果是 0 指令将被解释为 arm
模式,如果是 1 他们将被解释为 thumb
模式.
CPU can change modes when it is making a branch and the way to notify CPU about instruction set used is by setting the least significant bit in address of the instruction to be jumped. If it is 0 instruction will be interpreted as arm
mode, if it is 1 they will be interpreted as thumb
mode.
所以你看到的是你的函数处于 thumb2
模式,我们可以通过查看它由两个和四个字节长的指令组成来验证.
So what you are seeing is your function is in thumb2
mode which we can verify by seeing it consist of two and four byte long instructions.
这篇关于来自 otool for armv7 的错误方法实现地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!