Class: SeccompTools::Instruction::LD
- Defined in:
- lib/seccomp-tools/instruction/ld.rb
Overview
Instruction ld, loads a value into the accumulator register A.
The value can be an immediate, a word of struct seccomp_data, or a slot of the scratch
memory. LDX inherits from this class and targets the X register instead.
Constant Summary
Constants included from Const::BPF
Const::BPF::ACTION, Const::BPF::COMMAND, Const::BPF::JMP, Const::BPF::MISCOP, Const::BPF::MODE, Const::BPF::OP, Const::BPF::PR_SET_SECCOMP, Const::BPF::SECCOMP_MODE_FILTER, Const::BPF::SECCOMP_MODE_STRICT, Const::BPF::SECCOMP_RET_ACTION_FULL, Const::BPF::SECCOMP_RET_DATA, Const::BPF::SECCOMP_SET_MODE_FILTER, Const::BPF::SECCOMP_SET_MODE_STRICT, Const::BPF::SIZEOF_SECCOMP_DATA, Const::BPF::SRC
Instance Method Summary collapse
-
#branch(state) ⇒ Array<(Integer, Symbolic::State)>
See Base#branch.
-
#decompile ⇒ String
Decompile instruction.
-
#reg ⇒ String
Name of the register being loaded into.
-
#symbolize ⇒ [:ld, Symbol, {rel: Symbol, val: Integer}]
See Base#symbolize.
Methods inherited from Base
Methods included from Const::BPF
Constructor Details
This class inherits a constructor from SeccompTools::Instruction::Base
Instance Method Details
#branch(state) ⇒ Array<(Integer, Symbolic::State)>
See Base#branch.
47 48 49 50 51 52 53 54 55 |
# File 'lib/seccomp-tools/instruction/ld.rb', line 47 def branch(state) v = load_val val = case v[:rel] when :immi then Symbolic::Expr.imm(v[:val]) when :mem then state.mem[v[:val]] when :data then Symbolic::Expr.data(v[:val]) end [[line + 1, reg == 'X' ? state.with(x: val) : state.with(a: val)]] end |
#decompile ⇒ String
Decompile instruction.
17 18 19 20 21 22 23 24 |
# File 'lib/seccomp-tools/instruction/ld.rb', line 17 def decompile ret = "#{reg} = " _, _reg, type = symbolize return ret + type[:val].to_s if type[:rel] == :immi return ret + "mem[#{type[:val]}]" if type[:rel] == :mem ret + seccomp_data_str end |
#reg ⇒ String
Name of the register being loaded into.
38 39 40 |
# File 'lib/seccomp-tools/instruction/ld.rb', line 38 def reg 'A' end |
#symbolize ⇒ [:ld, Symbol, {rel: Symbol, val: Integer}]
See Base#symbolize.
30 31 32 33 |
# File 'lib/seccomp-tools/instruction/ld.rb', line 30 def symbolize type = load_val [:ld, reg.downcase.to_sym, type] end |