blob: 7f5b8380886276179a11b0f60d3a5a3384f9cd95 [file] [log] [blame]
Tony Breeds144ef902009-09-14 19:57:02 +00001#!/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
10# This script checks the relcoations of a vmlinux for "suspicious"
11# relocations.
12
13use strict;
14use warnings;
15
16if ($#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.
21my $objdump = shift;
22my $vmlinux = shift;
23my $bad_relocs_count = 0;
24my $bad_relocs = "";
25my $old_binutils = 0;
26
27open(FD, "$objdump -R $vmlinux|") or die;
28while (<FD>) {
29 study $_;
30
31 # Only look at relcoation lines.
32 next if (!/\s+R_/);
33
34 # These relocations are okay
Suzuki Poulose9c5f7d32011-12-14 22:58:12 +000035 # 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/);
Tony Breeds144ef902009-09-14 19:57:02 +000047
48 # If we see this type of relcoation it's an idication that
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
58if ($bad_relocs_count) {
59 print "WARNING: $bad_relocs_count bad relocations\n";
60 print $bad_relocs;
61}
62
63if ($old_binutils) {
64 print "WARNING: You need at binutils >= 2.19 to build a ".
65 "CONFIG_RELCOATABLE kernel\n";
66}