Skip to content
Browse files

Added draft support for code analyzers

Can resolve symbol name for BL;
Can map LDR'ed data
  • Loading branch information...
1 parent 67388ac commit 540b398b60985108687bc6d1dab3f48bc8165966 @farcaller farcaller committed Apr 17, 2012
View
1 lib/indis-arm.rb
@@ -18,6 +18,7 @@
require 'indis-arm/version'
require 'indis-arm/code_parser'
+require 'indis-arm/analyzer'
module Indis
# Indis::ARM provides instruction parser for ARM and Thumb instruction sets.
View
17 lib/indis-arm/analyzer.rb
@@ -0,0 +1,17 @@
+module Indis
+ module ARM
+ module Analyzer
+
+ class Analyzer
+ def initialize(target, evt)
+ @target = target
+ target.subscribe_for_event(evt, self)
+ end
+ end
+
+ end
+ end
+end
+
+require 'indis-arm/analyzer/bl_analyzer'
+require 'indis-arm/analyzer/ldr_lit_analyzer'
View
20 lib/indis-arm/analyzer/bl_analyzer.rb
@@ -0,0 +1,20 @@
+module Indis
+ module ARM
+ module Analyzer
+
+ class BLAnalyzer < Analyzer
+
+ def initialize(target)
+ super target, :instruction_mapped
+ end
+
+ def instruction_mapped(instr)
+ return unless instr.class.name == :BL
+ sym = @target.resolve_symbol_at_address(instr.branch_address)
+ instr.tags[:branch_to_sym] = sym if sym
+ end
+ end
+
+ end
+ end
+end
View
25 lib/indis-arm/analyzer/ldr_lit_analyzer.rb
@@ -0,0 +1,25 @@
+require 'indis-core/data_entity'
+
+module Indis
+ module ARM
+ module Analyzer
+
+ class LDRLitAnalyzer < Analyzer
+
+ def initialize(target)
+ super target, :instruction_mapped
+ end
+
+ def instruction_mapped(instr)
+ return unless instr.class.name == :LDR && instr.class.encoding == :A1_lit
+
+ datab = Indis::DataEntity.new(instr.vmaddr+instr.imm+8, 4, @target.vmmap)
+ @target.vmmap.map!(datab)
+ instr.tags[:value] = datab
+ datab.tags[:loaded_by] = instr
+ end
+ end
+
+ end
+ end
+end

0 comments on commit 540b398

Please sign in to comment.
Something went wrong with that request. Please try again.