Class: SeccompTools::Instruction::ALU
- Defined in:
- lib/seccomp-tools/instruction/alu.rb
Overview
Instruction alu, performs an arithmetic or bitwise operation on the accumulator register A.
The right operand is either the X register or the immediate k.
Constant Summary collapse
- OP_SYM =
Mapping from name to operator.
{ add: :+, sub: :-, mul: :*, div: :/, or: :|, and: :&, lsh: :<<, rsh: :>>, # neg: :-, # should not be invoked # mod: :%, # the kernel rejects BPF_MOD (see Const::BPF::OP), so it never reaches here xor: :^ }.freeze
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.
-
#symbolize ⇒ [:alu, Symbol, (:x, Integer, nil)]
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.
49 50 51 |
# File 'lib/seccomp-tools/instruction/alu.rb', line 49 def branch(state) [[line + 1, state.with(a: Symbolic::Expr.opaque)]] end |
#decompile ⇒ String
Decompile instruction.
28 29 30 31 32 |
# File 'lib/seccomp-tools/instruction/alu.rb', line 28 def decompile return 'A = -A' if op == :neg "A #{op_sym}= #{src_str}" end |
#symbolize ⇒ [:alu, Symbol, (:x, Integer, nil)]
See Base#symbolize.
38 39 40 41 42 |
# File 'lib/seccomp-tools/instruction/alu.rb', line 38 def symbolize return [:alu, :neg, nil] if op == :neg [:alu, op_sym, src] end |