Windows: Check exported symbols
During a test run, cross check the Windows exports list against the version-script files. For the test to pass, all symbols on either list should be accounted for. If there are symbols that are specific to Windows or symbols that are not included on Windows, they should be annotated in the .def file as follows: ;! non_windows_symbol common_symbol windows_only_symbol ;!
This commit is contained in:
98
cf/w32-check-exported-symbols.pl
Normal file
98
cf/w32-check-exported-symbols.pl
Normal file
@@ -0,0 +1,98 @@
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
use feature "switch";
|
||||
|
||||
my $def_name = '';
|
||||
my $vs_name = '';
|
||||
my $show_help = 0;
|
||||
|
||||
my %syms;
|
||||
|
||||
my $def_only = 0;
|
||||
my $vs_only = 0;
|
||||
|
||||
GetOptions ("def=s" => \$def_name,
|
||||
"vs=s" => \$vs_name,
|
||||
"help|?" => \$show_help) or pod2usage( -exitval => 2,
|
||||
-verbose => 3 );
|
||||
pod2usage( -exitval => 1,
|
||||
-verbose => 3 ) if $show_help or !$def_name or !$vs_name;
|
||||
|
||||
open (my $def, '<', $def_name) or die $!;
|
||||
open (my $vs, '<', $vs_name) or die $!;
|
||||
|
||||
# First go through the version-script
|
||||
|
||||
my $global = 0;
|
||||
|
||||
while(<$vs>)
|
||||
{
|
||||
next unless m/^([^#]+)/;
|
||||
|
||||
@a = split(/\s+|({|})/,$1);
|
||||
|
||||
for $f (@a) {
|
||||
given ($f) {
|
||||
when (/global\:/) { $global = 1; }
|
||||
when (/{|}|.*\:/) { $global = 0; }
|
||||
when (/(.*)\;/ and $global == 1) {
|
||||
$syms{$1} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(<$def>)
|
||||
{
|
||||
next if m/^#/;
|
||||
next unless m/^;!([^;]+)/ or m/^([^;]+);?(!?)/;
|
||||
|
||||
@a = split(/\s+/, $1);
|
||||
|
||||
for $f (@a) {
|
||||
next if $f =~ /EXPORTS/ or $f =~ /DATA/ or not $f;
|
||||
|
||||
if (not exists $syms{$f} and not $2) {
|
||||
print "$f: Only in DEF\n";
|
||||
++$def_only;
|
||||
}
|
||||
delete $syms{$f};
|
||||
}
|
||||
}
|
||||
|
||||
#while (($k,$v) = each %syms) {
|
||||
for $k (sort keys %syms) {
|
||||
print "$k: Only in VS\n";
|
||||
++$vs_only;
|
||||
}
|
||||
|
||||
close($def);
|
||||
close($vs);
|
||||
|
||||
if ($def_only or $vs_only) {
|
||||
print "\nMismatches found.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
w32-sync-exported-symbols.pl - Synchronize Windows .def with version-script
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
w32-sync-exported-symbols.pl {options}
|
||||
|
||||
Options:
|
||||
--def Name of .def file
|
||||
--vs Name of version-script file
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Verifies that all the symbols exported by the version-script is also
|
||||
accounted for in the .def file. Also checks that no extra symbols are
|
||||
exported by the .def file unless they are marked as safe.
|
||||
|
||||
=cut
|
||||
|
@@ -82,3 +82,7 @@ clean::
|
||||
-$(RM) $(INCFILES)
|
||||
-$(RM) $(COMERRDLL)
|
||||
|
||||
test-exports:
|
||||
$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libcom_err-exports.def
|
||||
|
||||
test:: test-exports
|
||||
|
@@ -531,3 +531,8 @@ clean::
|
||||
"\t$(gssapi_files:.x=.obj)")
|
||||
"krb5src" "mechsrc" "spnegosrc" "ntlmsrc")
|
||||
!endif
|
||||
|
||||
test-exports:
|
||||
$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libgssapi-exports.def
|
||||
|
||||
test:: test-exports
|
||||
|
@@ -244,3 +244,7 @@ test-run:
|
||||
|
||||
test:: $(TESTLIB) test-binaries test-run
|
||||
|
||||
test-exports:
|
||||
$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libhcrypto-exports.def
|
||||
|
||||
test:: test-exports
|
||||
|
@@ -193,3 +193,7 @@ hdb_cflags=$(openldap_inc_flag) -I$(OBJ)
|
||||
{$(OBJ)}.c{$(OBJ)}.obj::
|
||||
$(C2OBJ_P) $(hdb_cflags)
|
||||
|
||||
test-exports:
|
||||
$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libhdb-exports.def
|
||||
|
||||
test:: test-exports
|
||||
|
@@ -254,4 +254,9 @@ test-run:
|
||||
$(CP) $< $@
|
||||
|
||||
{}.c{$(OBJ)}.obj::
|
||||
$(C2OBJ_P) -I$(OBJ) -I$(KADM5INCDIR)
|
||||
$(C2OBJ_P) -I$(OBJ) -I$(KADM5INCDIR)
|
||||
|
||||
test-exports:
|
||||
$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libkadm5srv-exports.def
|
||||
|
||||
test:: test-exports
|
||||
|
@@ -399,3 +399,8 @@ $(test_binaries): $$(@R).obj
|
||||
|
||||
$(test_binaries:.exe=.obj): $$(@B).c
|
||||
$(C2OBJ_C) -Fo$@ -Fd$(@D)\ $** -DBlah
|
||||
|
||||
test-exports:
|
||||
$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libkrb5-exports.def.in
|
||||
|
||||
test:: test-exports
|
||||
|
@@ -74,3 +74,8 @@ $(OBJ)\test_ntlm.exe: $(OBJ)\test_ntlm.obj $(LIBHEIMNTLM) $(LIBHEIMDAL) $(LIBVER
|
||||
$(EXEPREP_NODIST)
|
||||
|
||||
test:: test-binaries test-run
|
||||
|
||||
test-exports:
|
||||
$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libheimntlm-exports.def
|
||||
|
||||
test:: test-exports
|
||||
|
@@ -152,3 +152,8 @@ clean::
|
||||
-$(RM) $(INCFILES)
|
||||
|
||||
test:: test-binaries test-run
|
||||
|
||||
test-exports:
|
||||
$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libwind-exports.def
|
||||
|
||||
test:: test-exports
|
||||
|
Reference in New Issue
Block a user