Class: SeccompTools::Instruction::JMP
- Defined in:
- lib/seccomp-tools/instruction/jmp.rb
Overview
Instruction jmp, an unconditional jump or a comparison of A against X or an immediate.
Jumps are always forward, jt and jf being offsets relative to the following line.
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.
-
#symbolize ⇒ [:cmp, Symbol, (:x, Integer), Integer, Integer], [:jmp, 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.
Unlike the other instructions, a conditional jump has two possible successors. On the taken branch of an equality test the state is narrowed, recording that A is known to equal the compared value.
50 51 52 53 54 55 56 |
# File 'lib/seccomp-tools/instruction/jmp.rb', line 50 def branch(state) return [[at(k), state]] if jop == :none return [[at(jt), state]] if jt == jf return [[at(jt), narrow(state)], [at(jf), state]] if jop == :== [[at(jt), state], [at(jf), state]] end |
#decompile ⇒ String
Decompile instruction.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/seccomp-tools/instruction/jmp.rb', line 15 def decompile return goto(k) if jop == :none # if jt == 0 && jf == 0 => no-op # should not happen # jt == 0 => if(!) goto jf; # jf == 0 => if() goto jt; # otherwise => if () goto jt; else goto jf; return '/* no-op */' if jt.zero? && jf.zero? return goto(jt) if jt == jf return if_str(neg: true) + goto(jf) if jt.zero? if_str + goto(jt) + (jf.zero? ? '' : " else #{goto(jf)}") end |
#symbolize ⇒ [:cmp, Symbol, (:x, Integer), Integer, Integer], [:jmp, Integer]
See Base#symbolize.
32 33 34 35 36 |
# File 'lib/seccomp-tools/instruction/jmp.rb', line 32 def symbolize return [:jmp, k] if jop == :none [:cmp, jop, src, jt, jf] end |