Browse Source

[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
<rdsandiford@googlemail.com> but in the meantime iPXE needs to
implement a workaround.

Reported-by: Steve Jones <steve@squaregoldfish.co.uk>
Reported-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Suggested-by: Joshua Oreman <oremanj@rwcr.net>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Stefan Hajnoczi 14 years ago
parent
commit
8ee6d216e4
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      src/include/compiler.h

+ 9
- 2
src/include/compiler.h View File

181
 
181
 
182
 #ifndef ASSEMBLY
182
 #ifndef ASSEMBLY
183
 
183
 
184
-/** Declare a function as weak (use *before* the definition) */
185
-#define __weak		__attribute__ (( weak ))
184
+/** Declare a function as weak (use *before* the definition)
185
+ *
186
+ * Due to a bug in at least GCC 4.4.4 and earlier, weak symbols may be
187
+ * inlined if they have hidden visibility (see above for why hidden
188
+ * visibility is used).  This results in the non-weak symbol never
189
+ * being used, so explicitly mark the function as noinline to prevent
190
+ * inlining.
191
+ */
192
+#define __weak		__attribute__ (( weak, noinline ))
186
 
193
 
187
 #endif
194
 #endif
188
 
195
 

Loading…
Cancel
Save