6 # Sort the symbol table portion of the output of objdump -ht by
7 # section, then by symbol value, then by size. Used to enhance the
8 # linker maps produced by "make bin/%.map" by also showing the values
9 # of all non-global symbols.
11 my %section_idx = ( "*ABS*" => "." );
14 if ( /^\s+(\d+)\s+([\.\*]\S+)\s+[0-9a-fA-F]+\s+[0-9a-fA-F]/ ) {
15 # It's a header line containing a section definition; extract the
16 # section index and store it. Also print the header line.
18 ( my $index, my $section ) = ( $1, $2 );
19 $section_idx{$section} = sprintf ( "%02d", $index );
20 } elsif ( /^([0-9a-fA-F]+)\s.*?\s([\.\*]\S+)\s+([0-9a-fA-F]+)\s/ ) {
21 # It's a symbol line - store it in the hash, indexed by
22 # "<section index>:<value>:<size>"
23 ( my $value, my $section, my $size ) = ( $1, $2, $3 );
24 die "Unrecognised section \"$section\"\n"
25 unless exists $section_idx{$section};
26 my $section_idx = $section_idx{$section};
27 my $key = $section_idx.":".$value.":".$size;
31 # It's a generic header line: just print it.
36 print $lines{$_} foreach sort keys %lines;