33 lines
914 B
C
33 lines
914 B
C
#include <stdio.h>
|
|
|
|
#define __stringify_1(x) #x
|
|
#define __stringify(x) __stringify_1(x)
|
|
|
|
#define __ADDRESSABLE(sym) \
|
|
static void * __addressable_##sym __attribute__((used)) = (void *)&(sym)
|
|
|
|
#define __GENDWARFKSYMS_EXPORT(sym) /* nothing */
|
|
|
|
#define ASM_NL "\n"
|
|
|
|
#define __EXPORT_SYMBOL_REF(sym) \
|
|
".balign 8" ASM_NL \
|
|
".quad " __stringify(sym)
|
|
|
|
#define ___EXPORT_SYMBOL(sym, license, ns...) \
|
|
".section \".export_symbol\",\"a\"" ASM_NL \
|
|
"__export_symbol_" __stringify(sym) ":" ASM_NL \
|
|
".asciz \"" license "\"" ASM_NL \
|
|
".ascii \"" ns "\\0\"" ASM_NL \
|
|
__EXPORT_SYMBOL_REF(sym) ASM_NL \
|
|
".previous"
|
|
|
|
#define __EXPORT_SYMBOL(sym, license, ns) \
|
|
extern typeof(sym) sym; \
|
|
__ADDRESSABLE(sym); \
|
|
__GENDWARFKSYMS_EXPORT(sym); \
|
|
asm(___EXPORT_SYMBOL(sym, license, ns))
|
|
|
|
#define EXPORT_SYMBOL(sym) __EXPORT_SYMBOL(sym, "license", "namespace")
|
|
|