aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/relocs_check.pl
diff options
context:
space:
mode:
authorTony Breeds <tony@bakeyournoodle.com>2009-09-14 15:57:02 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-09-24 01:31:40 -0400
commit144ef909c09b60c97b3c20b69ea30abd1e60e54d (patch)
treebfade6f9d26ea4fddaf72e7c7f10102758fcacb6 /arch/powerpc/relocs_check.pl
parentad08587e5df17e192a57437bfedaba125998de25 (diff)
powerpc: Check for unsupported relocs when using CONFIG_RELOCATABLE
When using CONFIG_RELOCATABLE, we build the kernel as a position independent executable. The kernel then uses a little bit of relocation code to relocate itself. That code only deals with R_PPC64_RELATIVE relocations though. If for some reason you use assembly constructs such as LOAD_REG_IMMEDIATE() to load the address of a symbol, you'll generate different kinds of relocations that won't be processed properly and bad things will happen. (We have 2 such bugs today). The perl script tries to filter out "known" bad ones. It's possible that we are missing some in the case of a weak function that nobody implements, we'll see if we get false positive and fix it. Signed-off-by: Tony Breeds <tony@bakeyournoodle.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/relocs_check.pl')
-rwxr-xr-xarch/powerpc/relocs_check.pl56
1 files changed, 56 insertions, 0 deletions
diff --git a/arch/powerpc/relocs_check.pl b/arch/powerpc/relocs_check.pl
new file mode 100755
index 000000000000..d2571096c3e9
--- /dev/null
+++ b/arch/powerpc/relocs_check.pl
@@ -0,0 +1,56 @@
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
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
35 next if (/R_PPC64_RELATIVE/ or /R_PPC64_NONE/ or
36 /R_PPC64_ADDR64\s+mach_/);
37
38 # If we see this type of relcoation it's an idication that
39 # we /may/ be using an old version of binutils.
40 if (/R_PPC64_UADDR64/) {
41 $old_binutils++;
42 }
43
44 $bad_relocs_count++;
45 $bad_relocs .= $_;
46}
47
48if ($bad_relocs_count) {
49 print "WARNING: $bad_relocs_count bad relocations\n";
50 print $bad_relocs;
51}
52
53if ($old_binutils) {
54 print "WARNING: You need at binutils >= 2.19 to build a ".
55 "CONFIG_RELCOATABLE kernel\n";
56}