summaryrefslogtreecommitdiffstats
path: root/bcc32/mkexports.rb
blob: 888ab2e2a631b0d189c7a1963711a328a12e7364 (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
#!./miniruby -s

$:.unshift(File.expand_path("../..", __FILE__))
require 'win32/mkexports'

class Exports::Bcc < Exports
  def forwarding(internal, export)
    internal[/\A_?/]+export
  end

  def each_line(objs, &block)
    objs.each do |obj|
      opt = /\.(?:so|dll)\z/i =~ obj ? "-ee" : "-oiPUBDEF -oiPUBD32"
      IO.foreach("|tdump -q #{opt} #{obj.tr('/', '\\')} < nul", &block)
    end
  end

  def each_export(objs)
    objdump(objs) do |l|
      next unless /(?:PUBDEF|PUBD32|EXPORT)/ =~ l
      yield $1 if /'(.*?)'/ =~ l
    end
    yield "_strcasecmp", "_stricmp"
    yield "_strncasecmp", "_strnicmp"
  end
end