summaryrefslogtreecommitdiff
path: root/bcc32/mkexports.rb
blob: 3cc8e535dfd83ec3e0c16d447289b753082cbe53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!./miniruby -s

$name = $library = $description = nil

SYM = {}
STDIN.reopen(open("nul"))
ARGV.each do |obj|
  IO.foreach("|tdump -q -oiPUBDEF -oiPUBD32 #{obj.tr('/', '\\')}") do |l|
    next unless /(?:PUBDEF|PUBD32)/ =~ l
    SYM[$1] = !$2 if /'(.*?)'\s+Segment:\s+_(TEXT)?/ =~ l
  end
end

exports = []
if $name
  exports << "Name " + $name
elsif $library
  exports << "Library " + $library
end
exports << "Description " + $description.dump if $description
exports << "EXPORTS"
SYM.sort.each do |sym, is_data|
  exports << (is_data ? "#{sym} DATA" : sym)
end

if $output
  open($output, 'w') {|f| f.puts exports.join("\n")}
else
  puts exports.join("\n")
end