Commit | Line | Data |
---|---|---|
144ef909 TB |
1 | #!/usr/bin/perl |
2 | ||
3 | # Copyright © 2009 IBM Corporation | |
4 | ||
5 | # This program is free software; you can redistribute it and/or | |
6 | # modify it under the terms of the GNU General Public License | |
7 | # as published by the Free Software Foundation; either version | |
8 | # 2 of the License, or (at your option) any later version. | |
9 | ||
8b05537e | 10 | # This script checks the relocations of a vmlinux for "suspicious" |
144ef909 TB |
11 | # relocations. |
12 | ||
13 | use strict; | |
14 | use warnings; | |
15 | ||
16 | if ($#ARGV != 1) { | |
17 | die "$0 [path to objdump] [path to vmlinux]\n"; | |
18 | } | |
19 | ||
20 | # Have Kbuild supply the path to objdump so we handle cross compilation. | |
21 | my $objdump = shift; | |
22 | my $vmlinux = shift; | |
23 | my $bad_relocs_count = 0; | |
24 | my $bad_relocs = ""; | |
25 | my $old_binutils = 0; | |
26 | ||
27 | open(FD, "$objdump -R $vmlinux|") or die; | |
28 | while (<FD>) { | |
29 | study $_; | |
30 | ||
8b05537e | 31 | # Only look at relocation lines. |
144ef909 TB |
32 | next if (!/\s+R_/); |
33 | ||
34 | # These relocations are okay | |
9c5f7d39 SP |
35 | # On PPC64: |
36 | # R_PPC64_RELATIVE, R_PPC64_NONE, R_PPC64_ADDR64 | |
37 | # On PPC: | |
38 | # R_PPC_RELATIVE, R_PPC_ADDR16_HI, | |
39 | # R_PPC_ADDR16_HA,R_PPC_ADDR16_LO, | |
40 | # R_PPC_NONE | |
41 | ||
42 | next if (/\bR_PPC64_RELATIVE\b/ or /\bR_PPC64_NONE\b/ or | |
43 | /\bR_PPC64_ADDR64\s+mach_/); | |
44 | next if (/\bR_PPC_ADDR16_LO\b/ or /\bR_PPC_ADDR16_HI\b/ or | |
45 | /\bR_PPC_ADDR16_HA\b/ or /\bR_PPC_RELATIVE\b/ or | |
46 | /\bR_PPC_NONE\b/); | |
144ef909 | 47 | |
8b05537e | 48 | # If we see this type of relocation it's an idication that |
144ef909 TB |
49 | # we /may/ be using an old version of binutils. |
50 | if (/R_PPC64_UADDR64/) { | |
51 | $old_binutils++; | |
52 | } | |
53 | ||
54 | $bad_relocs_count++; | |
55 | $bad_relocs .= $_; | |
56 | } | |
57 | ||
58 | if ($bad_relocs_count) { | |
59 | print "WARNING: $bad_relocs_count bad relocations\n"; | |
60 | print $bad_relocs; | |
61 | } | |
62 | ||
63 | if ($old_binutils) { | |
8b05537e PB |
64 | print "WARNING: You need at least binutils >= 2.19 to build a ". |
65 | "CONFIG_RELOCATABLE kernel\n"; | |
144ef909 | 66 | } |