mksdef.pl 1.6 KB

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