Advertisement
Guest User

PETOOH_LANG

a guest
Apr 5th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #define DECLARE_CN(type, name, str_name) \
  2. extern type name __attribute__((__visibility__("hidden")));
  3.  
  4.  
  5. #define DEFINE_CN(type, name, str_name) \
  6. DEFINE_HIDDEN_VAR_IN_SEC__(type,name,".CN,\"aw\",@nobits#") \
  7. static const p_cn_desc_t name ## _descriptor__ = { \
  8. str_name, (p_cn_t *) &name, 0 }; \
  9. static const p_cn_desc_t *name ## _descriptor_ref__ \
  10. __attribute__((__used__,__section__(".CNDESC"))) = \
  11. &name ## _descriptor__;
  12.  
  13.  
  14. #define DEFINE_HIDDEN_VAR_IN_SEC__(type,name,section) \
  15. DEFINE_HIDDEN_VAR_IN_SEC_INTERNAL__(type,name,section,__CN__)
  16. #define DEFINE_HIDDEN_VAR_IN_SEC_INTERNAL__(type,name,section,i) \
  17. extern type name __attribute__((__visibility__("hidden"))); \
  18. static void __attribute__((__used__,__section__(".discard"))) \
  19. CONCAT__(declare_variable_in_section__, i) () { \
  20. __asm__( \
  21. ".type\t" #name ", @object;\n" \
  22. "\t.pushsection\t" section "\n" \
  23. "\t.hidden\t" #name "\n" \
  24. "\t.globl\t" #name "\n" \
  25. "\t.align\t%c0;\n" \
  26. #name ":\n" \
  27. "\t.zero\t%c1\n" \
  28. "\t.size\t" #name ", %c1\n" \
  29. "\t.popsection" \
  30. ::"i"(__alignof__(type)), "i"(sizeof(type))); \
  31. }
  32. #define CONCAT__(a,b) a ## b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement