diff options
author | Michael Brown <mcb30@etherboot.org> | 2009-04-27 14:04:35 +0100 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2009-04-27 14:04:35 +0100 |
commit | 7c47ebd65c6a314435687296740b4e81b34f0edd (patch) | |
tree | f5ee7fc8dda78bb26dab0a023959ffc3252a0b61 /src/include/compiler.h | |
parent | 6e764282dde4aa433f8ddc60b2271085dad36510 (diff) | |
download | ipxe-7c47ebd65c6a314435687296740b4e81b34f0edd.tar.gz |
[build] Add {PROVIDE,REQUIRE}_SYMBOL macros and tidy up compiler.h
Diffstat (limited to 'src/include/compiler.h')
-rw-r--r-- | src/include/compiler.h | 109 |
1 files changed, 68 insertions, 41 deletions
diff --git a/src/include/compiler.h b/src/include/compiler.h index be3ce46fc..d23c16728 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -24,6 +24,50 @@ * */ +/* Force visibility of all symbols to "hidden", i.e. inform gcc that + * all symbol references resolve strictly within our final binary. + * This avoids unnecessary PLT/GOT entries on x86_64. + * + * This is a stronger claim than specifying "-fvisibility=hidden", + * since it also affects symbols marked with "extern". + */ +#ifndef ASSEMBLY +#if __GNUC__ >= 4 +#pragma GCC visibility push(hidden) +#endif +#endif /* ASSEMBLY */ + +/** + * @defgroup symmacros Macros to provide or require explicit symbols + * @{ + */ + +/** Provide a symbol within this object file */ +#ifdef ASSEMBLY +#define PROVIDE_SYMBOL( _sym ) \ + .globl _sym ; \ + .comm _sym, 0 +#else /* ASSEMBLY */ +#define PROVIDE_SYMBOL( _sym ) \ + char _sym[0] +#endif /* ASSEMBLY */ + +/** Require a symbol within this object file */ +#ifdef ASSEMBLY +#define REQUIRE_SYMBOL( _sym ) \ + .equ __need_ # _sym, _sym +#else /* ASSEMBLY */ +#define REQUIRE_SYMBOL( _sym ) \ + __asm__ ( ".equ\t__need_" #_sym ", " #_sym ) +#endif /* ASSEMBLY */ + +/** @} */ + +/** + * @defgroup objmacros Macros to provide or require explicit objects + * @{ + */ + /* Not quite sure why cpp requires two levels of macro call in order * to actually expand OBJECT... */ @@ -31,44 +75,24 @@ #define _H1( x, y ) x ## y #undef _H2 #define _H2( x, y ) _H1 ( x, y ) -#define PREFIX_OBJECT(prefix) _H2 ( prefix, OBJECT ) -#define OBJECT_SYMBOL PREFIX_OBJECT(obj_) -#undef _STR -#define _STR(s) #s -#undef _XSTR -#define _XSTR(s) _STR(s) -#define OBJECT_SYMBOL_STR _XSTR ( OBJECT_SYMBOL ) - -#ifdef ASSEMBLY +#define PREFIX_OBJECT( _prefix ) _H2 ( _prefix, OBJECT ) +#define OBJECT_SYMBOL PREFIX_OBJECT ( obj_ ) - .globl OBJECT_SYMBOL - .equ OBJECT_SYMBOL, 0 +/** Always provide the symbol for the current object (defined by -DOBJECT) */ +PROVIDE_SYMBOL ( OBJECT_SYMBOL ); -#else /* ASSEMBLY */ +/** Explicitly require another object */ +#define REQUIRE_OBJECT( _obj ) REQUIRE_SYMBOL ( obj_ ## _obj ) -__asm__ ( ".globl\t" OBJECT_SYMBOL_STR ); -__asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" ); +/** @} */ -/** - * Drag in an object by object name. - * - * Macro to allow objects to explicitly drag in other objects by - * object name. Used by config.c. - * - */ -#define REQUIRE_OBJECT(object) \ - __asm__ ( ".equ\tneed_" #object ", obj_" #object ); +/** Select file identifier for errno.h (if used) */ +#define ERRFILE PREFIX_OBJECT ( ERRFILE_ ) -/* Force visibility of all symbols to "hidden", i.e. inform gcc that - * all symbol references resolve strictly within our final binary. - * This avoids unnecessary PLT/GOT entries on x86_64. - * - * This is a stronger claim than specifying "-fvisibility=hidden", - * since it also affects symbols marked with "extern". +/** @defgroup dbg Debugging infrastructure + * @{ */ -#if __GNUC__ >= 4 -#pragma GCC visibility push(hidden) -#endif +#ifndef ASSEMBLY /** @def DBG * @@ -117,12 +141,7 @@ __asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" ); * DEBUG_LEVEL will be inserted into the object file. * */ -#define DEBUG_SYMBOL PREFIX_OBJECT(debug_) - -#if DEBUG_SYMBOL -#define DEBUG_SYMBOL_STR _XSTR ( DEBUG_SYMBOL ) -__asm__ ( ".equ\tDBGLVL, " DEBUG_SYMBOL_STR ); -#endif +#define DEBUG_SYMBOL PREFIX_OBJECT ( debug_ ) /** printf() for debugging * @@ -305,8 +324,13 @@ int __debug_disable; #define NDEBUG #endif -/** Select file identifier for errno.h (if used) */ -#define ERRFILE PREFIX_OBJECT ( ERRFILE_ ) +#endif /* ASSEMBLY */ +/** @} */ + +/** @defgroup attrs Miscellaneous attributes + * @{ + */ +#ifndef ASSEMBLY /** Declare a data structure as packed. */ #define PACKED __attribute__ (( packed )) @@ -374,11 +398,14 @@ int __debug_disable; */ #define __shared __asm__ ( "_shared_bss" ) __aligned +#endif /* ASSEMBLY */ +/** @} */ + /** * Optimisation barrier */ +#ifndef ASSEMBLY #define barrier() __asm__ __volatile__ ( "" : : : "memory" ) - #endif /* ASSEMBLY */ #include <bits/compiler.h> |