Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM big endian not supported? #353

Closed
michalmalik opened this issue Dec 31, 2015 · 5 comments
Closed

ARM big endian not supported? #353

michalmalik opened this issue Dec 31, 2015 · 5 comments

Comments

@michalmalik
Copy link
Contributor

Does Unicorn have support for ARMEB?

from __future__ import print_function
from unicorn import *
from unicorn.arm_const import *

'''
mov %r0, $10
mov %r1, $20
add %r2, %r0, %r1
'''
CODE_LE = "\x0A\x00\xA0\xE3\x14\x10\xA0\xE3\x01\x20\x80\xE0"
CODE_BE = "\xE3\xA0\x00\x0A\xE3\xA0\x10\x14\xE0\x80\x20\x01"
BASE = 0x8000
EP = 0x8074
SIZE = 0x1000

try:
        little = Uc(UC_ARCH_ARM, UC_MODE_ARM | UC_MODE_LITTLE_ENDIAN)
        little.mem_map(BASE, SIZE)
        little.mem_write(EP, CODE_LE)
        little.emu_start(EP, EP + len(CODE_LE))
        print("LE R0: %d" % little.reg_read(UC_ARM_REG_R0))
        print("LE R1: %d" % little.reg_read(UC_ARM_REG_R1))
        print("LE R2: %d" % little.reg_read(UC_ARM_REG_R2))
except UcError as e:
        print("Little endian error: %s" % e)

try:
        big = Uc(UC_ARCH_ARM, UC_MODE_ARM | UC_MODE_BIG_ENDIAN)
        big.mem_map(BASE, SIZE)
        big.mem_write(EP, CODE_BE)
        big.emu_start(EP, EP + len(CODE_BE))
        print("BE R0: %d" % big.reg_read(UC_ARM_REG_R0))
        print("BE R1: %d" % big.reg_read(UC_ARM_REG_R1))
        print("BE R2: %d" % big.reg_read(UC_ARM_REG_R2))
except UcError as e:
        print("Big endian error: %s" % e)

Outputs:

LE R0: 10
LE R1: 20
LE R2: 30
Big endian error: Invalid mode (UC_ERR_MODE)
from __future__ import print_function
from unicorn import *

try:
    big = Uc(UC_ARCH_ARM, UC_MODE_ARM | UC_MODE_BIG_ENDIAN)
except UcError as e:
    print("Big endian error: %s" % e)

Outputs:

Big endian error: Invalid mode (UC_ERR_MODE)
@aquynh
Copy link
Member

aquynh commented Dec 31, 2015

the reason is that Qemu does not support big endian for ARM, i dont know why. for Unicorn, you can look at how Mips supports big/little endian, and do the same thing to ARM. if you can do this, a pull request is welcome. otherwise, look forward to community support.

i will create a TODO list, and put this there.

@lunixbochs
Copy link
Contributor

qemu-user has an armeb target

@aquynh
Copy link
Member

aquynh commented Jan 1, 2016

this makes it even easier to port the big endian support to Unicorn.

@zachriggle
Copy link
Contributor

Any updates on this before the v1.0 release?

@aquynh
Copy link
Member

aquynh commented Feb 17, 2017 via email

@wtdcode wtdcode closed this as completed Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants