Class: SeccompTools::Instruction::ST

Inherits:
LD
  • Object
show all
Defined in:
lib/seccomp-tools/instruction/st.rb

Overview

Instruction st, stores the accumulator register A into a slot of the scratch memory.

STX inherits from this class and stores the X register instead.

Direct Known Subclasses

STX

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

Methods inherited from LD

#reg

Methods inherited from Base

#initialize, #invalid

Methods included from Const::BPF

action_label

Constructor Details

This class inherits a constructor from SeccompTools::Instruction::Base

Instance Method Details

#branch(state) ⇒ Array<(Integer, Symbolic::State)>

Parameters:

Returns:

  • (Array<(Integer, Symbolic::State)>)

    Always the next line, with the register's value recorded in the scratch slot.



30
31
32
33
34
# File 'lib/seccomp-tools/instruction/st.rb', line 30

def branch(state)
  mem = state.mem.dup
  mem[k] = reg == 'X' ? state.x : state.a
  [[line + 1, state.with(mem:)]]
end

#decompileString

Decompile instruction.

Returns:

  • (String)

    The store as assembly, e.g. "mem[0] = A".



14
15
16
# File 'lib/seccomp-tools/instruction/st.rb', line 14

def decompile
  "mem[#{k}] = #{reg}"
end

#symbolize[:st, (:a, :x), Integer]

Returns:

  • ([:st, (:a, :x), Integer])

    The source register and the index of the target memory slot.



21
22
23
# File 'lib/seccomp-tools/instruction/st.rb', line 21

def symbolize
  [:st, reg.downcase.to_sym, k]
end