#!/usr/bin/perl
# un-mangle c++ symbol
# assuming the c++filt command is available
use strict;
use warnings;
if ($#ARGV != 0) {
print "usage:\n";
print "program filename\n";
}
my $in_filename = $ARGV[0];
open(my $in,"<",$in_filename) or dIE "Can't not open file $in_filename: $!\n";
$/ = undef;
my $body = <$in>;
while ($body =~ /\<(_Z\w+)[\+|\>]/g) {
my $mangled_symbol_full = $&;
my $mangled_symbol = $1;
my $unmangled_symbol = `c++filt '$mangled_symbol'`;
$unmangled_symbol =~ tr/\n//d;
#print $mangled_symbol;
#print "\n";
#print $unmangled_symbol;
#print "\n";
$body =~ s/$mangled_symbol/$unmangled_symbol/g;
}
print $body;
print "\n";
close $in or dIE "$in: $!\n";
注:如果你拿到的是objdump出来的东西,就没必要这么复杂了,objdump -C就可以unmangle好了。
总结以上是内存溢出为你收集整理的[Scripts][Perl] unmangle指定文件中所有mangle过的C++符号名全部内容,希望文章能够帮你解决[Scripts][Perl] unmangle指定文件中所有mangle过的C++符号名所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)