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