summaryrefslogtreecommitdiffstats
path: root/src/include/compiler.h
diff options
context:
space:
mode:
authorJoshua Oreman2010-05-27 02:52:44 +0200
committerMichael Brown2010-05-27 11:19:14 +0200
commit2aad3fab233f0235f9a8f677ae7bb402f1647eb6 (patch)
treec4630d1f9e5a2c9d21b7018c63fe20878d1c00af /src/include/compiler.h
parent[efi] Fix link order for elf2efi (diff)
downloadipxe-2aad3fab233f0235f9a8f677ae7bb402f1647eb6.tar.gz
ipxe-2aad3fab233f0235f9a8f677ae7bb402f1647eb6.tar.xz
ipxe-2aad3fab233f0235f9a8f677ae7bb402f1647eb6.zip
[build] Use weak definitions instead of weak declarations
This removes the need for inline safety wrappers, marginally reducing the size penalty of weak functions, and works around an apparent binutils bug that causes undefined weak symbols to not actually be NULL when compiling with -fPIE (as EFI builds do). A bug in versions of binutils prior to 2.16 (released in 2005) will cause same-file weak definitions to not work with those toolchains. Update the README to reflect our new dependency on binutils >= 2.16. 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.h33
1 files changed, 2 insertions, 31 deletions
diff --git a/src/include/compiler.h b/src/include/compiler.h
index a9067c94..654eaac2 100644
--- a/src/include/compiler.h
+++ b/src/include/compiler.h
@@ -179,41 +179,12 @@ REQUEST_EXPANDED ( CONFIG_SYMBOL );
/** Select file identifier for errno.h (if used) */
#define ERRFILE PREFIX_OBJECT ( ERRFILE_ )
-/**
- * @defgroup weakmacros Macros to manage weak symbol definitions
- *
- * Weak symbols allow one to reference a function in another file
- * without necessarily requiring that file to be linked in. In their
- * native form, the function will be @c NULL if its file is not linked
- * in; these macros provide an inline wrapper that returns an
- * appropriate error indication or default value.
- *
- * @{
- */
#ifndef ASSEMBLY
-/** Mangle @a name into its weakly-referenced implementation */
-#define __weak_impl( name ) _w_ ## name
-
-/**
- * Declare a weak function with inline safety wrapper
- *
- * @v ret Return type of weak function
- * @v name Name of function to expose
- * @v proto Parenthesized list of arguments with types
- * @v args Parenthesized list of argument names
- * @v dfl Value to return if weak function is not available
- */
-#define __weak_decl( ret, name, proto, args, dfl ) \
- ret __weak_impl( name ) proto __attribute__ (( weak )); \
- static inline ret name proto { \
- if ( __weak_impl( name ) ) \
- return __weak_impl( name ) args; \
- return dfl; \
- }
+/** Declare a function as weak (use *before* the definition) */
+#define __weak __attribute__ (( weak ))
#endif
-/** @} */
/** @defgroup dbg Debugging infrastructure
* @{