afslog.1: Remove documentation for removed no-v4 argument.
[heimdal.git] / cf / w32-list-externs-from-objs.pl
blob9712120e9f1fd73774f3a19415737fb71cdef3a9
1 ########################################################################
3 # Copyright (c) 2010, Secure Endpoints Inc.
4 # All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
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
16 # distribution.
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;
33 my $use_indent = 1;
34 my $strip_leading_underscore = 0;
36 # Dump all symbols for the given object file that are defined and have
37 # external scope.
39 sub dump_symbols_for_file($)
41 $fn = shift;
43 print STDERR "Opening dump of object [$fn]\n";
45 open(SP, '-|', "dumpbin /symbols \"".$fn."\"") or die "Can't open pipe for $fn";
47 LINE:
48 while (<SP>) {
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 =~ /_(.*)/) {
59 $symbol = $1;
61 if ($strip_leading_underscore && $symbol =~ /(.*)\@.*$/) {
62 $symbol = $1;
64 print $symbol;
65 if ($type ne "()") {
66 print "\tDATA";
68 print "\n";
73 close SP;
76 sub use_response_file($)
78 $fn = shift;
80 open (RF, '<', $fn) or die "Can't open response file $fn";
82 while (<RF>) {
83 /(\S+)/ && do {
84 dump_symbols_for_file($1);
87 close RF;
90 for (@ARGV) {
91 ARG: {
92 /^-q$/ && do {
93 $show_module_name = 0;
94 last ARG;
97 /^-1$/ && do {
98 $use_indent = 0;
99 last ARG;
102 /^-u$/ && do {
103 $strip_leading_underscore = 1;
104 last ARG;
107 /^@(.*)$/ && do {
108 use_response_file($1);
109 last ARG;
112 dump_symbols_for_file($_);