diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /scripts/reference_init.pl |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'scripts/reference_init.pl')
-rw-r--r-- | scripts/reference_init.pl | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/scripts/reference_init.pl b/scripts/reference_init.pl new file mode 100644 index 000000000000..9a2408453869 --- /dev/null +++ b/scripts/reference_init.pl | |||
@@ -0,0 +1,107 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # | ||
3 | # reference_init.pl (C) Keith Owens 2002 <kaos@ocs.com.au> | ||
4 | # | ||
5 | # List references to vmlinux init sections from non-init sections. | ||
6 | |||
7 | # Unfortunately I had to exclude references from read only data to .init | ||
8 | # sections, almost all of these are false positives, they are created by | ||
9 | # gcc. The downside of excluding rodata is that there really are some | ||
10 | # user references from rodata to init code, e.g. drivers/video/vgacon.c | ||
11 | # | ||
12 | # const struct consw vga_con = { | ||
13 | # con_startup: vgacon_startup, | ||
14 | # | ||
15 | # where vgacon_startup is __init. If you want to wade through the false | ||
16 | # positives, take out the check for rodata. | ||
17 | |||
18 | use strict; | ||
19 | die($0 . " takes no arguments\n") if($#ARGV >= 0); | ||
20 | |||
21 | my %object; | ||
22 | my $object; | ||
23 | my $line; | ||
24 | my $ignore; | ||
25 | |||
26 | $| = 1; | ||
27 | |||
28 | printf("Finding objects, "); | ||
29 | open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed"; | ||
30 | while (defined($line = <OBJDUMP_LIST>)) { | ||
31 | chomp($line); | ||
32 | if ($line =~ /:\s+file format/) { | ||
33 | ($object = $line) =~ s/:.*//; | ||
34 | $object{$object}->{'module'} = 0; | ||
35 | $object{$object}->{'size'} = 0; | ||
36 | $object{$object}->{'off'} = 0; | ||
37 | } | ||
38 | if ($line =~ /^\s*\d+\s+\.modinfo\s+/) { | ||
39 | $object{$object}->{'module'} = 1; | ||
40 | } | ||
41 | if ($line =~ /^\s*\d+\s+\.comment\s+/) { | ||
42 | ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5]; | ||
43 | } | ||
44 | } | ||
45 | close(OBJDUMP_LIST); | ||
46 | printf("%d objects, ", scalar keys(%object)); | ||
47 | $ignore = 0; | ||
48 | foreach $object (keys(%object)) { | ||
49 | if ($object{$object}->{'module'}) { | ||
50 | ++$ignore; | ||
51 | delete($object{$object}); | ||
52 | } | ||
53 | } | ||
54 | printf("ignoring %d module(s)\n", $ignore); | ||
55 | |||
56 | # Ignore conglomerate objects, they have been built from multiple objects and we | ||
57 | # only care about the individual objects. If an object has more than one GCC: | ||
58 | # string in the comment section then it is conglomerate. This does not filter | ||
59 | # out conglomerates that consist of exactly one object, can't be helped. | ||
60 | |||
61 | printf("Finding conglomerates, "); | ||
62 | $ignore = 0; | ||
63 | foreach $object (keys(%object)) { | ||
64 | if (exists($object{$object}->{'off'})) { | ||
65 | my ($off, $size, $comment, $l); | ||
66 | $off = hex($object{$object}->{'off'}); | ||
67 | $size = hex($object{$object}->{'size'}); | ||
68 | open(OBJECT, "<$object") || die "cannot read $object"; | ||
69 | seek(OBJECT, $off, 0) || die "seek to $off in $object failed"; | ||
70 | $l = read(OBJECT, $comment, $size); | ||
71 | die "read $size bytes from $object .comment failed" if ($l != $size); | ||
72 | close(OBJECT); | ||
73 | if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) { | ||
74 | ++$ignore; | ||
75 | delete($object{$object}); | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | printf("ignoring %d conglomerate(s)\n", $ignore); | ||
80 | |||
81 | printf("Scanning objects\n"); | ||
82 | foreach $object (sort(keys(%object))) { | ||
83 | my $from; | ||
84 | open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object"; | ||
85 | while (defined($line = <OBJDUMP>)) { | ||
86 | chomp($line); | ||
87 | if ($line =~ /RELOCATION RECORDS FOR /) { | ||
88 | ($from = $line) =~ s/.*\[([^]]*).*/$1/; | ||
89 | } | ||
90 | if (($line =~ /\.init$/ || $line =~ /\.init\./) && | ||
91 | ($from !~ /\.init$/ && | ||
92 | $from !~ /\.init\./ && | ||
93 | $from !~ /\.stab$/ && | ||
94 | $from !~ /\.rodata$/ && | ||
95 | $from !~ /\.text\.lock$/ && | ||
96 | $from !~ /\.pci_fixup_header$/ && | ||
97 | $from !~ /\.pci_fixup_final$/ && | ||
98 | $from !~ /\.pdr$/ && | ||
99 | $from !~ /\__param$/ && | ||
100 | $from !~ /\.altinstructions/ && | ||
101 | $from !~ /\.debug_/)) { | ||
102 | printf("Error: %s %s refers to %s\n", $object, $from, $line); | ||
103 | } | ||
104 | } | ||
105 | close(OBJDUMP); | ||
106 | } | ||
107 | printf("Done\n"); | ||