otool for armv7 的方法实现地址错误? [英] Wrong method implementation address from otool for armv7?

查看:32
本文介绍了otool for armv7 的方法实现地址错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'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

所以方法从 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 的方法实现地址错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆