Browse Source

Tweaked to read more information (including symbol size) from blib.a

tags/v0.9.3
Michael Brown 20 years ago
parent
commit
88baf7a383
2 changed files with 46 additions and 14 deletions
  1. 1
    1
      src/Makefile.housekeeping
  2. 45
    13
      src/util/symcheck.pl

+ 1
- 1
src/Makefile.housekeeping View File

@@ -407,7 +407,7 @@ CLEANUP	+= TAGS*
407 407
 #
408 408
 SYMTAB	= $(BIN)/symtab
409 409
 $(SYMTAB) : $(BLIB)
410
-	$(NM) -o -g $< > $@
410
+	$(NM) -o -S $< > $@
411 411
 
412 412
 symcheck : $(SYMTAB)
413 413
 	$(SYMCHECK) $<

+ 45
- 13
src/util/symcheck.pl View File

@@ -3,30 +3,62 @@
3 3
 use strict;
4 4
 use warnings;
5 5
 
6
-my $symbols = {};
6
+use constant WARNING_SIZE => 2048;
7 7
 
8
-# Scan output of "nm -o -g bin/blib.a" and build up symbol cross-ref table
8
+my $symtab = {};
9
+
10
+# Scan output of "nm -o -S bin/blib.a" and build up symbol table
9 11
 #
10 12
 while ( <> ) {
11 13
   chomp;
12
-  ( my $object, my $type, my $symbol ) = /^.*?:(.*?\.o):.*?\s(\S)\s(.*)$/;
13
-  my $category = $type eq 'U' ? "requires" : "provides";
14
-  $symbols->{$symbol}->{$category}->{$object} = 1;
14
+  ( my $object, undef, my $value, undef, my $size, my $type, my $symbol )
15
+      = /^.*?:(.*?\.o):((\S+)(\s+(\S+))?)?\s+(\S)\s+(\S+)$/;
16
+  $symtab->{$object}->{$symbol} = {
17
+    global	=> ( $type eq uc $type ),
18
+    type	=> ( $type ),
19
+    value	=> ( $value ? hex ( $value ) : 0 ),
20
+    size	=> ( $size ? hex ( $size ) : 0 ),
21
+  };
15 22
 }
16 23
 
17 24
 # Add symbols that we know will be generated or required by the linker
18 25
 #
19
-while ( ( my $symbol, my $info ) = each %$symbols ) {
20
-  $info->{requires}->{LINKER} = 1 if $symbol =~ /^obj_/;
26
+foreach my $object ( keys %$symtab ) {
27
+  my $obj_symbol = "obj_$object";
28
+  $obj_symbol =~ s/\.o$//;
29
+  $obj_symbol =~ s/\W/_/g;
30
+  $symtab->{LINKER}->{$obj_symbol} = {
31
+    global	=> 1,
32
+    type	=> 'U',
33
+    value	=> 0,
34
+    size	=> 0,
35
+  };
36
+}
37
+foreach my $link_sym qw ( _prefix _eprefix _decompress _edecompress _text
38
+			  _etext _data _edata _bss _ebss _end ) {
39
+  $symtab->{LINKER}->{$link_sym} = {
40
+    global	=> 1,
41
+    type       	=> 'A',
42
+    value	=> 0,
43
+    size	=> 0,
44
+  };
45
+}
46
+
47
+# Build up requires and provides tables for global symbols
48
+my $globals = {};
49
+while ( ( my $object, my $symbols ) = each %$symtab ) {
50
+  while ( ( my $symbol, my $info ) = each %$symbols ) {
51
+    if ( $info->{global} ) {
52
+      my $category = ( ( $info->{type} eq 'U' ? "requires" : "provides" ) );
53
+      $globals->{$symbol}->{$category}->{$object} = 1;
54
+    }
55
+  }
21 56
 }
22
-$symbols->{$_}->{provides}->{LINKER} = 1
23
-    foreach qw ( _prefix _eprefix _decompress _edecompress _text
24
-		 _etext _data _edata _bss _ebss _end );
25 57
 
26
-# Check for multiply defined, never-defined and unused symbols
58
+# Check for multiply defined, never-defined and unused global symbols
27 59
 #
28 60
 my $problems = {};
29
-while ( ( my $symbol, my $info ) = each %$symbols ) {
61
+while ( ( my $symbol, my $info ) = each %$globals ) {
30 62
   my @provides = keys %{$info->{provides}};
31 63
   my @requires = keys %{$info->{requires}};
32 64
 
@@ -58,7 +90,7 @@ foreach my $object ( sort keys %$problems ) {
58 90
   $errors += @nonexistent;
59 91
   foreach my $symbol ( @multiples ) {
60 92
     my @other_objects = sort grep { $_ ne $object }
61
-		        keys %{$symbols->{$symbol}->{provides}};
93
+		        keys %{$globals->{$symbol}->{provides}};
62 94
     print "ERR  $object provides symbol $symbol"
63 95
 	." (also provided by @other_objects)\n";
64 96
   }

Loading…
Cancel
Save