diff options
Diffstat (limited to 'util/checkplatformsyms.pl')
| -rwxr-xr-x | util/checkplatformsyms.pl | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/util/checkplatformsyms.pl b/util/checkplatformsyms.pl index 742dd8ea84fe..73f2a1b62184 100755 --- a/util/checkplatformsyms.pl +++ b/util/checkplatformsyms.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2006-2026 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the Apache License 2.0 (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy @@ -14,6 +14,13 @@ my $expectedsyms=$ARGV[0]; shift(@ARGV); +# Check that object files exist +foreach (@ARGV) { + unless (-f $_ && -r $_) { + die "Path is not a regular readable file: '$_'"; + } +} + my $objlist; my $objfilelist = join(" ", @ARGV); my $expsyms; @@ -36,13 +43,13 @@ if ($Config{osname} eq "MSWin32") { { chomp; my $dllfile = $_; - $dllfile =~ s/( +)(.*)(\.dll)(.*)/DLLFILE \2/; + $dllfile =~ s/( +)(.*)(\.dll)(.*)/DLLFILE $2/; if (index($dllfile, "DLLFILE") >= 0) { $currentdll = substr($dllfile, 8); $currentdll =~ s/^\s+|s+$//g; } # filter imports from our own library - if ("$currentdll" ne "libcrypto-3-x64") { + if ("$currentdll" !~ /^libcrypto-[1-9][0-9]*(-x64)?$/) { my $line = $_; $line =~ s/ [0-9a-fA-F]{1,2} /SYMBOL /; if (index($line, "SYMBOL") != -1) { @@ -51,18 +58,28 @@ if ($Config{osname} eq "MSWin32") { } } } + + close($OBJFH); + ($? >> 8 == 0) or die "Command '$cmd' has failed."; + + my $ok = 1; foreach (@symlist) { + chomp; if (index($exps, $_) < 0) { print "Symbol $_ not in the allowed platform symbols list\n"; - exit 1; + $ok = 0; } } - exit 0; + exit !$ok; } else { - $cmd = "objdump -t " . $objfilelist . " | grep UND | grep -v \@OPENSSL"; - $cmd = $cmd . " | awk '{print \$NF}' |"; - $cmd = $cmd . " sed -e\"s/@.*\$//\" | sort | uniq"; + $cmd = "objdump -t " . $objfilelist . " | awk " . + "'/\\\\*UND\\\\*/ {" . + "split(\$NF, sym_lib, \"@\");" . + "if (sym_lib[2] !~ \"OPENSSL_[1-9][0-9]*\\\\.[0-9]+\\\\.[0-9]+\$\")" . + "syms[sym_lib[1]] = 1;" . + "}" . + "END { for (s in syms) print s; };'"; open $expsyms, '<', $expectedsyms or die; { @@ -72,13 +89,16 @@ else { close($expsyms); open($OBJFH, "$cmd|") or die "Cannot open process: $!"; + my $ok = 1; while (<$OBJFH>) { + chomp; if (index($exps, $_) < 0) { print "Symbol $_ not in the allowed platform symbols list\n"; - exit 1; + $ok = 0; } } close($OBJFH); - exit 0; + + exit !(!($? >> 8) || !$ok); } |
