unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.33k stars 1.31k forks source link

The memory regions returned from mem_regions() are not matched with the ones allocated by mem_map() in MIPS #1877

Closed SaerTrial closed 10 months ago

SaerTrial commented 10 months ago
>>> from unicorn import *
>>> uc = Uc(UC_ARCH_MIPS, UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN)
>>> uc.mem_map(0x9d000000, 0x5000, 7)
>>> uc.mem_map(0x80000000, 0x80000, 7)
>>> for begin, size, perms in uc.mem_regions():
...     print("begin:0x{:x}, size:0x{:x}".format(begin, size))
... 
begin:0x0, size:0x7ffff
begin:0x1d000000, size:0x1d004fff
>>> uc = Uc(UC_ARCH_ARM, UC_MODE_THUMB | UC_MODE_MCLASS | UC_MODE_LITTLE_ENDIAN)
>>> uc.mem_map(0x9d000000, 0x5000, 7)
>>> uc.mem_map(0x80000000, 0x80000, 7)
>>> for begin, size, perms in uc.mem_regions():
...     print("begin:0x{:x}".format(begin))
... 
begin:0x80000000, size:0x8007ffff
begin:0x9d000000, size:0x9d004fff
PhilippTakacs commented 10 months ago

Are you using the master (or latest release) or the dev branch?

SaerTrial commented 10 months ago

The version of unicorn is 2.0.1

SaerTrial commented 10 months ago

It seems like that the addresses below 0x80000000 could be allocated correctly

>>> uc = Uc(UC_ARCH_MIPS, UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN)
>>> uc.mem_map(0x1d000000, 0x5000, 7)
>>> uc.mem_map(0x3d000000, 0x4000, 7)
>>> for begin, size, perms in uc.mem_regions():
...     print("begin:0x{:x}, size:0x{:x}".format(begin, size))
... 
begin:0x1d000000, size:0x1d004fff
begin:0x3d000000, size:0x3d003fff
wtdcode commented 10 months ago

It looks like our mem_redirect hack which should be already removed in dev branch.


From: alles_carbon @.> Sent: Monday, September 4, 2023 10:00:40 PM To: unicorn-engine/unicorn @.> Cc: Subscribed @.***> Subject: Re: [unicorn-engine/unicorn] The memory regions returned from mem_regions() are not matched with the ones allocated by mem_map() in MIPS (Issue #1877)

It seems like that the addresses below 0x80000000 could be allocated correctly

`>>> uc = Uc(UC_ARCH_MIPS, UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN)

uc.mem_map(0x1d000000, 0x5000, 7) uc.mem_map(0x3d000000, 0x4000, 7) for begin, size, perms in uc.mem_regions(): ... print("begin:0x{:x}, size:0x{:x}".format(begin, size)) ... begin:0x1d000000, size:0x1d004fff begin:0x3d000000, size:0x3d003fff `

― Reply to this email directly, view it on GitHubhttps://github.com/unicorn-engine/unicorn/issues/1877#issuecomment-1705324343, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHJULO5XEU44ISMLPWOREBLXYXNIRANCNFSM6AAAAAA4KLS6VU. You are receiving this because you are subscribed to this thread.Message ID: @.***>

SaerTrial commented 10 months ago

Thanks for this hint