2014年7月7日 星期一

function pointer and thumb/arm mode change

X call a function pointer Y

X is ARM mode
Y is ARM or thumb mode
is it workable?

Answer: yes, because
BX Rm and BLX Rm derive the target state from bit[0] of Rm:
  • if bit[0] of Rm is 0, the processor changes to, or remains in, ARM state
  • if bit[0] of Rm is 1, the processor changes to, or remains in, Thumb state.

before link, symbol table
12: 00000000     8 FUNC    GLOBAL DEFAULT    1 foo2  
12: 00000001     2 FUNC    GLOBAL DEFAULT    1 foo1

after link, symbol table
 3105: 00008d6c     8 FUNC    GLOBAL DEFAULT    3 foo2   <==compile into arm

 3106: 00008d69     2 FUNC    GLOBAL DEFAULT    3 foo1   <==compile into thumb


沒有留言:

張貼留言