]>
git.ipfire.org Git - thirdparty/openssl.git/blob - util/mknum.pl
3 # Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
5 # Licensed under the Apache License 2.0 (the "License"). You may not use
6 # this file except in compliance with the License. You can obtain a copy
7 # in the file LICENSE in the source distribution or at
8 # https://www.openssl.org/source/license.html
15 use lib
"$FindBin::Bin/perl";
17 use OpenSSL
::Ordinals
;
20 my $ordinals_file = undef; # the ordinals file to use
21 my $symhacks_file = undef; # a symbol hacking file (optional)
22 my $version = undef; # the version to use for added symbols
23 my $checkexist = 0; # (unsure yet)
28 GetOptions
('ordinals=s' => \
$ordinals_file,
29 'symhacks=s' => \
$symhacks_file,
30 'version=s' => \
$version,
31 'exist' => \
$checkexist,
32 'warnings!' => \
$warnings,
33 'verbose' => \
$verbose,
35 or die "Error in command line arguments\n";
37 die "Please supply ordinals file\n"
38 unless $ordinals_file;
40 my $ordinals = OpenSSL
::Ordinals
->new(from
=> $ordinals_file,
41 warnings
=> $warnings,
44 $ordinals->set_version($version);
47 %orig_names = map { $_->name() => 1 }
48 $ordinals->items(comparator
=> sub { $_[0] cmp $_[1] },
49 filter
=> sub { $_->exists() })
52 # Invalidate all entries, they get revalidated when we re-check below
53 $ordinals->invalidate();
55 foreach my $f (($symhacks_file // (), @ARGV)) {
56 print STDERR
$f," ","-" x
(69 - length($f)),"\n" if $verbose;
57 open IN
, $f || die "Couldn't open $f: $!\n";
58 foreach (parse
(<IN
>, { filename
=> $f,
59 warnings
=> $warnings,
62 $_->{value
} = $_->{value
}||"";
63 next if grep { $_ eq 'CONST_STRICT' } @
{$_->{conds
}};
64 printf STDERR
"%s> %s%s : %s\n",
67 ($_->{type
} eq 'M' && defined $symhacks_file && $f eq $symhacks_file
70 join(', ', @
{$_->{conds
}})
73 && defined $symhacks_file
74 && $f eq $symhacks_file
75 && $_->{value
} =~ /^\w(?:\w|\d)*/) {
76 $ordinals->add_alias($_->{value
}, $_->{name
}, @
{$_->{conds
}});
78 next if $_->{returntype
} =~ /\b(?:ossl_)inline/;
84 $ordinals->add($_->{name
}, $type, @
{$_->{conds
}});
91 # As long as we're running in development or alpha releases, we can have
92 # symbols without specific numbers assigned. When in beta or final release,
93 # all symbols MUST have an assigned number.
94 if ($version !~ m/^\d+\.\d+\.\d+(?:[a-z]+)?-(?:dev|alpha)/) {
95 $ordinals->renumber();
99 my %new_names = map { $_->name() => 1 }
100 $ordinals->items(comparator
=> sub { $_[0] cmp $_[1] },
101 filter
=> sub { $_->exists() });
102 # Eliminate common names
103 foreach (keys %orig_names) {
104 next unless exists $new_names{$_};
105 delete $orig_names{$_};
106 delete $new_names{$_};
109 print "The following symbols do not seem to exist in code:\n";
110 foreach (sort keys %orig_names) {
115 print "The following existing symbols are not in ordinals file:\n";
116 foreach (sort keys %new_names) {
121 $ordinals->rewrite();
122 my %stats = $ordinals->stats();
124 "${ordinals_file}: $stats{modified} old symbols have updated info\n"
127 print STDERR
"${ordinals_file}: Added $stats{new} new symbols\n";
129 print STDERR
"${ordinals_file}: No new symbols added\n";
131 if ($stats{unassigned
}) {
132 my $symbol = $stats{unassigned
} == 1 ?
"symbol" : "symbols";
133 my $is = $stats{unassigned
} == 1 ?
"is" : "are";
134 print STDERR
"${ordinals_file}: $stats{unassigned} $symbol $is without ordinal number\n";