generic.em 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. # This shell script emits a C file. -*- C -*-
  2. # It does some substitutions.
  3. fragment <<EOF
  4. /* This file is is generated by a shell script. DO NOT EDIT! */
  5. /* emulate the original gld for the given ${EMULATION_NAME}
  6. Copyright (C) 1991-2015 Free Software Foundation, Inc.
  7. Written by Steve Chamberlain steve@cygnus.com
  8. This file is part of the GNU Binutils.
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 3 of the License, or
  12. (at your option) any later version.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  20. MA 02110-1301, USA. */
  21. #define TARGET_IS_${EMULATION_NAME}
  22. #include "sysdep.h"
  23. #include "bfd.h"
  24. #include "bfdlink.h"
  25. #include "ld.h"
  26. #include "ldmain.h"
  27. #include "ldmisc.h"
  28. #include "ldexp.h"
  29. #include "ldlang.h"
  30. #include "ldfile.h"
  31. #include "ldemul.h"
  32. EOF
  33. # Import any needed special functions and/or overrides.
  34. #
  35. if test -n "$EXTRA_EM_FILE" ; then
  36. source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
  37. fi
  38. if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
  39. fragment <<EOF
  40. static void
  41. gld${EMULATION_NAME}_before_parse (void)
  42. {
  43. #ifndef TARGET_ /* I.e., if not generic. */
  44. ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
  45. #endif /* not TARGET_ */
  46. EOF
  47. # The MSP430 port *needs* linker relaxtion in order to cope with large
  48. # functions where conditional branches do not fit into a +/- 1024 byte range.
  49. case ${target} in
  50. msp430-*-* )
  51. fragment <<EOF
  52. if (!bfd_link_relocatable (&link_info))
  53. TARGET_ENABLE_RELAXATION;
  54. EOF
  55. ;;
  56. esac
  57. fragment <<EOF
  58. }
  59. EOF
  60. fi
  61. if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
  62. fragment <<EOF
  63. static char *
  64. gld${EMULATION_NAME}_get_script (int *isfile)
  65. EOF
  66. if test x"$COMPILE_IN" = xyes
  67. then
  68. # Scripts compiled in.
  69. # sed commands to quote an ld script as a C string.
  70. sc="-f stringify.sed"
  71. fragment <<EOF
  72. {
  73. *isfile = 0;
  74. if (bfd_link_relocatable (&link_info) && config.build_constructors)
  75. return
  76. EOF
  77. sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
  78. echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
  79. sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
  80. echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
  81. sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
  82. echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
  83. sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
  84. echo ' ; else return' >> e${EMULATION_NAME}.c
  85. sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
  86. echo '; }' >> e${EMULATION_NAME}.c
  87. else
  88. # Scripts read from the filesystem.
  89. fragment <<EOF
  90. {
  91. *isfile = 1;
  92. if (bfd_link_relocatable (&link_info) && config.build_constructors)
  93. return "ldscripts/${EMULATION_NAME}.xu";
  94. else if (bfd_link_relocatable (&link_info))
  95. return "ldscripts/${EMULATION_NAME}.xr";
  96. else if (!config.text_read_only)
  97. return "ldscripts/${EMULATION_NAME}.xbn";
  98. else if (!config.magic_demand_paged)
  99. return "ldscripts/${EMULATION_NAME}.xn";
  100. else
  101. return "ldscripts/${EMULATION_NAME}.x";
  102. }
  103. EOF
  104. fi
  105. fi
  106. fragment <<EOF
  107. struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
  108. {
  109. ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
  110. ${LDEMUL_SYSLIB-syslib_default},
  111. ${LDEMUL_HLL-hll_default},
  112. ${LDEMUL_AFTER_PARSE-after_parse_default},
  113. ${LDEMUL_AFTER_OPEN-after_open_default},
  114. ${LDEMUL_AFTER_ALLOCATION-after_allocation_default},
  115. ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
  116. ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
  117. ${LDEMUL_BEFORE_ALLOCATION-before_allocation_default},
  118. ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
  119. "${EMULATION_NAME}",
  120. "${OUTPUT_FORMAT}",
  121. ${LDEMUL_FINISH-finish_default},
  122. ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
  123. ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-NULL},
  124. ${LDEMUL_PLACE_ORPHAN-NULL},
  125. ${LDEMUL_SET_SYMBOLS-NULL},
  126. ${LDEMUL_PARSE_ARGS-NULL},
  127. ${LDEMUL_ADD_OPTIONS-NULL},
  128. ${LDEMUL_HANDLE_OPTION-NULL},
  129. ${LDEMUL_UNRECOGNIZED_FILE-NULL},
  130. ${LDEMUL_LIST_OPTIONS-NULL},
  131. ${LDEMUL_RECOGNIZED_FILE-NULL},
  132. ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
  133. ${LDEMUL_NEW_VERS_PATTERN-NULL},
  134. ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL}
  135. };
  136. EOF