Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the gcc ARM equivalent to this x64 assembly
    primarykey
    data
    text
    <p>This is the X64 code (I don't know much about assembly, and this code can be compiled by visual studio, don't know which format it is):</p> <pre><code>.code extern mProcs:QWORD myfunc proc jmp mProcs[1*8] myfunc endp </code></pre> <p>The mProcs is an array defined in C code, and the function myfunc simply jmp to the second element in the array. If viewed from C, it is jumping to *(mProcs+1) (1*8 because in x64 a pointer is 8 bytes).</p> <p>In GCC ARM version, I tried to do this:</p> <pre><code>.extern mProcs .global myfunc myfunc: b mProcs+4 </code></pre> <p>(here mProcs+4 because a pointer is 4 bytes)</p> <p>But this code seems no working. In C does it means jump to *(mProcs+1) or jump to mProcs+1? How can I make it *(mProcs+1)? </p> <p>============================================================================</p> <p>After discussion in the comments with Michael, I understood that I need to do the calculation on the register and then use the bx instruction to jump to the target function.</p> <p>However, the problem comes here. Since I'm implementing a thunk (I'm intercepting the function call and do something in the middle), I have no idea how the target routine uses the register.</p> <p><strong>1.</strong> I need to keep the callee save registers before I jmp to the target, else the target function will be preserving the wrong value.</p> <p><strong>2.</strong> I need to keep the argument registers intact before I perform a jump, so that the target function will have the correct arguments. 3. The above 2 points means I can only use caller save but non-argument registers.</p> <p>r0-r3 is the argument register, and r4-r12 are callee save register, r13 onwards are special registers. </p> <p>Which means none of the registers can be used without restoring the value.</p> <p>If the bx instruction can only operate on a register, then there is no chance I can restore that register even if that register is temporally saved on the stack.</p> <p>Any solutions? Or just arm binaries can't be hooked.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload