mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-08 20:41:59 +03:00
34 lines
744 B
Perl
Executable File
34 lines
744 B
Perl
Executable File
#!/usr/bin/perl
|
|
|
|
# Run this script on the map with cross-reference generated by GNU ld,
|
|
# and it will generate a list of symbols that don't need to be global.
|
|
# To create the map, run something like this:
|
|
# make LDFLAGS=-Wl,-Map,mc.map,--cref
|
|
|
|
use strict;
|
|
|
|
if ($#ARGV != 0) {
|
|
print "Usage: unrefglobals.pl mapfile\n";
|
|
exit 1;
|
|
}
|
|
|
|
if (!open (MAP, "$ARGV[0]")) {
|
|
print "Cannot open file \"$ARGV[0]\"\n";
|
|
exit 1;
|
|
}
|
|
|
|
my $line;
|
|
my $next_line = <MAP>;
|
|
while (1) {
|
|
last unless $next_line;
|
|
$line = $next_line;
|
|
$next_line = <MAP>;
|
|
next unless ($line =~ m{^[A-Za-z_][A-Za-z0-9_]* +[^ /][^ ]+\.o$} or
|
|
$line =~ m{^[A-Za-z_][A-Za-z0-9_]* +[^ ]+\.a\([^ ]+\.o\)$});
|
|
if (!$next_line or ($next_line !~ /^ /)) {
|
|
print $line;
|
|
}
|
|
}
|
|
|
|
close(MAP);
|