Class: SeccompTools::Instruction::JMP
- Defined in:
- lib/seccomp-tools/instruction/jmp.rb
Overview
Instruction jmp.
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_RET_ACTION_FULL, Const::BPF::SECCOMP_RET_DATA, Const::BPF::SECCOMP_SET_MODE_FILTER, Const::BPF::SIZEOF_SECCOMP_DATA, Const::BPF::SRC
Instance Method Summary collapse
-
#branch(context) ⇒ Array<(Integer, Context)>
See Base#branch.
-
#decompile ⇒ Object
Decompile instruction.
-
#symbolize ⇒ [:cmp, Symbol, (:x, Integer), Integer, Integer], [:jmp, Integer]
See Base#symbolize.
Methods inherited from Base
Constructor Details
This class inherits a constructor from SeccompTools::Instruction::Base
Instance Method Details
#branch(context) ⇒ Array<(Integer, Context)>
See Base#branch.
36 37 38 39 40 41 42 |
# File 'lib/seccomp-tools/instruction/jmp.rb', line 36 def branch(context) return [[at(k), context]] if jop == :none return [[at(jt), context]] if jt == jf return [[at(jt), context.dup.eql!(src)], [at(jf), context]] if jop == :== [[at(jt), context], [at(jf), context]] end |
#decompile ⇒ Object
Decompile instruction.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/seccomp-tools/instruction/jmp.rb', line 11 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.
26 27 28 29 30 |
# File 'lib/seccomp-tools/instruction/jmp.rb', line 26 def symbolize return [:jmp, k] if jop == :none [:cmp, jop, src, jt, jf] end |