[PATCH] kbuild, sparseirq: work around GCC bug with __weak aliases

From: Ingo Molnar
Date: Fri Dec 26 2008 - 08:39:51 EST


Impact: fix panic on null pointer with sparseirq

Certain versions of GCC inline the weak global functions.
Work it around by marking __weak functions as noinline.

Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
---
include/linux/compiler-gcc.h | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 5c8351b..1ad72e6 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -41,11 +41,17 @@

#define __deprecated __attribute__((deprecated))
#define __packed __attribute__((packed))
-#define __weak __attribute__((weak))
#define __naked __attribute__((naked))
#define __noreturn __attribute__((noreturn))

/*
+ * Mark weak aliases also noinline, because some GCC versions
+ * incorrectly inline weak aliases (even when a non-weak variant
+ * is there) and thus cause crashes:
+ */
+#define __weak __attribute__((weak)) noinline
+
+/*
* From the GCC manual:
*
* Many functions have no effects except the return value and their
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/