vxworks.em 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # This shell script emits a C file. -*- C -*-
  2. # Copyright (C) 2006-2015 Free Software Foundation, Inc.
  3. #
  4. # This file is part of the GNU Binutils.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  19. # MA 02110-1301, USA.
  20. #
  21. if test -n "$VXWORKS_BASE_EM_FILE" ; then
  22. source_em "${srcdir}/emultempl/${VXWORKS_BASE_EM_FILE}.em"
  23. fi
  24. fragment <<EOF
  25. static int force_dynamic;
  26. static void
  27. vxworks_before_parse (void)
  28. {
  29. ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse} ();
  30. config.rpath_separator = ';';
  31. }
  32. static void
  33. vxworks_after_open (void)
  34. {
  35. ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open} ();
  36. if (force_dynamic
  37. && link_info.input_bfds
  38. && bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
  39. && !_bfd_elf_link_create_dynamic_sections (link_info.input_bfds,
  40. &link_info))
  41. einfo ("%X%P: Cannot create dynamic sections %E\n");
  42. if (!force_dynamic
  43. && !bfd_link_pic (&link_info)
  44. && bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
  45. && elf_hash_table (&link_info)->dynamic_sections_created)
  46. einfo ("%X%P: Dynamic sections created in non-dynamic link\n");
  47. }
  48. EOF
  49. PARSE_AND_LIST_PROLOGUE=$PARSE_AND_LIST_PROLOGUE'
  50. enum {
  51. OPTION_FORCE_DYNAMIC = 501
  52. };
  53. '
  54. PARSE_AND_LIST_LONGOPTS=$PARSE_AND_LIST_LONGOPTS'
  55. {"force-dynamic", no_argument, NULL, OPTION_FORCE_DYNAMIC},
  56. '
  57. PARSE_AND_LIST_OPTIONS=$PARSE_AND_LIST_OPTIONS'
  58. fprintf (file, _("\
  59. --force-dynamic Always create dynamic sections\n"));
  60. '
  61. PARSE_AND_LIST_ARGS_CASES=$PARSE_AND_LIST_ARGS_CASES'
  62. case OPTION_FORCE_DYNAMIC:
  63. force_dynamic = 1;
  64. break;
  65. '
  66. # Hook in our routines above. There are three possibilities:
  67. #
  68. # (1) VXWORKS_BASE_EM_FILE did not set the hook's LDEMUL_FOO variable.
  69. # We want to define LDEMUL_FOO to vxworks_foo in that case,
  70. #
  71. # (2) VXWORKS_BASE_EM_FILE set the hook's LDEMUL_FOO variable to
  72. # gld${EMULATION_NAME}_foo. This means that the file has
  73. # replaced elf32.em's default definition, so we simply #define
  74. # the current value of LDEMUL_FOO to vxworks_foo.
  75. #
  76. # (3) VXWORKS_BASE_EM_FILE set the hook's LDEMUL_FOO variable to
  77. # something other than gld${EMULATION_NAME}_foo. We handle
  78. # this case in the same way as (1).
  79. for override in before_parse after_open; do
  80. var="LDEMUL_`echo ${override} | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`"
  81. eval value=\$${var}
  82. if test "${value}" = "gld${EMULATION_NAME}_${override}"; then
  83. fragment <<EOF
  84. #define ${value} vxworks_${override}
  85. EOF
  86. else
  87. eval $var=vxworks_${override}
  88. fi
  89. done