1
########################################################################
3
# Copyright (c) 2010, Secure Endpoints Inc.
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions
10
# - Redistributions of source code must retain the above copyright
11
# notice, this list of conditions and the following disclaimer.
13
# - Redistributions in binary form must reproduce the above copyright
14
# notice, this list of conditions and the following disclaimer in
15
# the documentation and/or other materials provided with the
18
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
# POSSIBILITY OF SUCH DAMAGE.
32
my $show_module_name = 1;
34
my $strip_leading_underscore = 0;
36
# Dump all symbols for the given object file that are defined and have
39
sub dump_symbols_for_file($)
43
print STDERR "Opening dump of object [$fn]\n";
45
open(SP, '-|', "dumpbin /symbols \"".$fn."\"") or die "Can't open pipe for $fn";
49
# 008 00000000 SECT3 notype () External | _encode_AccessDescription
51
/^[[:xdigit:]]{3,}\s[[:xdigit:]]{8,}\s(\w+)\s+\w*\s+(\(\)| )\s+(\w+)\s+\|\s+([0-9a-zA-Z\@\_]+)$/ && do {
52
my ($section, $type, $visibility, $symbol) = ($1, $2, $3, $4);
54
if ($section ne "UNDEF" && $visibility eq "External") {
55
print $fn if $show_module_name;
56
print "\t" if $use_indent || $show_module_name;
58
if ($strip_leading_underscore && $symbol =~ /_(.*)/) {
61
if ($strip_leading_underscore && $symbol =~ /(.*)\@.*$/) {
76
sub use_response_file($)
80
open (RF, '<', $fn) or die "Can't open response file $fn";
84
dump_symbols_for_file($1);
93
$show_module_name = 0;
103
$strip_leading_underscore = 1;
108
use_response_file($1);
112
dump_symbols_for_file($_);