Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions archinfo/arch_aarch64.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
class ArchAArch64(Arch):
def __init__(self, endness=Endness.LE):
super().__init__(endness)
if _unicorn is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this seem like the best place to have put this?

unicorn_sp = _unicorn.arm64_const.UC_ARM64_REG_SP
self.uc_regs["xsp"] = unicorn_sp
self.vex_to_unicorn_map[self.sp_offset] = (unicorn_sp, self.bytes)
if endness == Endness.BE:
self.pcode_id = "AARCH64:BE:64:v8A"
self.ida_processor = "armb"
Expand Down
14 changes: 14 additions & 0 deletions tests/test_aarch64.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from __future__ import annotations

import pytest

from archinfo import ArchAArch64


def test_unicorn_stack_pointer_mapping():
unicorn = pytest.importorskip("unicorn")
arch = ArchAArch64()
unicorn_sp = unicorn.arm64_const.UC_ARM64_REG_SP

assert arch.uc_regs["xsp"] == unicorn_sp
assert arch.vex_to_unicorn_map[arch.sp_offset] == (unicorn_sp, arch.bytes)