AArch64

Instruction

class Instruction : public LIEF::assembly::Instruction

This class represents an AArch64 instruction.

Public Types

using operands_it = iterator_range<Operand::Iterator>

Public Functions

OPCODE opcode() const

The instruction opcode as defined in LLVM.

operands_it operands() const

Iterator over the operands of the current instruction.

virtual ~Instruction() override = default

Public Static Functions

static bool classof(const assembly::Instruction *inst)

True if inst is an effective instance of aarch64::Instruction.

Opcodes

See LIEF::assembly::aarch64::OPCODE in include/asm/aarch64/opcodes.hpp

Operands

class Operand

This class represents an operand for an AArch64 instruction.

Subclassed by LIEF::assembly::aarch64::operands::Immediate, LIEF::assembly::aarch64::operands::Memory, LIEF::assembly::aarch64::operands::PCRelative, LIEF::assembly::aarch64::operands::Register

Public Functions

std::string to_string() const

Pretty representation of the operand.

template<class T>
inline const T *as() const

This function can be used to down cast an Operand instance:

std::unique_ptr<assembly::aarch64::Operand> op = ...;
if (const auto* imm = inst->as<assembly::aarch64::operands::Immediate>()) {
  const int64_t value = imm->value();
}
virtual ~Operand()

Friends

inline friend std::ostream &operator<<(std::ostream &os, const Operand &op)
class Iterator : public LIEF::iterator_facade_base<Iterator, std::forward_iterator_tag, std::unique_ptr<Operand>, std::ptrdiff_t, Operand*, std::unique_ptr<Operand>>

Forward iterator that outputs aarch64 Operand as std::unique_ptr

Public Types

using implementation = details::OperandIt

Public Functions

Iterator()
Iterator(std::unique_ptr<details::OperandIt> impl)
Iterator(const Iterator&)
Iterator &operator=(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator &operator=(Iterator&&) noexcept
~Iterator()
Iterator &operator++()
std::unique_ptr<Operand> operator*() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)

Immediate

class Immediate : public LIEF::assembly::aarch64::Operand

This class represents an immediate operand (i.e. a constant)

For instance:

mov x0, #8;
         |
         +---> Immediate(8)

Public Functions

int64_t value() const

The constant value wrapped by this operand.

~Immediate() override = default

Public Static Functions

static bool classof(const Operand *op)

Register

class Register : public LIEF::assembly::aarch64::Operand

This class represents a register operand.

mrs     x0, TPIDR_EL0
        |   |
 +------+   +-------+
 |                  |
 v                  v
 REG              SYSREG

Public Functions

reg_t value() const

The effective register as either: a REG or a SYSREG.

~Register() override = default

Public Static Functions

static bool classof(const Operand *op)
struct reg_t

Public Types

enum class TYPE

Enum type used to discriminate the anonymous union.

Values:

enumerator NONE = 0
enumerator SYSREG

The union holds a sysreg attribute.

enumerator REG

The union holds the reg attribute.

Public Members

REG reg = REG::NoRegister
SYSREG sysreg
union LIEF::assembly::aarch64::operands::Register::reg_t
TYPE type = TYPE::NONE

Memory

class Memory : public LIEF::assembly::aarch64::Operand

This class represents a memory operand.

ldr     x0, [x1, x2, lsl #3]
             |   |    |
+------------+   |    +--------+
|                |             |
v                v             v
Base            Reg Offset    Shift

Public Types

enum class SHIFT : int32_t

Values:

enumerator UNKNOWN = 0
enumerator LSL
enumerator UXTX
enumerator UXTW
enumerator SXTX
enumerator SXTW

Public Functions

REG base() const

The base register.

For str x3, [x8, #8] it would return x8.

offset_t offset() const

The addressing offset.

It can be either:

  • A register (e.g. ldr x0, [x1, x3])

  • An offset (e.g. ldr x0, [x1, #8])

shift_info_t shift() const

Shift information.

For instance, for ldr x1, [x2, x3, lsl #3] it would return a SHIFT::LSL with a shift_info_t::value set to 3.

~Memory() override = default

Public Static Functions

static bool classof(const Operand *op)
struct offset_t

Wraps a memory offset as an integer offset or as a register offset.

Public Types

enum class TYPE

Enum type used to discriminate the anonymous union.

Values:

enumerator NONE = 0
enumerator REG

The union holds the REG attribute.

enumerator DISP

The union holds the displacement attribute (int64_t)

Public Members

REG reg

Register offset.

int64_t displacement = 0

Integer offset.

union LIEF::assembly::aarch64::operands::Memory::offset_t
TYPE type = TYPE::NONE
struct shift_info_t

This structure holds shift info (type + value)

Public Members

SHIFT type = SHIFT::UNKNOWN
int8_t value = -1

PCRelative

class PCRelative : public LIEF::assembly::aarch64::Operand

This class represents a PC-relative operand.

ldr x0, #8
        |
        v
 PC Relative operand

Public Functions

int64_t value() const

The effective value that is relative to the current pc register.

~PCRelative() override = default

Public Static Functions

static bool classof(const Operand *op)