@@ -7,7 +7,7 @@ module RbConfig
77end
88
99class Exports
10- PrivateNames = /(?:Init_|InitVM_|ruby_static_id_ |threadptr|_ec_|DllMain\b )/
10+ PrivateNames = /(?:\A Init_| \A InitVM_| \A ruby_static_id_ |threadptr|_ec_|DllMain\b )/
1111
1212 def self . create ( *args , &block )
1313 platform = RUBY_PLATFORM
@@ -96,20 +96,57 @@ def symbols()
9696
9797class Exports ::Mswin < Exports
9898 def each_line ( objs , &block )
99- IO . popen ( %w" dumpbin -symbols -exports " + objs ) do |f |
100- f . each ( &block )
99+ # IO.popen(%w"dumpbin -linkermember:1" + objs) do |f|
100+ objs . each do |o |
101+ open ( o ) do |f |
102+ f . each ( &block )
103+ end
101104 end
102105 end
103106
104107 def each_export ( objs )
105108 noprefix = ( $arch ||= nil and /^(sh|i\d 86)/ !~ $arch)
106109 objs = objs . collect { |s | s . tr ( '/' , '\\' ) }
107- filetype = nil
110+ libname = RbConfig ::CONFIG [ "LIBRUBY_A" ]
111+ libname [ /\. lib$/ ] = ""
112+ publics = false
113+ started = false
114+ finished = false
108115 objdump ( objs ) do |l |
109- if ( filetype = l [ /^File Type: (.+)/ , 1 ] ) ..( /^\f / =~ l )
110- case filetype
116+ next if finished
117+ l . chomp!
118+ finished ||= started && l == ""
119+ started ||= publics && l != ""
120+ publics ||= /^\s +Address\s +Publics by Value\s +Rva\+ Base\s +Lib:Object$/ . match? ( l )
121+
122+ if started
123+ /\A \s +\h +:\h +\s +(#{ noprefix ? "" : "_" } [a-zA-Z_]\w +#{ noprefix ? "" : /(?:@\d +)?/ } )\s +\h +(?:\s +(f)\s +|\s *)(?:#{ libname } :[\w -]+\. [\w -]+|<common>)\z / . match ( l ) do |m |
124+ sym , f = m [ 1 ] , m [ 2 ]
125+ if !noprefix && /^[@_]/ . match? ( sym ) && !/@\d +$/ . match? ( sym )
126+ sym . sub! ( /^[@_]/ , '' )
127+ end
128+ next if /\A _[^@]*\z |#{ PrivateNames } /o . match? ( sym )
129+ next if /@[[:xdigit:]]{8,32}\z / . match? ( sym )
130+ yield sym , f != "f"
131+ end
132+ end
133+ next
134+
135+ symbols ||= /^\s *\d +\s public symbols$/ . match? l
136+ symbols &&= !( /^Archive member name/ . match? l )
137+ if symbols
138+ l . chomp!
139+ next if l == ""
140+
141+ /^\s *\h +\s (#{ noprefix ? "" : "_" } [a-zA-Z_]\w +)$/ . match ( l ) do |m |
142+ is_data = ""
143+ next if /^_?#{ PrivateNames } /o . match? ( m [ 1 ] )
144+ yield m [ 1 ] , nil
145+ end
146+ next
147+
148+ case symbols
111149 when /OBJECT/ , /LIBRARY/
112- l . chomp!
113150 next if ( /^ .*\( pick any\) $/ =~ l ) ...true
114151 next if /^[[:xdigit:]]+ 0+ UNDEF / =~ l
115152 next unless /External/ =~ l
0 commit comments