summaryrefslogtreecommitdiffstats
path: root/src/include/compiler.h
diff options
context:
space:
mode:
authorJoshua Oreman2010-08-19 01:37:22 +0200
committerMichael Brown2010-08-19 14:37:52 +0200
commit49d6f5700561be091b2b25bb7641708333e4911d (patch)
treeac34755391ad3025d3fd817af3696d1bca3276cf /src/include/compiler.h
parent[build] Add tap.linux to "make everything" (diff)
downloadipxe-49d6f5700561be091b2b25bb7641708333e4911d.tar.gz
ipxe-49d6f5700561be091b2b25bb7641708333e4911d.tar.xz
ipxe-49d6f5700561be091b2b25bb7641708333e4911d.zip
[compiler] Prevent empty weak function stubs from being removed
Even with the noinline specifier added by commit 1a260f8, gcc may skip calls to non-inlinable functions that it knows have no side effects. This caused the get_cached_dhcpack() call in start_dhcp(), the weak stub of which has no code in its body, to be removed, preventing cached DHCP from working. Fix by adding a __keepme macro to compiler.h expanding to asm(""), as recommended by gcc's info page, and using it in the weak stub for get_cached_dhcpack(). Reported-by: Aaron Brooks <aaron@brooks1.net> Tested-by: Aaron Brooks <aaron@brooks1.net> Signed-off-by: Joshua Oreman <oremanj@rwcr.net> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/compiler.h')
-rw-r--r--src/include/compiler.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/include/compiler.h b/src/include/compiler.h
index 16165b36..738655af 100644
--- a/src/include/compiler.h
+++ b/src/include/compiler.h
@@ -191,6 +191,14 @@ REQUEST_EXPANDED ( CONFIG_SYMBOL );
*/
#define __weak __attribute__ (( weak, noinline ))
+/** Prevent a function from being optimized away without inlining
+ *
+ * Calls to functions with void return type that contain no code in their body
+ * may be removed by gcc's optimizer even when inlining is inhibited. Placing
+ * this macro in the body of the function prevents that from occurring.
+ */
+#define __keepme asm("");
+
#endif
/** @defgroup dbg Debugging infrastructure