Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define DECLARE_CN(type, name, str_name) \
- extern type name __attribute__((__visibility__("hidden")));
- #define DEFINE_CN(type, name, str_name) \
- DEFINE_HIDDEN_VAR_IN_SEC__(type,name,".CN,\"aw\",@nobits#") \
- static const p_cn_desc_t name ## _descriptor__ = { \
- str_name, (p_cn_t *) &name, 0 }; \
- static const p_cn_desc_t *name ## _descriptor_ref__ \
- __attribute__((__used__,__section__(".CNDESC"))) = \
- &name ## _descriptor__;
- #define DEFINE_HIDDEN_VAR_IN_SEC__(type,name,section) \
- DEFINE_HIDDEN_VAR_IN_SEC_INTERNAL__(type,name,section,__CN__)
- #define DEFINE_HIDDEN_VAR_IN_SEC_INTERNAL__(type,name,section,i) \
- extern type name __attribute__((__visibility__("hidden"))); \
- static void __attribute__((__used__,__section__(".discard"))) \
- CONCAT__(declare_variable_in_section__, i) () { \
- __asm__( \
- ".type\t" #name ", @object;\n" \
- "\t.pushsection\t" section "\n" \
- "\t.hidden\t" #name "\n" \
- "\t.globl\t" #name "\n" \
- "\t.align\t%c0;\n" \
- #name ":\n" \
- "\t.zero\t%c1\n" \
- "\t.size\t" #name ", %c1\n" \
- "\t.popsection" \
- ::"i"(__alignof__(type)), "i"(sizeof(type))); \
- }
- #define CONCAT__(a,b) a ## b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement