summaryrefslogtreecommitdiffstats
path: root/src/util/sortobjdump.pl
diff options
context:
space:
mode:
authorMichael Brown2005-04-27 12:40:59 +0200
committerMichael Brown2005-04-27 12:40:59 +0200
commitac01cf4997a306badc1c5d0f502645492d379106 (patch)
tree09157cef3a800b58dc36b71e8085673350063751 /src/util/sortobjdump.pl
parentAdded back in the actual call to load(). (diff)
downloadipxe-ac01cf4997a306badc1c5d0f502645492d379106.tar.gz
ipxe-ac01cf4997a306badc1c5d0f502645492d379106.tar.xz
ipxe-ac01cf4997a306badc1c5d0f502645492d379106.zip
First version
Diffstat (limited to 'src/util/sortobjdump.pl')
-rwxr-xr-xsrc/util/sortobjdump.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/util/sortobjdump.pl b/src/util/sortobjdump.pl
new file mode 100755
index 00000000..99d793b6
--- /dev/null
+++ b/src/util/sortobjdump.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+# Sort the symbol table portion of the output of objdump -ht by
+# section, then by symbol value. Used to enhance the linker maps
+# produced by "make bin/%.map" by also showing the values of all
+# non-global symbols.
+
+my %section_idx = ( "*ABS*" => "." );
+my %lines;
+while ( <> ) {
+ if ( /^\s+(\d+)\s+([\.\*]\S+)\s+[0-9a-fA-F]+\s+[0-9a-fA-F]/ ) {
+ # It's a header line containing a section definition; extract the
+ # section index and store it. Also print the header line.
+ print;
+ ( my $index, my $section ) = ( $1, $2 );
+ $section_idx{$section} = sprintf ( "%02d", $index );
+ } elsif ( /^([0-9a-fA-F]+)\s.*?\s([\.\*]\S+)\s/ ) {
+ # It's a symbol line - store it in the hash, indexed by
+ # "<section index>.<value>"
+ ( my $value, my $section ) = ( $1, $2 );
+ die "Unrecognised section \"$section\"\n"
+ unless exists $section_idx{$section};
+ my $section_idx = $section_idx{$section};
+ $lines{${section_idx}.":".${value}} = $_;
+ } else {
+ # It's a generic header line: just print it.
+ print;
+ }
+}
+
+print $lines{$_} foreach sort keys %lines;