X86/x86-64¶
Instruction¶
- class Instruction : public LIEF::assembly::Instruction¶
This class represents a x86/x86-64 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.
- bool has_lock_prefix() const¶
True if this instruction has a
LOCKprefix.
- bool is_lockable() const¶
True if the
LOCKprefix is architecturally valid on this instruction.
- bool is_atomic() const¶
True if this instruction executes as an atomic read-modify-write.
- std::unique_ptr<Instruction> lock() const¶
Re-encoded copy of this instruction with a
LOCKprefix added.If the instruction already has a
LOCKprefix, it returns a plain copy.
- std::unique_ptr<Instruction> unlock() const¶
Re-encoded copy of this instruction with the
LOCKprefix removed.If the instruction does not have a
LOCKprefix, it returns a plain copy or a nullptr if theLOCKsemantic can’t be removed.
- virtual ~Instruction() override = default¶
Public Static Functions
- static bool classof(const assembly::Instruction *inst)¶
True if
instis an effective instance of x86::Instruction.
- using operands_it = iterator_range<Operand::Iterator>¶
Opcodes¶
See LIEF::assembly::x86::OPCODE in include/asm/x86/opcodes.hpp
Operands¶
- class Operand¶
This class represents an operand for an x86/x86-64 instruction.
Subclassed by LIEF::assembly::x86::operands::Immediate, LIEF::assembly::x86::operands::Memory, LIEF::assembly::x86::operands::PCRelative, LIEF::assembly::x86::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::x86::Operand> op = ...; if (const auto* memory = inst->as<assembly::x86::operands::Memory>()) { const assembly::x86::REG base = memory->base(); }
- virtual ~Operand()¶
- std::string to_string() const¶
Immediate¶
Register¶
Memory¶
- class Memory : public LIEF::assembly::x86::Operand¶
This class represents a memory operand.
For instance:
movq xmm3, qword ptr [rip + 823864]; | | Memory | +-----------+-----------+ | | | Base: rip Scale: 1 Displacement: 823864Public Functions
- REG base() const¶
The base register.
For
lea rdx, [rip + 244634]it would returnrip
- REG scaled_register() const¶
The scaled register.
For
mov rdi, qword ptr [r13 + 8*r14]it would returnr14
- REG segment_register() const¶
The segment register associated with the memory operation.
For
mov eax, dword ptr gs:[0]is would returngs
- uint64_t scale() const¶
The scale value associated with the scaled_register():
For
mov rdi, qword ptr [r13 + 8*r14]it would return8
- int64_t displacement() const¶
The displacement value.
For
call qword ptr [rip + 248779]it would return248779
- ~Memory() override = default¶
- REG base() const¶