relocs_check.pl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/perl
  2. # Copyright © 2009 IBM Corporation
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version
  6. # 2 of the License, or (at your option) any later version.
  7. # This script checks the relcoations of a vmlinux for "suspicious"
  8. # relocations.
  9. use strict;
  10. use warnings;
  11. if ($#ARGV != 1) {
  12. die "$0 [path to objdump] [path to vmlinux]\n";
  13. }
  14. # Have Kbuild supply the path to objdump so we handle cross compilation.
  15. my $objdump = shift;
  16. my $vmlinux = shift;
  17. my $bad_relocs_count = 0;
  18. my $bad_relocs = "";
  19. my $old_binutils = 0;
  20. open(FD, "$objdump -R $vmlinux|") or die;
  21. while (<FD>) {
  22. study $_;
  23. # Only look at relcoation lines.
  24. next if (!/\s+R_/);
  25. # These relocations are okay
  26. next if (/R_PPC64_RELATIVE/ or /R_PPC64_NONE/ or
  27. /R_PPC64_ADDR64\s+mach_/);
  28. # If we see this type of relcoation it's an idication that
  29. # we /may/ be using an old version of binutils.
  30. if (/R_PPC64_UADDR64/) {
  31. $old_binutils++;
  32. }
  33. $bad_relocs_count++;
  34. $bad_relocs .= $_;
  35. }
  36. if ($bad_relocs_count) {
  37. print "WARNING: $bad_relocs_count bad relocations\n";
  38. print $bad_relocs;
  39. }
  40. if ($old_binutils) {
  41. print "WARNING: You need at binutils >= 2.19 to build a ".
  42. "CONFIG_RELCOATABLE kernel\n";
  43. }