gensymlist.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #include <../config-util.h>
  33. EOF
  34. for i in $*; do
  35. echo "#include <$i>"
  36. done
  37. cat <<EOF
  38. #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
  39. #pragma GCC diagnostic ignored "-Wmissing-format-attribute"
  40. void
  41. grub_register_exported_symbols (void)
  42. {
  43. EOF
  44. cat <<EOF
  45. struct symtab { const char *name; void *addr; int isfunc; };
  46. struct symtab *p;
  47. static struct symtab tab[] =
  48. {
  49. EOF
  50. (while read LINE; do echo $LINE; done) \
  51. | grep -v '^#' \
  52. | sed -n \
  53. -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/ {"\1", \1, 1},/;p;}' \
  54. -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", (void *) \&\1, 0},/;p;}' \
  55. | sort -u
  56. cat <<EOF
  57. {0, 0, 0}
  58. };
  59. COMPILE_TIME_ASSERT (sizeof (tab) > sizeof (tab[0]));
  60. for (p = tab; p->name; p++)
  61. grub_dl_register_symbol (p->name, p->addr, p->isfunc, 0);
  62. }
  63. EOF