translatesyms.pl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /usr/bin/env perl
  2. # Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. # This script will translate any SYMBOL_VECTOR item that has a translation
  9. # in CXX$DEMANGLER_DB. The latter is generated by and CC/DECC command that
  10. # uses the qualifier /REPOSITORY with the build directory as value. When
  11. # /NAMES=SHORTENED has been used, this file will hold the translations from
  12. # the original symbols to the shortened variants.
  13. #
  14. # CXX$DEMAGLER_DB. is an ISAM file, but with the magic of RMS, it can be
  15. # read as a text file, with each record as one line.
  16. #
  17. # The lines will have the following syntax for any symbol found that's longer
  18. # than 31 characters:
  19. #
  20. # LONG_symbol_34567890123{cksum}$LONG_symbol_34567890123_more_than_31_chars
  21. #
  22. # $ is present at the end of the shortened symbol name, and is preceded by a
  23. # 7 character checksum. The $ makes it easy to separate the shortened name
  24. # from the original one.
  25. use strict;
  26. use warnings;
  27. usage() if scalar @ARGV < 1;
  28. my %translations = ();
  29. open DEMANGLER_DATA, $ARGV[0]
  30. or die "Couldn't open $ARGV[0]: $!\n";
  31. while(<DEMANGLER_DATA>) {
  32. s|\R$||;
  33. (my $translated, my $original) = split /\$/;
  34. $translations{$original} = $translated.'$';
  35. }
  36. close DEMANGLER_DATA;
  37. $| = 1; # Autoflush
  38. while(<STDIN>) {
  39. s@
  40. ((?:[A-Za-z0-9_]+)\/)?([A-Za-z0-9_]+)=(PROCEDURE|DATA)
  41. @
  42. if (defined($translations{$2})) {
  43. my $trans = $translations{$2};
  44. my $trans_uc = uc $trans;
  45. if (defined($1) && $trans ne $trans_uc) {
  46. "$trans_uc/$trans=$3"
  47. } else {
  48. "$trans=$3"
  49. }
  50. } else {
  51. $&
  52. }
  53. @gxe;
  54. print $_;
  55. }