#! /usr/bin/perl use strict; use warnings; open NM,"-|",'m68k-pic-coff-nm gnokii/gnokii.coff|sort' or die "nm: $!"; my(%big,$prevhex,$prevsym,$tot); while () { chomp; /^([0-9a-f]+) (\w) (.*)$/ or die "parse: $_"; my $hex=hex $1; my $type=$2; my $sym=$3; next if $type!~/[tT]/ || $sym=~/^\./ || $sym=~/^L\d+$/ || $sym eq "__gnu_compiled_c" || $sym eq "gcc2_compiled."; if ($prevhex) { warn "dup: $prevsym" if exists $big{$prevsym}; $big{$prevsym}=$hex-$prevhex; $tot+=$hex-$prevhex; } $prevhex=$hex; $prevsym=$sym; } close NM; $big{"_TOTAL"}=$tot; for (sort { $big{$b} <=> $big{$a} } keys %big) { printf "%4u %s\n",$big{$_},$_; }