epiphany_4x4.sc 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. # Copyright (C) 2014-2015 Free Software Foundation, Inc.
  2. #
  3. # Copying and distribution of this file, with or without modification,
  4. # are permitted in any medium without royalty provided the copyright
  5. # notice and this notice are preserved.
  6. #
  7. # Unusual variables checked by this code:
  8. # NOP - four byte opcode for no-op (defaults to 0)
  9. # NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
  10. # empty.
  11. # SMALL_DATA_CTOR - .ctors contains small data.
  12. # SMALL_DATA_DTOR - .dtors contains small data.
  13. # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
  14. # INITIAL_READONLY_SECTIONS - at start of text segment
  15. # OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
  16. # (e.g., .PARISC.milli)
  17. # OTHER_TEXT_SECTIONS - these get put in .text when relocating
  18. # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
  19. # (e.g., .PARISC.global)
  20. # OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
  21. # (e.g. PPC32 .fixup, .got[12])
  22. # OTHER_BSS_SECTIONS - other than .bss .sbss ...
  23. # ATTRS_SECTIONS - at the end
  24. # OTHER_SECTIONS - at the end
  25. # EXECUTABLE_SYMBOLS - symbols that must be defined for an
  26. # executable (e.g., _DYNAMIC_LINK)
  27. # TEXT_START_ADDR - the first byte of the text segment, after any
  28. # headers.
  29. # TEXT_BASE_ADDRESS - the first byte of the text segment.
  30. # TEXT_START_SYMBOLS - symbols that appear at the start of the
  31. # .text section.
  32. # DATA_START_SYMBOLS - symbols that appear at the start of the
  33. # .data section.
  34. # DATA_END_SYMBOLS - symbols that appear at the end of the
  35. # writeable data sections.
  36. # OTHER_GOT_SYMBOLS - symbols defined just before .got.
  37. # OTHER_GOT_SECTIONS - sections just after .got.
  38. # OTHER_SDATA_SECTIONS - sections just after .sdata.
  39. # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
  40. # .bss section besides ___bss_start.
  41. # DATA_PLT - .plt should be in data segment, not text segment.
  42. # PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
  43. # BSS_PLT - .plt should be in bss segment
  44. # NO_REL_RELOCS - Don't include .rel.* sections in script
  45. # NO_RELA_RELOCS - Don't include .rela.* sections in script
  46. # NON_ALLOC_DYN - Place dynamic sections after data segment.
  47. # TEXT_DYNAMIC - .dynamic in text segment, not data segment.
  48. # EMBEDDED - whether this is for an embedded system.
  49. # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
  50. # start address of shared library.
  51. # INPUT_FILES - INPUT command of files to always include
  52. # WRITABLE_RODATA - if set, the .rodata section should be writable
  53. # INIT_START, INIT_END - statements just before and just after
  54. # combination of .init sections.
  55. # FINI_START, FINI_END - statements just before and just after
  56. # combination of .fini sections.
  57. # STACK_ADDR - start of a .stack section.
  58. # OTHER_SYMBOLS - symbols to place right at the end of the script.
  59. # ETEXT_NAME - name of a symbol for the end of the text section,
  60. # normally etext.
  61. # SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
  62. # so that .got can be in the RELRO area. It should be set to
  63. # the number of bytes in the beginning of .got.plt which can be
  64. # in the RELRO area as well.
  65. # USER_LABEL_PREFIX - prefix to add to user-visible symbols.
  66. #
  67. # When adding sections, do note that the names of some sections are used
  68. # when specifying the start address of the next.
  69. #
  70. # Many sections come in three flavours. There is the 'real' section,
  71. # like ".data". Then there are the per-procedure or per-variable
  72. # sections, generated by -ffunction-sections and -fdata-sections in GCC,
  73. # and useful for --gc-sections, which for a variable "foo" might be
  74. # ".data.foo". Then there are the linkonce sections, for which the linker
  75. # eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
  76. # The exact correspondences are:
  77. #
  78. # Section Linkonce section
  79. # .text .gnu.linkonce.t.foo
  80. # .rodata .gnu.linkonce.r.foo
  81. # .data .gnu.linkonce.d.foo
  82. # .bss .gnu.linkonce.b.foo
  83. # .sdata .gnu.linkonce.s.foo
  84. # .sbss .gnu.linkonce.sb.foo
  85. # .sdata2 .gnu.linkonce.s2.foo
  86. # .sbss2 .gnu.linkonce.sb2.foo
  87. # .debug_info .gnu.linkonce.wi.foo
  88. # .tdata .gnu.linkonce.td.foo
  89. # .tbss .gnu.linkonce.tb.foo
  90. # .lrodata .gnu.linkonce.lr.foo
  91. # .ldata .gnu.linkonce.l.foo
  92. # .lbss .gnu.linkonce.lb.foo
  93. #
  94. # Each of these can also have corresponding .rel.* and .rela.* sections.
  95. test -z "$ENTRY" && ENTRY=_start
  96. test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  97. test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  98. if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
  99. test -z "${ELFSIZE}" && ELFSIZE=32
  100. test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
  101. test "$LD_FLAG" = "N" && DATA_ADDR=.
  102. test -z "${ETEXT_NAME}" && ETEXT_NAME=etext
  103. test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
  104. test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
  105. test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
  106. test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
  107. DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
  108. DATA_SEGMENT_RELRO_END=""
  109. DATA_SEGMENT_END=""
  110. if test -n "${COMMONPAGESIZE}"; then
  111. DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
  112. DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
  113. DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
  114. fi
  115. if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
  116. INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
  117. fi
  118. if test -z "$PLT"; then
  119. PLT=".plt ${RELOCATING-0} : { *(.plt) }"
  120. fi
  121. test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
  122. if test -z "$GOT"; then
  123. if test -z "$SEPARATE_GOTPLT"; then
  124. GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }"
  125. else
  126. GOT=".got ${RELOCATING-0} : { *(.got) }"
  127. GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }"
  128. fi
  129. fi
  130. DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
  131. RODATA=".rodata ${RELOCATING+ADDR(.data)+SIZEOF(.data)} ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) } /*> INTERNAL_RAM*/"
  132. DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }"
  133. DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }"
  134. if test -z "${NO_SMALL_DATA}"; then
  135. SBSS=".sbss ${RELOCATING-0} :
  136. {
  137. ${RELOCATING+${SBSS_START_SYMBOLS}}
  138. ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
  139. *(.dynsbss)
  140. *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
  141. *(.scommon)
  142. ${RELOCATING+${SBSS_END_SYMBOLS}}
  143. }"
  144. SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
  145. SDATA="/* We want the small data sections together, so single-instruction offsets
  146. can access them all, and initialized data all before uninitialized, so
  147. we can shorten the on-disk segment size. */
  148. .sdata ${RELOCATING-0} :
  149. {
  150. ${RELOCATING+${SDATA_START_SYMBOLS}}
  151. ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
  152. *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
  153. }"
  154. SDATA2=".sdata2 ${RELOCATING-0} :
  155. {
  156. ${RELOCATING+${SDATA2_START_SYMBOLS}}
  157. *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*})
  158. }"
  159. REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
  160. .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
  161. REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
  162. .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
  163. REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
  164. .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
  165. REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
  166. .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
  167. else
  168. NO_SMALL_DATA=" "
  169. fi
  170. if test -z "${DATA_GOT}"; then
  171. if test -n "${NO_SMALL_DATA}"; then
  172. DATA_GOT=" "
  173. fi
  174. fi
  175. if test -z "${SDATA_GOT}"; then
  176. if test -z "${NO_SMALL_DATA}"; then
  177. SDATA_GOT=" "
  178. fi
  179. fi
  180. test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
  181. test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
  182. .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
  183. .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
  184. .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
  185. .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
  186. .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
  187. .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
  188. test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
  189. ${OTHER_BSS_SECTIONS}
  190. .lbss ${RELOCATING-0} :
  191. {
  192. *(.dynlbss)
  193. *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
  194. *(LARGE_COMMON)
  195. }"
  196. test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
  197. .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
  198. {
  199. *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
  200. }
  201. .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
  202. {
  203. *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
  204. ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
  205. }"
  206. CTOR=".ctors ADDR(.text) + SIZEOF(.text) ${CONSTRUCTING-0} :
  207. {
  208. ${CONSTRUCTING+${CTOR_START}}
  209. /* gcc uses crtbegin.o to find the start of
  210. the constructors, so we make sure it is
  211. first. Because this is a wildcard, it
  212. doesn't matter if the user does not
  213. actually link against crtbegin.o; the
  214. linker won't look for a file to match a
  215. wildcard. The wildcard also means that it
  216. doesn't matter which directory crtbegin.o
  217. is in. */
  218. KEEP (*crtbegin.o(.ctors))
  219. KEEP (*crtbegin?.o(.ctors))
  220. /* We don't want to include the .ctor section from
  221. the crtend.o file until after the sorted ctors.
  222. The .ctor section from the crtend file contains the
  223. end of ctors marker and it must be last */
  224. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
  225. KEEP (*(SORT(.ctors.*)))
  226. KEEP (*(.ctors))
  227. ${CONSTRUCTING+${CTOR_END}}
  228. } /*> INTERNAL_RAM*/"
  229. DTOR=".dtors ADDR(.ctors) + SIZEOF(.ctors) ${CONSTRUCTING-0} :
  230. {
  231. ${CONSTRUCTING+${DTOR_START}}
  232. KEEP (*crtbegin.o(.dtors))
  233. KEEP (*crtbegin?.o(.dtors))
  234. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
  235. KEEP (*(SORT(.dtors.*)))
  236. KEEP (*(.dtors))
  237. ${CONSTRUCTING+${DTOR_END}}
  238. } /*> INTERNAL_RAM*/ "
  239. STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
  240. {
  241. ${RELOCATING+___stack = .;}
  242. *(.stack)
  243. }"
  244. # If this is for an embedded system, don't add SIZEOF_HEADERS.
  245. if [ -z "$EMBEDDED" ]; then
  246. test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
  247. else
  248. test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
  249. fi
  250. cat <<EOF
  251. /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
  252. Copying and distribution of this script, with or without modification,
  253. are permitted in any medium without royalty provided the copyright
  254. notice and this notice are preserved. */
  255. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  256. "${LITTLE_OUTPUT_FORMAT}")
  257. OUTPUT_ARCH(${OUTPUT_ARCH})
  258. ${RELOCATING+ENTRY(${ENTRY})}
  259. ${RELOCATING+${EXECUTABLE_SYMBOLS}}
  260. ${RELOCATING+${INPUT_FILES}}
  261. ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
  262. if gld -r is used and the intermediate file has sections starting
  263. at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
  264. bug. But for now assigning the zero vmas works. */}
  265. /* BSP specific*/
  266. __PROG_SIZE_FOR_CORE__ = 1M;
  267. __HEAP_SIZE_FOR_CORE__ = 1M;
  268. __MAX_NUM_CORES_IN_ROWS__ = 4;
  269. __MAX_NUM_CORES_IN_COLS__ = 4;
  270. __FIRST_CORE_ROW_ = 0x20;
  271. __FIRST_CORE_COL_ = 0x24;
  272. PROVIDE (__CORE_ROW_ = __FIRST_CORE_ROW_);
  273. PROVIDE (__CORE_COL_ = __FIRST_CORE_COL_);
  274. /* generic don't touch */
  275. /* used to calculated the slice address in the external memory*/
  276. __CORE_NUM_ = (__CORE_ROW_ - __FIRST_CORE_ROW_ )* __MAX_NUM_CORES_IN_COLS__ + (__CORE_COL_ - __FIRST_CORE_COL_ ) ;
  277. MEMORY
  278. {
  279. EXTERNAL_DRAM_0 (WXAI) : ORIGIN = 0x80000000, LENGTH = 0x1000000 /*.text, data, rodata, bss and .stack*/
  280. EXTERNAL_DRAM_1 (WXAI) : ORIGIN = 0x81000000, LENGTH = 0x1000000 /*.heap */
  281. EXTERNAL_SRAM (WXAI) : ORIGIN = 0x92000000, LENGTH = 8K /* small external RAM, used for testing*/
  282. /* run time lib and crt0*/
  283. RESERVED_CRT0_RAM (WXAI) : ORIGIN = 0, LENGTH = 0x400
  284. /* user program, per bank usage */
  285. BANK0_SRAM (WXAI) : ORIGIN = LENGTH(RESERVED_CRT0_RAM), LENGTH = 8K - LENGTH(RESERVED_CRT0_RAM)
  286. BANK1_SRAM (WXAI) : ORIGIN = 0x2000, LENGTH = 8K
  287. BANK2_SRAM (WXAI) : ORIGIN = 0x4000, LENGTH = 8K
  288. BANK3_SRAM (WXAI) : ORIGIN = 0x6000, LENGTH = 8K
  289. /* user program, continious placement */
  290. INTERNAL_RAM (WXAI) : ORIGIN = LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K - LENGTH(RESERVED_CRT0_RAM)
  291. MMR (WAI) : ORIGIN = 0xF000, LENGTH = 32K
  292. /* multi cores space */
  293. CORE_0x20_0x24_INTERNAL_RAM : ORIGIN = 0x82400000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  294. CORE_0x20_0x25_INTERNAL_RAM : ORIGIN = 0x82500000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  295. CORE_0x20_0x26_INTERNAL_RAM : ORIGIN = 0x82600000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  296. CORE_0x20_0x27_INTERNAL_RAM : ORIGIN = 0x82700000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  297. CORE_0x21_0x24_INTERNAL_RAM : ORIGIN = 0x86400000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  298. CORE_0x21_0x25_INTERNAL_RAM : ORIGIN = 0x86500000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  299. CORE_0x21_0x26_INTERNAL_RAM : ORIGIN = 0x86600000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  300. CORE_0x21_0x27_INTERNAL_RAM : ORIGIN = 0x86700000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  301. CORE_0x22_0x24_INTERNAL_RAM : ORIGIN = 0x8a400000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  302. CORE_0x22_0x25_INTERNAL_RAM : ORIGIN = 0x8a500000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  303. CORE_0x22_0x26_INTERNAL_RAM : ORIGIN = 0x8a600000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  304. CORE_0x22_0x27_INTERNAL_RAM : ORIGIN = 0x8a700000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  305. CORE_0x23_0x24_INTERNAL_RAM : ORIGIN = 0x8e400000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  306. CORE_0x23_0x25_INTERNAL_RAM : ORIGIN = 0x8e500000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  307. CORE_0x23_0x26_INTERNAL_RAM : ORIGIN = 0x8e600000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  308. CORE_0x23_0x27_INTERNAL_RAM : ORIGIN = 0x8e700000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  309. CORE_0x24_0x24_INTERNAL_RAM : ORIGIN = 0x82000000+LENGTH(RESERVED_CRT0_RAM), LENGTH = 32K- LENGTH(RESERVED_CRT0_RAM)
  310. }
  311. SECTIONS
  312. {
  313. IVT 0 : {*.o(IVT) } > RESERVED_CRT0_RAM
  314. RESERVED_CRT0 : {*.o(RESERVED_CRT0) } > RESERVED_CRT0_RAM
  315. RESERVED_CRT0 : {*.o(reserved_crt0) } > RESERVED_CRT0_RAM
  316. CORE_RAM_0 : {*.o(core_ram_0) } > BANK0_SRAM
  317. CORE_RAM_1 : {*.o(core_ram_1) } > BANK1_SRAM
  318. CORE_RAM_2 : {*.o(core_ram_2) } > BANK2_SRAM
  319. CORE_RAM_3 : {*.o(core_ram_3) } > BANK3_SRAM
  320. SRAM_SOUTH : {*.o(sram) } > EXTERNAL_SRAM
  321. DRAM_WEST : {*.o(dram) } > EXTERNAL_DRAM_1
  322. CORE_INTERNAL : {*.o(core_ram_internal) } /*> INTERNAL_RAM*/
  323. /* the newlib (libc and libm) library is maped to the dedicated section */
  324. __new_lib_start_external_ = ( ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ *__CORE_NUM_ );
  325. __new_lib_start_ = DEFINED(__USE_INTERNAL_MEM_FOR_NEW_LIB_) ? ORIGIN(BANK1_SRAM) : __new_lib_start_external_ ;
  326. NEW_LIB_RO ${RELOCATING+__new_lib_start_} : { lib_a-*.o(.text .rodata ) *.o(libgloss_epiphany) } /* > INTERNAL_RAM*/
  327. GNU_C_BUILTIN_LIB_RO ADDR(NEW_LIB_RO) + SIZEOF(NEW_LIB_RO) : {
  328. *mulsi3.o(.text .rodata) *modsi3.o(.text .rodata)
  329. *divsi3.o(.text .rodata) *udivsi3.o(.text .rodata)
  330. *umodsi3.o(.text .rodata) _*.o(.text .rodata)
  331. }
  332. NEW_LIB_WR ADDR(GNU_C_BUILTIN_LIB_RO) + SIZEOF(GNU_C_BUILTIN_LIB_RO) : { lib_a-*.o(.data ) } /* > INTERNAL_RAM*/
  333. __init_start = DEFINED(__USE_INTERNAL_MEM_) ? ORIGIN(BANK1_SRAM) : (ADDR(NEW_LIB_WR) + SIZEOF(NEW_LIB_WR) ) ;
  334. __init_start = DEFINED(__USE_INTERNAL_MEM_FOR_NEW_LIB_) ? ADDR(NEW_LIB_WR) + SIZEOF(NEW_LIB_WR) : __init_start;
  335. /* Read-only sections, merged into text segment: */
  336. /*${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}*/
  337. ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
  338. ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
  339. ${INITIAL_READONLY_SECTIONS}
  340. .note.gnu.build-id : { *(.note.gnu.build-id) }
  341. EOF
  342. test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
  343. test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
  344. cat > ldscripts/dyntmp.$$ <<EOF
  345. ${TEXT_DYNAMIC+${DYNAMIC}}
  346. .hash ${RELOCATING-0} : { *(.hash) }
  347. .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
  348. .dynsym ${RELOCATING-0} : { *(.dynsym) }
  349. .dynstr ${RELOCATING-0} : { *(.dynstr) }
  350. .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
  351. .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
  352. .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
  353. EOF
  354. if [ "x$COMBRELOC" = x ]; then
  355. COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
  356. else
  357. COMBRELOCCAT="cat > $COMBRELOC"
  358. fi
  359. eval $COMBRELOCCAT <<EOF
  360. .rel.init ${RELOCATING-0} : { *(.rel.init) }
  361. .rela.init ${RELOCATING-0} : { *(.rela.init) }
  362. .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
  363. .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
  364. .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
  365. .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
  366. .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
  367. .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
  368. ${OTHER_READONLY_RELOC_SECTIONS}
  369. .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) }
  370. .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) }
  371. .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
  372. .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
  373. .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
  374. .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
  375. .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
  376. .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
  377. .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
  378. .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
  379. .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
  380. .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
  381. .rel.got ${RELOCATING-0} : { *(.rel.got) }
  382. .rela.got ${RELOCATING-0} : { *(.rela.got) }
  383. ${OTHER_GOT_RELOC_SECTIONS}
  384. ${REL_SDATA}
  385. ${REL_SBSS}
  386. ${REL_SDATA2}
  387. ${REL_SBSS2}
  388. .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
  389. .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
  390. ${REL_LARGE}
  391. EOF
  392. if [ -n "$COMBRELOC" ]; then
  393. cat >> ldscripts/dyntmp.$$ <<EOF
  394. .rel.dyn ${RELOCATING-0} :
  395. {
  396. EOF
  397. sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
  398. cat >> ldscripts/dyntmp.$$ <<EOF
  399. }
  400. .rela.dyn ${RELOCATING-0} :
  401. {
  402. EOF
  403. sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
  404. cat >> ldscripts/dyntmp.$$ <<EOF
  405. }
  406. EOF
  407. fi
  408. cat >> ldscripts/dyntmp.$$ <<EOF
  409. .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
  410. .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
  411. ${OTHER_PLT_RELOC_SECTIONS}
  412. EOF
  413. if test -z "${NON_ALLOC_DYN}"; then
  414. if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
  415. cat ldscripts/dyntmp.$$
  416. else
  417. if test -z "${NO_REL_RELOCS}"; then
  418. sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
  419. fi
  420. if test -z "${NO_RELA_RELOCS}"; then
  421. sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
  422. fi
  423. fi
  424. rm -f ldscripts/dyntmp.$$
  425. fi
  426. cat <<EOF
  427. .init __init_start :
  428. {
  429. ${RELOCATING+${INIT_START}}
  430. KEEP (*(.init))
  431. ${RELOCATING+${INIT_END}}
  432. } /*> INTERNAL_RAM*/ =${NOP-0}
  433. ${TEXT_PLT+${PLT}}
  434. ${TINY_READONLY_SECTION}
  435. .fini ${RELOCATING+ADDR(.init)+SIZEOF(.init)} ${RELOCATING-0} :
  436. {
  437. ${RELOCATING+${FINI_START}}
  438. KEEP (*(.fini))
  439. ${RELOCATING+${FINI_END}}
  440. } /*> INTERNAL_RAM*/ =${NOP-0}
  441. .text ${RELOCATING+ADDR(.fini)+SIZEOF(.fini)} ${RELOCATING-0} :
  442. {
  443. ${RELOCATING+${TEXT_START_SYMBOLS}}
  444. *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
  445. /* .gnu.warning sections are handled specially by elf32.em. */
  446. *(.gnu.warning)
  447. ${RELOCATING+${OTHER_TEXT_SECTIONS}}
  448. } /*> INTERNAL_RAM */ =${NOP-0}
  449. ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
  450. ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
  451. ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
  452. ${WRITABLE_RODATA-${RODATA}}
  453. .rodata1 ${RELOCATING-0} : { *(.rodata1) }
  454. ${CREATE_SHLIB-${SDATA2}}
  455. ${CREATE_SHLIB-${SBSS2}}
  456. ${OTHER_READONLY_SECTIONS}
  457. .eh_frame_hdr : { *(.eh_frame_hdr) }
  458. .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  459. .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
  460. /* Adjust the address for the data segment. We want to adjust up to
  461. the same address within the page on the next page up. */
  462. ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
  463. ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
  464. ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
  465. /* Exception handling */
  466. .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
  467. .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  468. /* Thread Local Storage sections */
  469. .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
  470. .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
  471. .preinit_array ${RELOCATING-0} :
  472. {
  473. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
  474. KEEP (*(.preinit_array))
  475. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
  476. }
  477. .init_array ${RELOCATING-0} :
  478. {
  479. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
  480. KEEP (*(SORT(.init_array.*)))
  481. KEEP (*(.init_array))
  482. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
  483. }
  484. .fini_array ${RELOCATING-0} :
  485. {
  486. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
  487. KEEP (*(.fini_array))
  488. KEEP (*(SORT(.fini_array.*)))
  489. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
  490. }
  491. ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
  492. ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
  493. .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
  494. ${RELOCATING+${DATARELRO}}
  495. ${OTHER_RELRO_SECTIONS}
  496. ${TEXT_DYNAMIC-${DYNAMIC}}
  497. ${DATA_GOT+${RELRO_NOW+${GOT}}}
  498. ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
  499. ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
  500. ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
  501. ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
  502. ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
  503. ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
  504. .data ${RELOCATING+ADDR(.dtors)+SIZEOF(.dtors)} ${RELOCATING-0} :
  505. {
  506. ${RELOCATING+${DATA_START_SYMBOLS}}
  507. *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
  508. ${CONSTRUCTING+SORT(CONSTRUCTORS)}
  509. } /*> INTERNAL_RAM*/
  510. .data1 ${RELOCATING-0} : { *(.data1) }
  511. ${WRITABLE_RODATA+${RODATA}}
  512. ${OTHER_READWRITE_SECTIONS}
  513. ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
  514. ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
  515. ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
  516. ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}
  517. ${SDATA_GOT+${GOT}}
  518. ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
  519. ${SDATA}
  520. ${OTHER_SDATA_SECTIONS}
  521. ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
  522. /* Align ___bss_start and _end to a multiple of 8 so that we can use strd
  523. to clear bss. N.B., without adding any extra alignment, we would have
  524. to clear the bss byte by byte. */
  525. ${RELOCATING+. = ALIGN(8);}
  526. ${RELOCATING+___bss_start = .;}
  527. ${RELOCATING+${OTHER_BSS_SYMBOLS}}
  528. ${SBSS}
  529. ${BSS_PLT+${PLT}}
  530. .bss ${RELOCATING+ADDR(.rodata)+SIZEOF(.rodata)} ${RELOCATING-0} :
  531. {
  532. *(.dynbss)
  533. *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
  534. *(COMMON)
  535. /* Align here to ensure that the .bss section occupies space up to
  536. _end. Align after .bss to ensure correct alignment even if the
  537. .bss section disappears because there are no input sections.
  538. FIXME: Why do we need it? When there is no .bss section, we don't
  539. pad the .data section. */
  540. ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
  541. } /*> INTERNAL_RAM*/
  542. ${OTHER_BSS_SECTIONS}
  543. ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
  544. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  545. ${LARGE_SECTIONS}
  546. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  547. ${RELOCATING+. = ALIGN(8);}
  548. ${RELOCATING+${OTHER_END_SYMBOLS}}
  549. ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
  550. ${RELOCATING+${DATA_SEGMENT_END}}
  551. EOF
  552. if test -n "${NON_ALLOC_DYN}"; then
  553. if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
  554. cat ldscripts/dyntmp.$$
  555. else
  556. if test -z "${NO_REL_RELOCS}"; then
  557. sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
  558. fi
  559. if test -z "${NO_RELA_RELOCS}"; then
  560. sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
  561. fi
  562. fi
  563. rm -f ldscripts/dyntmp.$$
  564. fi
  565. cat <<EOF
  566. /* Stabs debugging sections. */
  567. .stab 0 : { *(.stab) }
  568. .stabstr 0 : { *(.stabstr) }
  569. .stab.excl 0 : { *(.stab.excl) }
  570. .stab.exclstr 0 : { *(.stab.exclstr) }
  571. .stab.index 0 : { *(.stab.index) }
  572. .stab.indexstr 0 : { *(.stab.indexstr) }
  573. .comment 0 : { *(.comment) }
  574. EOF
  575. . $srcdir/scripttempl/DWARF.sc
  576. cat <<EOF
  577. ${TINY_DATA_SECTION}
  578. ${TINY_BSS_SECTION}
  579. /*${STACK_ADDR+${STACK}}*/
  580. PROVIDE ( __stack_start_ = ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ * __CORE_NUM_ + __PROG_SIZE_FOR_CORE__ - 0x10) ;
  581. .stack ${RELOCATING+__stack_start_} : { ___stack = .; *(.stack) }
  582. PROVIDE ( ___heap_start = ORIGIN(EXTERNAL_DRAM_1) + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ );
  583. /*.heap_start __heap_start_ : { _heap_start_ = .; *(.heap_start) }*/
  584. PROVIDE ( ___heap_end = ORIGIN(EXTERNAL_DRAM_1) + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ + __HEAP_SIZE_FOR_CORE__ - 4 );
  585. /* .heap_end __heap_end_ : { _heap_end_ = .; *(.heap_end) }*/
  586. ${ATTRS_SECTIONS}
  587. ${OTHER_SECTIONS}
  588. ${RELOCATING+${OTHER_SYMBOLS}}
  589. ${RELOCATING+${DISCARDED}}
  590. }
  591. EOF