Last active
December 19, 2017 03:48
-
-
Save camthesaxman/456104e4f2a1f555756d2f027cca0504 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Created by Cameron Hall (camthesaxman) on July 9, 2017 | |
# | |
# This script calculates the decompilation progress of pokeruby by using the | |
# pokeruby.map file. | |
# | |
(@ARGV == 1) | |
or die "ERROR: no map file specified.\n"; | |
open(my $file, $ARGV[0]) | |
or die "ERROR: could not open file '$ARGV[0]'.\n"; | |
my %text = (); | |
my %rodata = (); | |
while (my $line = <$file>) | |
{ | |
# Find all lines of the following form | |
# .section address size filename | |
if ($line =~ /^ \.(\w+)\s+0x[0-9a-f]+\s+(0x[0-9a-f]+) (\w+)\/.+\.o/) | |
{ | |
my ($secName, $size, $dir) = ($1, hex($2), $3); | |
my $section; | |
if ($secName =~ /text/) | |
{ | |
$section = \%text; | |
} | |
elsif ($secName =~ /rodata/) | |
{ | |
$section = \%rodata; | |
} | |
$section->{$dir} += $size; | |
} | |
} | |
sub print_report | |
{ | |
my ($label, $decompiled, $undecompiled) = @_; | |
my $total = $decompiled + $undecompiled; | |
my $percent = 100 * $decompiled / $total; | |
print "$label: $decompiled of $total bytes decompiled ($percent%)\n"; | |
} | |
print_report('CODE', $text{'src'}, $text{'asm'}); | |
print_report('DATA', $rodata{'src'}, $rodata{'data'}); | |
print_report('TOTAL', $text{'src'} + $rodata{'src'}, $text{'asm'} + $rodata{'data'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment