elfmicroblaze.sc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. # Adapted from mips.sc
  2. #
  3. # Copyright (C) 2014-2022 Free Software Foundation, Inc.
  4. #
  5. # Copying and distribution of this file, with or without modification,
  6. # are permitted in any medium without royalty provided the copyright
  7. # notice and this notice are preserved.
  8. #
  9. # These variables may be overridden by the emulation file. The
  10. # defaults are appropriate for a DECstation running Ultrix.
  11. test -z "$ENTRY" && ENTRY=_start
  12. #test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x0"
  13. CTOR=".ctors ${CONSTRUCTING-0} :
  14. {
  15. ${CONSTRUCTING+${CTOR_START}}
  16. /* gcc uses crtbegin.o to find the start of
  17. the constructors, so we make sure it is
  18. first. Because this is a wildcard, it
  19. doesn't matter if the user does not
  20. actually link against crtbegin.o; the
  21. linker won't look for a file to match a
  22. wildcard. The wildcard also means that it
  23. doesn't matter which directory crtbegin.o
  24. is in. */
  25. KEEP (*crtbegin.o(.ctors))
  26. /* We don't want to include the .ctor section from
  27. from the crtend.o file until after the sorted ctors.
  28. The .ctor section from the crtend file contains the
  29. end of ctors marker and it must be last */
  30. KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
  31. KEEP (*(SORT(.ctors.*)))
  32. KEEP (*(.ctors))
  33. ${CONSTRUCTING+${CTOR_END}}
  34. }"
  35. DTOR=" .dtors ${CONSTRUCTING-0} :
  36. {
  37. ${CONSTRUCTING+${DTOR_START}}
  38. KEEP (*crtbegin.o(.dtors))
  39. KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
  40. KEEP (*(SORT(.dtors.*)))
  41. KEEP (*(.dtors))
  42. ${CONSTRUCTING+${DTOR_END}}
  43. }"
  44. cat <<EOF
  45. /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
  46. Copying and distribution of this script, with or without modification,
  47. are permitted in any medium without royalty provided the copyright
  48. notice and this notice are preserved. */
  49. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  50. "${LITTLE_OUTPUT_FORMAT}")
  51. /*${LIB_SEARCH_DIRS}*/
  52. ${RELOCATING+${LIB_SEARCH_DIRS}}
  53. ${RELOCATING+ENTRY (${ENTRY})}
  54. ${RELOCATING+_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50;
  55. _HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0;
  56. _STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400;}
  57. SECTIONS
  58. {
  59. .vectors.reset 0x0 : { KEEP (*(.vectors.reset)) } = 0
  60. .vectors.sw_exception 0x8 : { KEEP (*(.vectors.sw_exception)) } = 0
  61. .vectors.interrupt 0x10 : { KEEP (*(.vectors.interrupt)) } = 0
  62. .vectors.debug_sw_break 0x18 : { KEEP (*(.vectors.debug_sw_break)) } = 0
  63. .vectors.hw_exception 0x20 : { KEEP (*(.vectors.hw_exception)) } = 0
  64. ${RELOCATING+. = _TEXT_START_ADDR;}
  65. ${RELOCATING+ _ftext = .;}
  66. .text : {
  67. *(.text)
  68. ${RELOCATING+*(.text.*)}
  69. ${RELOCATING+*(.gnu.linkonce.t.*)}
  70. }
  71. ${RELOCATING+ _etext = .;}
  72. .init : { KEEP (*(SORT_NONE(.init))) } =0
  73. .fini : { KEEP (*(SORT_NONE(.fini))) } =0
  74. ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);}
  75. ${RELOCATING+PROVIDE (___CTOR_LIST__ = .);}
  76. ${RELOCATING+${CTOR}}
  77. ${RELOCATING+PROVIDE (__CTOR_END__ = .);}
  78. ${RELOCATING+PROVIDE (___CTOR_END__ = .);}
  79. ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);}
  80. ${RELOCATING+PROVIDE (___DTOR_LIST__ = .);}
  81. ${RELOCATING+${DTOR}}
  82. ${RELOCATING+PROVIDE (__DTOR_END__ = .);}
  83. ${RELOCATING+PROVIDE (___DTOR_END__ = .);}
  84. ${RELOCATING+ . = ALIGN(4);}
  85. ${RELOCATING+ _frodata = . ;}
  86. .rodata : {
  87. *(.rodata)
  88. ${RELOCATING+*(.rodata.*)}
  89. ${RELOCATING+*(.gnu.linkonce.r.*)}
  90. ${CONSTRUCTING+CONSTRUCTORS;} /* Is this needed? */
  91. }
  92. ${RELOCATING+ _erodata = .;}
  93. /* Alignments by 8 to ensure that _SDA2_BASE_ on a word boundary */
  94. /* Note that .sdata2 and .sbss2 must be contiguous */
  95. ${RELOCATING+. = ALIGN(8);}
  96. ${RELOCATING+ _ssrw = .;}
  97. .sdata2 : {
  98. *(.sdata2)
  99. ${RELOCATING+*(.sdata2.*)}
  100. ${RELOCATING+*(.gnu.linkonce.s2.*)}
  101. }
  102. ${RELOCATING+. = ALIGN(4);}
  103. .sbss2 : {
  104. ${RELOCATING+PROVIDE (__sbss2_start = .);}
  105. *(.sbss2)
  106. ${RELOCATING+*(.sbss2.*)}
  107. ${RELOCATING+*(.gnu.linkonce.sb2.*)}
  108. ${RELOCATING+PROVIDE (__sbss2_end = .);}
  109. }
  110. ${RELOCATING+. = ALIGN(8);}
  111. ${RELOCATING+ _essrw = .;}
  112. ${RELOCATING+ _ssrw_size = _essrw - _ssrw;}
  113. ${RELOCATING+ PROVIDE (_SDA2_BASE_ = _ssrw + (_ssrw_size / 2 ));}
  114. ${RELOCATING+ . = ALIGN(4);}
  115. ${RELOCATING+ _fdata = .;}
  116. .data : {
  117. *(.data)
  118. ${RELOCATING+*(.data.*)}
  119. ${RELOCATING+*(.gnu.linkonce.d.*)}
  120. ${CONSTRUCTING+CONSTRUCTORS;} /* Is this needed? */
  121. }
  122. ${RELOCATING+ _edata = . ;}
  123. /* Added to handle pic code */
  124. .got : {
  125. *(.got)
  126. }
  127. .got1 : {
  128. *(.got1)
  129. }
  130. .got2 : {
  131. *(.got2)
  132. }
  133. /* Added by Sathya to handle C++ exceptions */
  134. .eh_frame : {
  135. *(.eh_frame)
  136. }
  137. .jcr : {
  138. *(.jcr)
  139. }
  140. .gcc_except_table : {
  141. *(.gcc_except_table)
  142. }
  143. /* Alignments by 8 to ensure that _SDA_BASE_ on a word boundary */
  144. /* Note that .sdata and .sbss must be contiguous */
  145. ${RELOCATING+. = ALIGN(8);}
  146. ${RELOCATING+ _ssro = .;}
  147. .sdata : {
  148. *(.sdata)
  149. ${RELOCATING+*(.sdata.*)}
  150. ${RELOCATING+*(.gnu.linkonce.s.*)}
  151. }
  152. ${RELOCATING+. = ALIGN(4);}
  153. .sbss : {
  154. ${RELOCATING+PROVIDE (__sbss_start = .);}
  155. *(.sbss)
  156. ${RELOCATING+*(.sbss.*)}
  157. ${RELOCATING+*(.gnu.linkonce.sb.*)}
  158. ${RELOCATING+PROVIDE (__sbss_end = .);}
  159. }
  160. ${RELOCATING+. = ALIGN(8);}
  161. ${RELOCATING+ _essro = .;}
  162. ${RELOCATING+ _ssro_size = _essro - _ssro;}
  163. ${RELOCATING+PROVIDE (_SDA_BASE_ = _ssro + (_ssro_size / 2 ));}
  164. ${RELOCATING+ . = ALIGN(4);}
  165. ${RELOCATING+ _fbss = .;}
  166. .bss : {
  167. ${RELOCATING+PROVIDE (__bss_start = .);}
  168. *(.bss)
  169. ${RELOCATING+*(.bss.*)}
  170. ${RELOCATING+*(.gnu.linkonce.b.*)}
  171. ${RELOCATING+*(COMMON)}
  172. ${RELOCATING+. = ALIGN(. != 0 ? 4 : 1);}
  173. ${RELOCATING+PROVIDE (__bss_end = .);}
  174. }
  175. ${RELOCATING+ . = ALIGN(4);}
  176. .heap : {
  177. ${RELOCATING+ _heap = .;}
  178. ${RELOCATING+ _heap_start = .;}
  179. ${RELOCATING+ . += _HEAP_SIZE;}
  180. ${RELOCATING+ _heap_end = .;}
  181. }
  182. ${RELOCATING+ . = ALIGN(4);}
  183. .stack : {
  184. ${RELOCATING+ _stack_end = .;}
  185. ${RELOCATING+ . += _STACK_SIZE;}
  186. ${RELOCATING+ . = ALIGN(. != 0 ? 8 : 1);}
  187. ${RELOCATING+ _stack = .;}
  188. ${RELOCATING+ _end = .;}
  189. }
  190. .tdata : {
  191. *(.tdata)
  192. ${RELOCATING+*(.tdata.*)}
  193. ${RELOCATING+*(.gnu.linkonce.td.*)}
  194. }
  195. .tbss : {
  196. *(.tbss)
  197. ${RELOCATING+*(.tbss.*)}
  198. ${RELOCATING+*(.gnu.linkonce.tb.*)}
  199. }
  200. }
  201. EOF