node/lib/metasm/metasm/disassemble_api.rb
def load_map(str, off=0)
		str = File.read(str) rescue nil if not str.index("\n")
		sks = @sections.keys.sort
		seen = {}
		str.each_line { |l|
			case l.strip
			when /^([0-9A-F]+)\s+(\w+)\s+(\w+)/i	# kernel.map style
				addr = $1.to_i(16)+off
				set_label_at(addr, $3, false, !seen[addr])
				seen[addr] = true
			when /^([0-9A-F]+):([0-9A-F]+)\s+([a-z_]\w+)/i	# IDA style
				# we do not have section load order, let's just hope that the addresses are sorted (and sortable..)
				#  could check the 1st part of the file, with section sizes, but it is not very convenient
				# the regexp is so that we skip the 1st part with section descriptions
				# in the file, section 1 is the 1st section ; we have an additionnal section (exe header) which fixes the 0-index
				addr = sks[$1.to_i(16)] + $2.to_i(16) + off
				set_label_at(addr, $3, false, !seen[addr])
				seen[addr] = true
			end
		}
	end
# loads a map file (addr => symbol)
# off is an optionnal offset to add to every address found (for eg rebased binaries)
# understands:
#  standard map files (eg linux-kernel.map: <addr> <type> <name>, e.g. 'c01001ba t setup_idt')
#  ida map files (<sectionidx>:<sectionoffset> <name>)
# arg is either the map itself or the filename of the map (if it contains no newline)
loads a map file (addr => symbol)
off is an optionnal offset to add to every address found (for eg rebased binaries)
understands:
standard map files
ida map files (: )
arg is either the map itself or the filename of the map (if it contains no newline)
loads a map file ( addr = > symbol ) off is an optionnal offset to add to every address found ( for eg rebased binaries ) understands : standard map files ida map files ( : ) arg is either the map itself or the filename of the map ( if it contains no newline )
def load_map(str, off=0)
		str = File.read(str) rescue nil if not str.index("\n")
		sks = @sections.keys.sort
		seen = {}
		str.each_line { |l|
			case l.strip
			when /^([0-9A-F]+)\s+(\w+)\s+(\w+)/i	
				addr = $1.to_i(16)+off
				set_label_at(addr, $3, false, !seen[addr])
				seen[addr] = true
			when /^([0-9A-F]+):([0-9A-F]+)\s+([a-z_]\w+)/i	
				addr = sks[$1.to_i(16)] + $2.to_i(16) + off
				set_label_at(addr, $3, false, !seen[addr])
				seen[addr] = true
			end
		}
	end
def load_map ( str , off = 0 ) str = File . read ( str ) rescue nil if not str . index ( "\n" ) sks = @sections . keys . sort seen = { } str . each_line { | l | case l . strip when / ^([0-9A-F]+) \s +( \w +) \s +( \w +) /i addr = $1 . to_i ( 16 ) + off set_label_at ( addr , $3 , false , ! seen [ addr ] ) seen [ addr ] = true when / ^([0-9A-F]+):([0-9A-F]+) \s +([a-z_] \w +) /i addr = sks [ $1 . to_i ( 16 ) ] + $2 . to_i ( 16 ) + off set_label_at ( addr , $3 , false , ! seen [ addr ] ) seen [ addr ] = true end } end
loads a map file (addr => symbol)
off is an optionnal offset to add to every address found (for eg rebased binaries)
understands:
standard map files (eg linux-kernel.map: <addr> <type> <name>, e.g.
loads a map file ( addr = > symbol ) off is an optionnal offset to add to every address found ( for eg rebased binaries ) understands : standard map files ( eg linux - kernel . map : <addr > <type > <name > e . g .
# kernel.map style # IDA style # we do not have section load order, let's just hope that the addresses are sorted (and sortable..) #  could check the 1st part of the file, with section sizes, but it is not very convenient # the regexp is so that we skip the 1st part with section descriptions # in the file, section 1 is the 1st section ; we have an additionnal section (exe header) which fixes the 0-index
str
off