radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.39k stars 2.98k forks source link

Arm thumb: missing opcode mrs r0, PRIMASK #4215

Closed aeickho closed 7 years ago

aeickho commented 8 years ago

With: radare2 0.10.2-git 10468 @ linux-little-x86-64 git.0.10.1-11-g3624931 commit: 3624931cdec3aaf1f301dccb753bd044a66f89b5 build: 2016-03-04

the r2 disassembler can't translate the opcode mrs r0, PRIMASK

r2 f2

arm-none-eabi-objdump f2

radare commented 8 years ago

This is a bug in capstone. switch to the GNU one and it will work as expected:

e asm.arch=arm.gnu

I have filled an issue for this in the capstone repo: https://github.com/aquynh/capstone/issues/596

On 04 Mar 2016, at 00:32, alex, df8av notifications@github.com wrote:

With: radare2 0.10.2-git 10468 @ linux-little-x86-64 git.0.10.1-11-g3624931 commit: 3624931 https://github.com/radare/radare2/commit/3624931cdec3aaf1f301dccb753bd044a66f89b5 build: 2016-03-04

the r2 disassembler can't translate the opcode mrs r0, PRIMASK

r2 https://cloud.githubusercontent.com/assets/986535/13513269/1acac8c0-e1a0-11e5-85c7-e5a7e75b1080.png arm-none-eabi-objdump https://cloud.githubusercontent.com/assets/986535/13513284/27fc60f8-e1a0-11e5-9e77-4168e1bfe199.png — Reply to this email directly or view it on GitHub https://github.com/radare/radare2/issues/4215.

Maijin commented 8 years ago

@radare not a bug see the answer

queenp commented 7 years ago

Just chipping in here to add another example for a related opcode:

$ rasm2 -a arm -b 16 -d 81f31188
invalid
$ rasm2 -a arm.gnu -b 16 -d 81f31188
msr BASEPRI, r1

$ r2 malloc://512 -a arm -b 16
[0x00000000]> wx 81f31188
[0x00000000]> pd 1
            0x00000000      81f31188       
[0x00000000]> e asm.arch=arm.gnu
[0x00000000]> pd 1
            0x00000000      81f31188       msr BASEPRI,r1 

Have double checked that the current version of Capstone does handle this so long as mclass mode is enabled, and checked out the latest r2 to confirm (at time of writing): radare2 1.4.0-git 14218 @ linux-x86-64 git.1.3.0-123-gdb884ec commit: db884ecd1d04950200cfcfd589f48c8e4cdb30eb build: 2017-03-21__20:02:42.

alvarofe commented 7 years ago
air:capstone alvaro$ r2 -
 -- You can mark an offset in visual mode with the cursor and the ',' key. Later press '.' to go back
[0x00000000]> e asm.arch=arm
[0x00000000]> e asm.bits=16
[0x00000000]> e asm.cpu=?
v8
cortex
[0x00000000]> e asm.cpu=cortex
[0x00000000]> #cortex enable mclass (look at the code)
[0x00000000]> wx 81f31188
[0x00000000]> pd 1
            0x00000000      81f31188       msr basepri, r1