Sha256: 59df5223bb5d0360735c1fa45b060f88c3f47800427dced322b3012afc42dad5

Contents?: true

Size: 852 Bytes

Versions: 4

Compression:

Stored size: 852 Bytes

Contents

#    This file is part of Metasm, the Ruby assembly manipulation suite
#    Copyright (C) 2006-2009 Yoann GUILLOT
#
#    Licence is LGPL, see LICENCE in the top-level directory


# metasm dasm plugin
# walks all disassembled instructions referencing an address
# if the address is a label, update the instruction to use the label
# esp. useful after a disassemble_fast, with a .map file

def addrtolabel
	bp = prog_binding.invert
	@decoded.each_value { |di|
		next if not di.kind_of?(DecodedInstruction)
		di.each_expr { |e|
			next unless e.kind_of?(Expression)
			if l = bp[e.lexpr]
				add_xref(e.lexpr, Xref.new(:addr, di.address))
				e.lexpr = Expression[l]
			end
			if l = bp[e.rexpr]
				add_xref(e.rexpr, Xref.new(:addr, di.address))
				e.rexpr = (e.lexpr ? Expression[l] : l)
			end
		}
	}
	nil
end

if gui
	addrtolabel
	gui.gui_update
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
metasm-1.0.5 samples/dasm-plugins/imm2off.rb
metasm-1.0.4 samples/dasm-plugins/imm2off.rb
metasm-1.0.3 samples/dasm-plugins/imm2off.rb
metasm-1.0.2 samples/dasm-plugins/imm2off.rb