https://bitbucket.org/daniel_fort/magic-lantern
Raw File
Tip revision: ba26d6f5a146dd0856215a931659f14e97a64160 authored by danne on 29 April 2017, 07:11:41 UTC
Bouncyball added lj92 code (Andrew Baldwin) T o my specific ml-dng branch. Working flawlessly.
Tip revision: ba26d6f
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
#include <stub.h>

.text

HEADER

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