x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / powerpc / relocs_check.pl
blob3f46e8b9c56d7b51e045a48679ac46d26c7c67f3
1 #!/usr/bin/perl
3 # Copyright © 2009 IBM Corporation
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.
10 # This script checks the relocations of a vmlinux for "suspicious"
11 # relocations.
13 use strict;
14 use warnings;
16 if ($#ARGV != 1) {
17 die "$0 [path to objdump] [path to vmlinux]\n";
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;
27 open(FD, "$objdump -R $vmlinux|") or die;
28 while (<FD>) {
29 study $_;
31 # Only look at relocation lines.
32 next if (!/\s+R_/);
34 # These relocations are okay
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
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/);
48 # If we see this type of relocation it's an idication that
49 # we /may/ be using an old version of binutils.
50 if (/R_PPC64_UADDR64/) {
51 $old_binutils++;
54 $bad_relocs_count++;
55 $bad_relocs .= $_;
58 if ($bad_relocs_count) {
59 print "WARNING: $bad_relocs_count bad relocations\n";
60 print $bad_relocs;
63 if ($old_binutils) {
64 print "WARNING: You need at least binutils >= 2.19 to build a ".
65 "CONFIG_RELOCATABLE kernel\n";