~ubuntu-branches/ubuntu/lucid/openssl/lucid-proposed

« back to all changes in this revision

Viewing changes to util/mksdef.pl

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2009-06-13 18:15:46 UTC
  • mto: (11.1.5 squeeze)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20090613181546-vbfntai3b009dl1u
Tags: upstream-0.9.8k
ImportĀ upstreamĀ versionĀ 0.9.8k

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
# Perl script to split libeay32.def into two distinct DEF files for use in
 
3
# fipdso mode. It works out symbols in each case by running "link" command and
 
4
# parsing the output to find the list of missing symbols then splitting
 
5
# libeay32.def based on the result.
 
6
 
 
7
 
 
8
# Get list of unknown symbols
 
9
 
 
10
my @deferr = `link @ARGV`;
 
11
 
 
12
my $preamble = "";
 
13
my @fipsdll;
 
14
my @fipsrest;
 
15
my %nosym;
 
16
 
 
17
# Add symbols to a hash for easy lookup
 
18
 
 
19
foreach (@deferr)
 
20
        {
 
21
        if (/^.*symbol (\S+)$/)
 
22
                {
 
23
                $nosym{$1} = 1;
 
24
                }
 
25
        }
 
26
 
 
27
open (IN, "ms/libeay32.def") || die "Can't Open DEF file for spliting";
 
28
 
 
29
my $started = 0;
 
30
 
 
31
# Parse libeay32.def into two arrays depending on whether the symbol matches
 
32
# the missing list.
 
33
 
 
34
 
 
35
foreach (<IN>)
 
36
        {
 
37
        if (/^\s*(\S+)\s*(\@\S+)\s*$/)
 
38
                {
 
39
                $started = 1;
 
40
                if (exists $nosym{$1})
 
41
                        {
 
42
                        push @fipsrest, $_;
 
43
                        }
 
44
                else
 
45
                        {
 
46
                        my $imptmp = sprintf "     %-39s %s\n",
 
47
                                        "$1=libosslfips.$1", $2;
 
48
                        push @fipsrest, $imptmp;
 
49
                        push @fipsdll, "\t$1\n";
 
50
                        }
 
51
                }
 
52
        $preamble .= $_ unless $started;
 
53
        }
 
54
 
 
55
close IN;
 
56
 
 
57
# Hack! Add some additional exports needed for libcryptofips.dll
 
58
#
 
59
 
 
60
push @fipsdll, "\tOPENSSL_showfatal\n";
 
61
push @fipsdll, "\tOPENSSL_cpuid_setup\n";
 
62
 
 
63
# Write out DEF files for each array
 
64
 
 
65
write_def("ms/libosslfips.def", "LIBOSSLFIPS", $preamble, \@fipsdll);
 
66
write_def("ms/libeayfips.def", "", $preamble, \@fipsrest);
 
67
 
 
68
 
 
69
sub write_def
 
70
        {
 
71
        my ($fnam, $defname, $preamble, $rdefs) = @_;
 
72
        open (OUT, ">$fnam") || die "Can't Open DEF file $fnam for Writing\n";
 
73
 
 
74
        if ($defname ne "")
 
75
                {
 
76
                $preamble =~ s/LIBEAY32/$defname/g;
 
77
                $preamble =~ s/LIBEAY/$defname/g;
 
78
                }
 
79
        print OUT $preamble;
 
80
        foreach (@$rdefs)
 
81
                {
 
82
                print OUT $_;
 
83
                }
 
84
        close OUT;
 
85
        }
 
86
 
 
87