process_undef.pl 476 B

123456789101112131415161718192021
  1. #!/usr/bin/env perl
  2. # send linker output to stdin
  3. # make 2>&1 | process_undef.pl
  4. my %symbols;
  5. open($list, "cat $ARGV[0] " . '| grep \'undefined reference\' | grep -v \'more undefined\' | sed -e \'s/.*undefined reference to `\(.*\)./\1/\' |');
  6. my $line = <$list>;
  7. do
  8. {
  9. chop($line);
  10. $symbols{$line}++;
  11. } until (!($line = <$list>));
  12. @sorted = sort { $symbols{$b} <=> $symbols{$a} } keys %symbols;
  13. foreach (@sorted)
  14. {
  15. print "$symbols{$_} : $_\n";
  16. };