#!/usr/bin/perl12# Copyright © 2009 IBM Corporation34# This program is free software; you can redistribute it and/or5# modify it under the terms of the GNU General Public License6# as published by the Free Software Foundation; either version7# 2 of the License, or (at your option) any later version.89# This script checks the relcoations of a vmlinux for "suspicious"10# relocations.1112use strict;13use warnings;1415if ($#ARGV != 1) {16die "$0 [path to objdump] [path to vmlinux]\n";17}1819# Have Kbuild supply the path to objdump so we handle cross compilation.20my $objdump = shift;21my $vmlinux = shift;22my $bad_relocs_count = 0;23my $bad_relocs = "";24my $old_binutils = 0;2526open(FD, "$objdump -R $vmlinux|") or die;27while (<FD>) {28study $_;2930# Only look at relcoation lines.31next if (!/\s+R_/);3233# These relocations are okay34next if (/R_PPC64_RELATIVE/ or /R_PPC64_NONE/ or35/R_PPC64_ADDR64\s+mach_/);3637# If we see this type of relcoation it's an idication that38# we /may/ be using an old version of binutils.39if (/R_PPC64_UADDR64/) {40$old_binutils++;41}4243$bad_relocs_count++;44$bad_relocs .= $_;45}4647if ($bad_relocs_count) {48print "WARNING: $bad_relocs_count bad relocations\n";49print $bad_relocs;50}5152if ($old_binutils) {53print "WARNING: You need at binutils >= 2.19 to build a ".54"CONFIG_RELCOATABLE kernel\n";55}565758