ARM BLX 指令范围(绝对值) [英] ARM BLX Instruction Range (absolute)

查看:33
本文介绍了ARM BLX 指令范围(绝对值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 ARM BLX 指令的问题,特别是关于 BLX RX 指令的问题.在 ARM 手册上指出对于 BLX 标签,标签应在 32MB 范围内.在我的代码中,我将 R0 寄存器设置为指向 address1.我的当前地址和address1(目的地址)之间的距离大约是0x05000000.

当我到达指令时,它崩溃了(address1 中的代码是 ARM,因此 T 模式没有问题).在 BLX 中使用绝对值时是否有任何限制?我应该使用贴面吗?

谢谢!

解决方案

您可以使用任何地址作为 BLX RX 形式的 RX 寄存器.它将执行arm arm中描述的动作.

<前>如果 ConditionPassed(cond) 那么目标 = RmLR = BLX 指令后的指令地址CPSR T 位 = 目标 [0]PC = 目标和 0xFFFFFFFE

如果没有任何代码、调用或被调用的代码是拇指模式,那么您可能没问题,请确保在这种情况下您提供的地址的 lsbit 为零.您实际上需要在 0x05000000 处拥有代码,并且需要处理分支链接的代码,这意味着如果它进行更多 bl 样式调用,它会维护链接寄存器 (r14).同样,如果您在从其他人调用的函数中进行此 blx 调用,则需要在进行 blx 调用之前保留 r14 并恢复 r14,或者在从您的函数返回时执行任何操作将该值放回 r15 (pc).

反汇编/objdump 列表的代码示例或片段将有助于进一步帮助您解决此问题.包含 blx 的代码和被调用的代码.

I got a question about the ARM BLX instruction, specifically regarding BLX RX instruction. On the ARM manual it states that for BLX label, label should be within the 32MB range. In my code, I set the R0 register to point to address1. The distance between my current address and address1 (the destination address) is about 0x05000000.

When I reach the instruction, it crashes (the code in address1 is ARM so no problems with T-mode). Is there any limit when using absolute values with BLX? Should I use veneers?

Thanks!

解决方案

You can use any address as the RX register in the form BLX RX. It will perform the actions described in the arm arm.

if ConditionPassed(cond) then
    target = Rm
    LR = address of instruction after the BLX instruction
    CPSR T bit = target[0]
    PC = target AND 0xFFFFFFFE

If none of the code, calling or code being called is thumb mode then you are probably fine, make sure in that case the lsbit of the address you give it is a zero. You need to actually have code at 0x05000000 and needs to be code intented to handle a branch-link, meaning it maintains the link register (r14) if it makes more bl style calls. Likewise if you are making this blx call inside a function that was called from someone else you need to preserve r14 before making the blx call and restore r14 and or do whatever to put that value back in r15 (pc) when returning from your function.

A code example or snippets of the disassembly/objdump listing would be useful to further help you solve this problem. the code containing the blx and the code being called.

这篇关于ARM BLX 指令范围(绝对值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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