Michael Brown 19 лет назад
Родитель
Сommit
ac01cf4997
1 измененных файлов: 34 добавлений и 0 удалений
  1. 34
    0
      src/util/sortobjdump.pl

+ 34
- 0
src/util/sortobjdump.pl Просмотреть файл

@@ -0,0 +1,34 @@
1
+#!/usr/bin/perl -w
2
+
3
+use strict;
4
+use warnings;
5
+
6
+# Sort the symbol table portion of the output of objdump -ht by
7
+# section, then by symbol value.  Used to enhance the linker maps
8
+# produced by "make bin/%.map" by also showing the values of all
9
+# non-global symbols.
10
+
11
+my %section_idx = ( "*ABS*" => "." );
12
+my %lines;
13
+while ( <> ) {
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.
17
+    print;
18
+    ( my $index, my $section ) = ( $1, $2 );
19
+    $section_idx{$section} = sprintf ( "%02d", $index );
20
+  } elsif ( /^([0-9a-fA-F]+)\s.*?\s([\.\*]\S+)\s/ ) {
21
+    # It's a symbol line - store it in the hash, indexed by
22
+    # "<section index>.<value>"
23
+    ( my $value, my $section ) = ( $1, $2 );
24
+    die "Unrecognised section \"$section\"\n"
25
+	unless exists $section_idx{$section};
26
+    my $section_idx = $section_idx{$section};
27
+    $lines{${section_idx}.":".${value}} = $_;
28
+  } else {
29
+    # It's a generic header line: just print it.
30
+    print;
31
+  }
32
+}
33
+
34
+print $lines{$_} foreach sort keys %lines;

Загрузка…
Отмена
Сохранить