From 8ee6d216e4aabeeee525430b453733874948eddb Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 14 Jul 2010 10:13:44 +0100 Subject: [PATCH] [build] Mark weak functions noinline Weak functions whose visibility is hidden may be inlined due to a bug in GCC. Explicitly mark weak functions noinline to work around the problem. This makes the PXE_MENU config option work again, the PXE boot menu was never being called because the compiler inlined a weak stub function. The GCC bug was identified and fixed by Richard Sandiford but in the meantime iPXE needs to implement a workaround. Reported-by: Steve Jones Reported-by: Shao Miller Suggested-by: Joshua Oreman Signed-off-by: Stefan Hajnoczi Modified-by: Michael Brown Signed-off-by: Michael Brown --- src/include/compiler.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/include/compiler.h b/src/include/compiler.h index 66e275c2..16165b36 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -181,8 +181,15 @@ REQUEST_EXPANDED ( CONFIG_SYMBOL ); #ifndef ASSEMBLY -/** Declare a function as weak (use *before* the definition) */ -#define __weak __attribute__ (( weak )) +/** Declare a function as weak (use *before* the definition) + * + * Due to a bug in at least GCC 4.4.4 and earlier, weak symbols may be + * inlined if they have hidden visibility (see above for why hidden + * visibility is used). This results in the non-weak symbol never + * being used, so explicitly mark the function as noinline to prevent + * inlining. + */ +#define __weak __attribute__ (( weak, noinline )) #endif