return _REG_NAMES_x86[regnum]
elif machine_arch == 'x64':
return _REG_NAMES_x64[regnum]
+ elif machine_arch == 'AArch64':
+ return _REG_NAMES_AArch64[regnum]
elif default:
return 'r%s' % regnum
else:
'mxcsr', 'fcw', 'fsw'
]
+# https://developer.arm.com/docs/ihi0057/c/dwarf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4#id24
+_REG_NAMES_AArch64 = [
+ 'x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8', 'x9',
+ 'x10', 'x11', 'x12', 'x13', 'x14', 'x15', 'x16', 'x17', 'x18', 'x19',
+ 'x20', 'x21', 'x22', 'x23', 'x24', 'x25', 'x26', 'x27', 'x28', 'x29',
+ 'x30', 'sp'
+]
+
class ExprDumper(object):
""" A dumper for DWARF expressions that dumps a textual
from ..common.utils import elf_assert, struct_parse
from .sections import Section
from .enums import (
- ENUM_RELOC_TYPE_i386, ENUM_RELOC_TYPE_x64, ENUM_RELOC_TYPE_MIPS, ENUM_RELOC_TYPE_ARM, ENUM_D_TAG)
+ ENUM_RELOC_TYPE_i386, ENUM_RELOC_TYPE_x64, ENUM_RELOC_TYPE_MIPS,
+ ENUM_RELOC_TYPE_ARM, ENUM_RELOC_TYPE_AARCH64, ENUM_D_TAG)
class Relocation(object):
raise ELFRelocationError(
'Unexpected RELA relocation for ARM: %s' % reloc)
recipe = self._RELOCATION_RECIPES_ARM.get(reloc_type, None)
+ elif self.elffile.get_machine_arch() == 'AArch64':
+ recipe = self._RELOCATION_RECIPES_AARCH64.get(reloc_type, None)
if recipe is None:
raise ELFRelocationError(
calc_func=_arm_reloc_calc_sym_plus_value_pcrel),
}
+ _RELOCATION_RECIPES_AARCH64 = {
+ ENUM_RELOC_TYPE_AARCH64['R_AARCH64_ABS64']: _RELOCATION_RECIPE_TYPE(
+ bytesize=8, has_addend=True, calc_func=_reloc_calc_sym_plus_addend),
+ ENUM_RELOC_TYPE_AARCH64['R_AARCH64_ABS32']: _RELOCATION_RECIPE_TYPE(
+ bytesize=4, has_addend=True, calc_func=_reloc_calc_sym_plus_addend),
+ ENUM_RELOC_TYPE_AARCH64['R_AARCH64_PREL32']: _RELOCATION_RECIPE_TYPE(
+ bytesize=4, has_addend=True,
+ calc_func=_reloc_calc_sym_plus_addend_pcrel),
+ }
+
# https://dmz-portal.mips.com/wiki/MIPS_relocation_types
_RELOCATION_RECIPES_MIPS = {
ENUM_RELOC_TYPE_MIPS['R_MIPS_NONE']: _RELOCATION_RECIPE_TYPE(