https://bitbucket.org/hudson/magic-lantern
Raw File
Tip revision: 35de32ede1fe8fdeb556414b6884686fe634209a authored by a1ex on 22 October 2013, 21:24:22 UTC
Close branch YMP/added-new-scan-mode-that-detects-the-afm-1373777014817.
Tip revision: 35de32e
generate_stub.rb
#!/usr/bin/env ruby
if ARGV.length < 1 then
  puts "Usage #{__FILE__} [map file]"
  exit 1
end

stubs = {}
first = nil
File.open(ARGV[0],"rb") do |file|
  file.each_line do |line|
    if line.strip =~ /\A(.*)0x00000000([0-9a-z]{8}) .*?([A-Za-z_]+)\.?o?\)?\Z/ then
      initial = $1
      loc = $2.to_i(16)
      name = $3
      if initial !~ /debug/ and !name.strip.empty? then
        stubs[name] = loc
        first = loc if first.nil? and loc>0
      end
    end
  end
end

# header

puts <<HEADER
.text

#define NSTUB(addr,name) \
	.global name; \
	name = addr

#define NILSTUB(addr,name) \
	.global name; \
	name: BX LR

HEADER

stubs.sort.each do |v,k|
  puts "NSTUB( 0x#{k.to_s(16)}, #{v} )" if k>first
end
back to top