Sha256: 6e4f968364a1a6212a214ad026cdaec2a348bfcfd1bfbc958d568df00d0a1bc5

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'indis-core/target'
require 'indis-macho'
require 'indis-arm/code_parser'

describe Indis::ARM::CodeParser do
  it "should decode arm instructions in given section" do
    t = Indis::Target.new('spec/fixtures/single-object.o')
    t.load
    
    section = t.segments.find { |seg| seg.name == '__TEXT' }.sections.find { |sect| sect.name == '__text' }
    
    code_parser = Indis::ARM::CodeParser.new(t)
    
    code_parser.reparse_section(section)
    
    sm = t.vmmap[section.to_vmrange]
    
    sm.each_with_index do |b, idx|
      break if idx >= section.vmsize

      if idx % 4 == 0
        b.should be_a(Indis::Entity)
        b.should be_a(Indis::ARM::Instruction)
      else
        b.should be_nil
      end
    end
  end
  
  it "should parse known instructions" do
    code_parser = Indis::ARM::CodeParser.new(double("Target", vmmap: double("VMMap")))
    
    i = code_parser.instance_eval { build_instruction(0, 0xe92d4080) }
    i.should_not be_a(Indis::ARM::UnknownInstruction)
  end
  
  it "should load instructions" do
    Indis::ARM::CodeParser.load_instructions
    expect { Indis::ARM.const_get('PUSHInstruction_A1') }.not_to raise_error
  end
  
  it "should honor NotThisInstructionError" do
    code_parser = Indis::ARM::CodeParser.new(double("Target", vmmap: double("VMMap")))
    
    i = code_parser.instance_eval { build_instruction(0, 0xe59f0024) }
    i.class.should == Indis::ARM::LDRInstruction_A1_lit
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
indis-arm-0.3.1 spec/indis-arm/code_parser_spec.rb
indis-arm-0.3.0 spec/indis-arm/code_parser_spec.rb