On Wed, Jul 14, 2010 at 2:13 AM, Stefan Hajnoczi <[email protected]> wrote: > 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.
ACK. Thanks for putting this together. -- Josh > 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 > <[email protected]> but in the meantime gPXE needs to implement > a workaround. > > Reported-by: Steve Jones <[email protected]> > Reported-by: Shao Miller <[email protected]> > Suggested-by: Joshua Oreman <[email protected]> > Signed-off-by: Stefan Hajnoczi <[email protected]> > --- > src/include/compiler.h | 10 ++++++++-- > 1 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/src/include/compiler.h b/src/include/compiler.h > index 8ccc69c..926308b 100644 > --- a/src/include/compiler.h > +++ b/src/include/compiler.h > @@ -181,8 +181,14 @@ 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 )) __attribute (( noinline )) > > #endif > > -- > 1.7.1 > > _______________________________________________ gPXE-devel mailing list [email protected] http://etherboot.org/mailman/listinfo/gpxe-devel
