symbol.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 1999,2000,2001,2002,2006,2007,2008,2009 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef GRUB_SYMBOL_HEADER
  19. #define GRUB_SYMBOL_HEADER 1
  20. #include <config.h>
  21. /* Apple assembler requires local labels to start with a capital L */
  22. #define LOCAL(sym) L_ ## sym
  23. /* Add an underscore to a C symbol in assembler code if needed. */
  24. #ifdef HAVE_ASM_USCORE
  25. # define EXT_C(sym) _ ## sym
  26. #else
  27. # define EXT_C(sym) sym
  28. #endif
  29. #define FUNCTION(x) EXT_C(x): .globl EXT_C(x)
  30. #define VARIABLE(x) EXT_C(x): .globl EXT_C(x)
  31. /* Mark an exported symbol. */
  32. #ifndef GRUB_SYMBOL_GENERATOR
  33. # define EXPORT_FUNC(x) x
  34. # define EXPORT_VAR(x) x
  35. #endif /* ! GRUB_SYMBOL_GENERATOR */
  36. #ifdef ASM_FILE
  37. #ifdef APPLE_CC
  38. #define GRUB_EXPORT_START .section modattr,modattr,regular
  39. #elif defined(__MINGW32__) || defined(__CYGWIN__)
  40. #define GRUB_EXPORT_START .section modattr
  41. #else
  42. #define GRUB_EXPORT_START .section "modattr"
  43. #endif
  44. #define GRUB_EXPORT(name) .ascii "export:",#name,"\0"
  45. #define GRUB_EXPORT_END .text
  46. #else
  47. #ifdef APPLE_CC
  48. #define GRUB_MODATTR(name, value) \
  49. __asm (".section modattr,modattr\n.asciz \"" name ":" value "\"\n.text")
  50. #elif defined(__MINGW32__) || defined(__CYGWIN__)
  51. #define GRUB_MODATTR(name, value) \
  52. __asm (".section modattr\n.asciz \"" name ":" value "\"\n.text")
  53. #else
  54. #define GRUB_MODATTR(name, value) \
  55. __asm (".section \"modattr\"\n.asciz \"" name ":" value "\"\n.text")
  56. #endif
  57. #define GRUB_EXPORT(value) GRUB_MODATTR("export", #value)
  58. #endif
  59. #endif /* ! GRUB_SYMBOL_HEADER */