diff options
author | Tony Breeds <tony@bakeyournoodle.com> | 2009-09-14 23:57:02 +0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-09-24 09:31:40 +0400 |
commit | 144ef909c09b60c97b3c20b69ea30abd1e60e54d (patch) | |
tree | bfade6f9d26ea4fddaf72e7c7f10102758fcacb6 /arch/powerpc/relocs_check.pl | |
parent | ad08587e5df17e192a57437bfedaba125998de25 (diff) | |
download | linux-144ef909c09b60c97b3c20b69ea30abd1e60e54d.tar.xz |
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-x | arch/powerpc/relocs_check.pl | 56 |
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 @@ +#!/usr/bin/perl + +# Copyright © 2009 IBM Corporation + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version +# 2 of the License, or (at your option) any later version. + +# This script checks the relcoations of a vmlinux for "suspicious" +# relocations. + +use strict; +use warnings; + +if ($#ARGV != 1) { + die "$0 [path to objdump] [path to vmlinux]\n"; +} + +# Have Kbuild supply the path to objdump so we handle cross compilation. +my $objdump = shift; +my $vmlinux = shift; +my $bad_relocs_count = 0; +my $bad_relocs = ""; +my $old_binutils = 0; + +open(FD, "$objdump -R $vmlinux|") or die; +while (<FD>) { + study $_; + + # Only look at relcoation lines. + next if (!/\s+R_/); + + # These relocations are okay + next if (/R_PPC64_RELATIVE/ or /R_PPC64_NONE/ or + /R_PPC64_ADDR64\s+mach_/); + + # If we see this type of relcoation it's an idication that + # we /may/ be using an old version of binutils. + if (/R_PPC64_UADDR64/) { + $old_binutils++; + } + + $bad_relocs_count++; + $bad_relocs .= $_; +} + +if ($bad_relocs_count) { + print "WARNING: $bad_relocs_count bad relocations\n"; + print $bad_relocs; +} + +if ($old_binutils) { + print "WARNING: You need at binutils >= 2.19 to build a ". + "CONFIG_RELCOATABLE kernel\n"; +} |