Path: blob/main/crypto/krb5/src/util/export-check.pl
34889 views
#12# Copyright 2006 Massachusetts Institute of Technology.3# All Rights Reserved.4#5# Export of this software from the United States of America may6# require a specific license from the United States Government.7# It is the responsibility of any person or organization contemplating8# export to obtain such a license before exporting.9#10# WITHIN THAT CONSTRAINT, permission to use, copy, modify, and11# distribute this software and its documentation for any purpose and12# without fee is hereby granted, provided that the above copyright13# notice appear in all copies and that both that copyright notice and14# this permission notice appear in supporting documentation, and that15# the name of M.I.T. not be used in advertising or publicity pertaining16# to distribution of the software without specific, written prior17# permission. Furthermore if you modify this software you must label18# your software as modified software and not distribute it in such a19# fashion that it might be confused with the original M.I.T. software.20# M.I.T. makes no representations about the suitability of21# this software for any purpose. It is provided "as is" without express22# or implied warranty.23#2425$0 =~ s/^.*?([\w.-]+)$/$1/;2627# The real stuff.2829# Args: exportlist libfoo.so3031# This code assumes the GNU version of nm.32# For now, we'll only run it on GNU/Linux systems, so that's okay.3334if ($#ARGV != 1) {35die "usage: $0 exportfile libfoo.so\n";36}37my($exfile, $libfile) = @ARGV;3839@missing = ();40open NM, "nm -Dg --defined-only $libfile |" || die "can't run nm on $libfile: $!";41open EXPORT, "< $exfile" || die "can't read $exfile: $!";4243@export = <EXPORT>;44map chop, @export;45@export = sort @export;4647@found = ();48while (<NM>) {49chop;50s/^[0-9a-fA-F]+ +//;51s/@@.*$//;52next if /^A /;53if (!/^[TDRBGS] /) {54unlink $libfile;55die "not sure what to do with '$_'";56}57s/^[TDRBGS] +//;58push @found, $_;59}60@found = sort @found;61while ($#export >= 0 && $#found >= 0) {62if ($#export >= 1 && $export[0] eq $export[1]) {63print STDERR "Duplicate symbol in export list: $export[0]\n";64exit(1);65}66if ($export[0] eq $found[0]) {67# print "ok $export[0]\n";68shift @export;69shift @found;70} elsif ($export[0] lt $found[0]) {71push @missing, shift @export;72} else {73# Ignore added symbols, for now.74shift @found;75}76}77if ($#export >= 0) { @missing = (@missing, @export); }78if ($#missing >= 0) {79print STDERR "Missing symbols:\n\t", join("\n\t", @missing), "\n";80# unlink $libfile;81exit(1);82}83exit 0;848586