gensymlist.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /bin/sh
  2. #
  3. # Copyright (C) 2002,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
  4. #
  5. # This gensymlist.sh.in is free software; the author
  6. # gives unlimited permission to copy and/or distribute it,
  7. # with or without modifications, as long as this notice is preserved.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  11. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12. # PARTICULAR PURPOSE.
  13. cat <<EOF
  14. /* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
  15. /*
  16. * GRUB -- GRand Unified Bootloader
  17. * Copyright (C) 2002,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
  18. *
  19. * GRUB is free software: you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License as published by
  21. * the Free Software Foundation, either version 3 of the License, or
  22. * (at your option) any later version.
  23. *
  24. * GRUB is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  31. */
  32. EOF
  33. for i in $*; do
  34. echo "#include <$i>"
  35. done
  36. cat <<EOF
  37. #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
  38. #pragma GCC diagnostic ignored "-Wmissing-format-attribute"
  39. void
  40. grub_register_exported_symbols (void)
  41. {
  42. EOF
  43. cat <<EOF
  44. struct symtab { const char *name; void *addr; int isfunc; };
  45. struct symtab *p;
  46. static struct symtab tab[] =
  47. {
  48. EOF
  49. (while read LINE; do echo $LINE; done) \
  50. | grep -v '^#' \
  51. | sed -n \
  52. -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/ {"\1", \1, 1},/;p;}' \
  53. -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", (void *) \&\1, 0},/;p;}' \
  54. | sort -u
  55. cat <<EOF
  56. {0, 0, 0}
  57. };
  58. COMPILE_TIME_ASSERT (sizeof (tab) > sizeof (tab[0]));
  59. for (p = tab; p->name; p++)
  60. grub_dl_register_symbol (p->name, p->addr, p->isfunc, 0);
  61. }
  62. EOF