ARM BLX Instruction Range (absolute)

前端 未结 2 1076
情话喂你
情话喂你 2021-01-24 01:44

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.

2条回答
  •  星月不相逢
    2021-01-24 02:07

    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.

提交回复
热议问题