Skip to contentSkip to conversation

powerpc: Check for unsupported relocs when using CONFIG_RELOCATABLE

PATCH In review Benjamin Herrenschmidt 2 participants 2 messages Sep 15, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Check for unsupported relocs when using CONFIG_RELOCATABLE

From: Tony Breeds <[email protected]>

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.

---

arch/powerpc/Makefile +11 -0
index 952a396..0101e0c 100644
@@ -166,6 +166,17 @@ PHONY += $(BOOT_TARGETS)
 
 boot := arch/$(ARCH)/boot
 
+ifeq ($(CONFIG_RELOCATABLE),y)
+quiet_cmd_relocs_check = CALL    $<
+      cmd_relocs_check = perl $< "$(OBJDUMP)" "$(obj)/vmlinux"
+
+PHONY += relocs_check
+relocs_check: arch/powerpc/relocs_check.pl vmlinux
+	$(call cmd,relocs_check)
+
+zImage: relocs_check
+endif
+
 $(BOOT_TARGETS): vmlinux
 	$(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
 
arch/powerpc/relocs_check.pl new file +57 -0

57 lines not on this page · raw message

#1 lore raw
Quoted 13 lines · Benjamin Herrenschmidt
arch/powerpc/relocs_check.pl new file +7 -0
new file mode 100755
index 0000000..215e966
@@ -0,0 +1,57 @@
+#!/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

arch/powerpc/relocs_check.pl line 17

Quoted 10 lines
arch/powerpc/relocs_check.pl new file +10 -0
+# 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) {
+	print "$#ARGV\n";

Ooops that line should have been taken out. Sorry.

Yours Tony