symbol.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef GRUB_UTIL
  25. #ifdef __APPLE__
  26. #define MACRO_DOLLAR(x) $$ ## x
  27. #else
  28. #define MACRO_DOLLAR(x) $ ## x
  29. #endif
  30. #if HAVE_ASM_USCORE
  31. #ifdef ASM_FILE
  32. # define EXT_C(sym) _ ## sym
  33. #else
  34. # define EXT_C(sym) "_" sym
  35. #endif
  36. #else
  37. # define EXT_C(sym) sym
  38. #endif
  39. #ifdef __arm__
  40. #define END .end
  41. #endif
  42. #if defined (__APPLE__)
  43. #define FUNCTION(x) .globl EXT_C(x) ; EXT_C(x):
  44. #define VARIABLE(x) .globl EXT_C(x) ; EXT_C(x):
  45. #elif defined (__CYGWIN__) || defined (__MINGW32__)
  46. /* .type not supported for non-ELF targets. XXX: Check this in configure? */
  47. #define FUNCTION(x) .globl EXT_C(x) ; .def EXT_C(x); .scl 2; .type 32; .endef; EXT_C(x):
  48. #define VARIABLE(x) .globl EXT_C(x) ; .def EXT_C(x); .scl 2; .type 0; .endef; EXT_C(x):
  49. #elif defined (__arm__)
  50. #define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), %function ; EXT_C(x):
  51. #define VARIABLE(x) .globl EXT_C(x) ; .type EXT_C(x), %object ; EXT_C(x):
  52. #else
  53. #define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), @function ; EXT_C(x):
  54. #define VARIABLE(x) .globl EXT_C(x) ; .type EXT_C(x), @object ; EXT_C(x):
  55. #endif
  56. #endif
  57. /* Mark an exported symbol. */
  58. #ifndef GRUB_SYMBOL_GENERATOR
  59. # define EXPORT_FUNC(x) x
  60. # define EXPORT_VAR(x) x
  61. #endif /* ! GRUB_SYMBOL_GENERATOR */
  62. #endif /* ! GRUB_SYMBOL_HEADER */