1 my $show_module_name = 1;
3 my $strip_leading_underscore = 0;
5 my %target_exports = ();
6 my %local_exports = ();
8 sub build_target_exports_list
($)
12 print STDERR
"Processing defs from file [$fn]\n";
14 open(SP
, '-|', "dumpbin /exports \"".$fn."\"") or die "Can't open pipe for $fn";
18 # 112 6F 00071CDC krb5_encrypt_size
20 /^ +([[:digit:]]+)\s+[[:xdigit:]]+\s[[:xdigit:]]{8,}\s+(\S+)(?:| = (\S*))$/ && do {
21 my ($ordinal, $symbol, $in) = ($1, $2, $3);
23 if ($in eq "") { $in = $symbol };
24 $target_exports{$symbol} = $in;
31 # Dump all symbols for the given dll file that are defined and have
34 sub build_glue_exports_list
($)
38 print STDERR
"Opening dump of DLL [$fn]\n";
40 open(SP
, '-|', "dumpbin /exports \"".$fn."\"") or die "Can't open pipe for $fn";
44 # 112 6F 00071CDC krb5_encrypt_size
46 /^ +([[:digit:]]+)\s+[[:xdigit:]]+\s[[:xdigit:]]{8,}\s+(\S+)(?:| = (\S*))$/ && do {
47 my ($ordinal, $symbol, $in) = ($1, $2, $3);
49 if ($strip_leading_underscore && $symbol =~ /_(.*)/) {
52 if (exists $local_exports{$symbol}) {
54 print " = ".$local_exports{$symbol};
55 if ($in ne $local_exports{$symbol} and $in ne "") {
56 print STDERR
"Incorrect calling convention for local $symbol\n";
57 print STDERR
" ".$in." != ".$local_exports{$symbol}."\n";
59 print "\t@".$ordinal."\n";
60 } elsif (exists $local_exports{"SHIM_".$symbol}) {
62 print " = ".$local_exports{"SHIM_".$symbol};
63 print "\t@".$ordinal."\n";
64 } elsif (exists $target_exports{$symbol}) {
66 print " = ".$module_name;
67 if ($in ne $target_exports{$symbol} and $in ne "") {
68 print STDERR
"Incorrect calling convention for $symbol\n";
69 print STDERR
" ".$in." != ".$target_exports{$symbol}."\n";
71 my $texp = $target_exports{$symbol};
72 if ($texp =~ /^_([^@]+)$/) { $texp = $1; }
73 print $texp."\t@".$ordinal."\n";
75 print STDERR
"Symbol not found: $symbol\n";
83 sub build_local_exports_list
($)
87 print STDERR
"Opening dump of object [$fn]\n";
89 open(SP
, '-|', "dumpbin /symbols \"".$fn."\"") or die "Can't open pipe for $fn";
93 # 009 00000010 SECT3 notype () External | _remove_error_table@4
94 m/^[[:xdigit:]]{3,}\s[[:xdigit:]]{8,}\s(\w+)\s+\w*\s+(?:\(\)| )\s+(\w+)\s+\|\s+(\S+)$/ && do {
95 my ($section, $visibility, $symbol) = ($1, $2, $3);
97 if ($section ne "UNDEF" && $visibility eq "External") {
99 my $exp_name = $symbol;
101 if ($symbol =~ m/^_(\w+)(?:@.*|)$/) {
105 if ($symbol =~ m/^_([^@]+)$/) {
109 $local_exports{$exp_name} = $symbol;
121 if ($fn =~ m/\.dll$/i) {
122 build_glue_exports_list
($fn);
123 } elsif ($fn =~ m/\.obj$/i) {
124 build_local_exports_list
($fn);
126 die "File type not recognized for $fn.";
130 sub use_response_file
($)
134 open (RF
, '<', $fn) or die "Can't open response file $fn";
144 print "; This is a generated file. Do not modify directly.\n";
150 $module_name = $1.".";
155 build_target_exports_list
($1);
160 use_response_file
($1);