avrtiny.sc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. cat <<EOF
  7. /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
  8. Copying and distribution of this script, with or without modification,
  9. are permitted in any medium without royalty provided the copyright
  10. notice and this notice are preserved. */
  11. OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
  12. OUTPUT_ARCH(${ARCH})
  13. __TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
  14. __DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
  15. __FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 2;
  16. __LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 2;
  17. __SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 4;
  18. MEMORY
  19. {
  20. text (rx) : ORIGIN = $TEXT_ORIGIN, LENGTH = __TEXT_REGION_LENGTH__
  21. data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
  22. /* Provide offsets for config, lock and signature to match
  23. production file format. Ignore offsets in datasheet. */
  24. config (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
  25. lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
  26. signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
  27. }
  28. SECTIONS
  29. {
  30. /* Read-only sections, merged into text segment: */
  31. ${TEXT_DYNAMIC+${DYNAMIC}}
  32. .hash ${RELOCATING-0} : { *(.hash) }
  33. .dynsym ${RELOCATING-0} : { *(.dynsym) }
  34. .dynstr ${RELOCATING-0} : { *(.dynstr) }
  35. .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
  36. .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
  37. .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
  38. .rel.init ${RELOCATING-0} : { *(.rel.init) }
  39. .rela.init ${RELOCATING-0} : { *(.rela.init) }
  40. .rel.text ${RELOCATING-0} :
  41. {
  42. *(.rel.text)
  43. ${RELOCATING+*(.rel.text.*)}
  44. ${RELOCATING+*(.rel.gnu.linkonce.t*)}
  45. }
  46. .rela.text ${RELOCATING-0} :
  47. {
  48. *(.rela.text)
  49. ${RELOCATING+*(.rela.text.*)}
  50. ${RELOCATING+*(.rela.gnu.linkonce.t*)}
  51. }
  52. .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
  53. .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
  54. .rel.rodata ${RELOCATING-0} :
  55. {
  56. *(.rel.rodata)
  57. ${RELOCATING+*(.rel.rodata.*)}
  58. ${RELOCATING+*(.rel.gnu.linkonce.r*)}
  59. }
  60. .rela.rodata ${RELOCATING-0} :
  61. {
  62. *(.rela.rodata)
  63. ${RELOCATING+*(.rela.rodata.*)}
  64. ${RELOCATING+*(.rela.gnu.linkonce.r*)}
  65. }
  66. .rel.data ${RELOCATING-0} :
  67. {
  68. *(.rel.data)
  69. ${RELOCATING+*(.rel.data.*)}
  70. ${RELOCATING+*(.rel.gnu.linkonce.d*)}
  71. }
  72. .rela.data ${RELOCATING-0} :
  73. {
  74. *(.rela.data)
  75. ${RELOCATING+*(.rela.data.*)}
  76. ${RELOCATING+*(.rela.gnu.linkonce.d*)}
  77. }
  78. .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
  79. .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
  80. .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
  81. .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
  82. .rel.got ${RELOCATING-0} : { *(.rel.got) }
  83. .rela.got ${RELOCATING-0} : { *(.rela.got) }
  84. .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
  85. .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
  86. .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
  87. .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
  88. /* Internal text space or external memory. */
  89. .text ${RELOCATING-0} : ${RELOCATING+ AT (0x0)}
  90. {
  91. *(.vectors)
  92. KEEP(*(.vectors))
  93. /* For data that needs to reside in the lower 64k of progmem. */
  94. ${RELOCATING+ *(.progmem.gcc*)}
  95. /* PR 13812: Placing the trampolines here gives a better chance
  96. that they will be in range of the code that uses them. */
  97. ${RELOCATING+. = ALIGN(2);}
  98. ${CONSTRUCTING+ __trampolines_start = . ; }
  99. /* The jump trampolines for the 16-bit limited relocs will reside here. */
  100. *(.trampolines)
  101. ${RELOCATING+ *(.trampolines*)}
  102. ${CONSTRUCTING+ __trampolines_end = . ; }
  103. ${RELOCATING+ *(.progmem*)}
  104. ${RELOCATING+. = ALIGN(2);}
  105. /* For future tablejump instruction arrays for 3 byte pc devices.
  106. We don't relax jump/call instructions within these sections. */
  107. *(.jumptables)
  108. ${RELOCATING+ *(.jumptables*)}
  109. /* For code that needs to reside in the lower 128k progmem. */
  110. *(.lowtext)
  111. ${RELOCATING+ *(.lowtext*)}
  112. ${CONSTRUCTING+ __ctors_start = . ; }
  113. ${CONSTRUCTING+ *(.ctors) }
  114. ${CONSTRUCTING+ __ctors_end = . ; }
  115. ${CONSTRUCTING+ __dtors_start = . ; }
  116. ${CONSTRUCTING+ *(.dtors) }
  117. ${CONSTRUCTING+ __dtors_end = . ; }
  118. KEEP(SORT(*)(.ctors))
  119. KEEP(SORT(*)(.dtors))
  120. /* From this point on, we don't bother about wether the insns are
  121. below or above the 16 bits boundary. */
  122. *(.init0) /* Start here after reset. */
  123. KEEP (*(.init0))
  124. *(.init1)
  125. KEEP (*(.init1))
  126. *(.init2) /* Clear __zero_reg__, set up stack pointer. */
  127. KEEP (*(.init2))
  128. *(.init3)
  129. KEEP (*(.init3))
  130. *(.init4) /* Initialize data and BSS. */
  131. KEEP (*(.init4))
  132. *(.init5)
  133. KEEP (*(.init5))
  134. *(.init6) /* C++ constructors. */
  135. KEEP (*(.init6))
  136. *(.init7)
  137. KEEP (*(.init7))
  138. *(.init8)
  139. KEEP (*(.init8))
  140. *(.init9) /* Call main(). */
  141. KEEP (*(.init9))
  142. *(.text)
  143. ${RELOCATING+. = ALIGN(2);}
  144. ${RELOCATING+ *(.text.*)}
  145. ${RELOCATING+. = ALIGN(2);}
  146. *(.fini9) /* _exit() starts here. */
  147. KEEP (*(.fini9))
  148. *(.fini8)
  149. KEEP (*(.fini8))
  150. *(.fini7)
  151. KEEP (*(.fini7))
  152. *(.fini6) /* C++ destructors. */
  153. KEEP (*(.fini6))
  154. *(.fini5)
  155. KEEP (*(.fini5))
  156. *(.fini4)
  157. KEEP (*(.fini4))
  158. *(.fini3)
  159. KEEP (*(.fini3))
  160. *(.fini2)
  161. KEEP (*(.fini2))
  162. *(.fini1)
  163. KEEP (*(.fini1))
  164. *(.fini0) /* Infinite loop after program termination. */
  165. KEEP (*(.fini0))
  166. ${RELOCATING+ _etext = . ; }
  167. } ${RELOCATING+ > text}
  168. .data ${RELOCATING-0} :
  169. {
  170. ${RELOCATING+ PROVIDE (__data_start = .) ; }
  171. *(.data)
  172. ${RELOCATING+ *(.data*)}
  173. *(.rodata) /* We need to include .rodata here if gcc is used */
  174. ${RELOCATING+ *(.rodata*)} /* with -fdata-sections. */
  175. *(.gnu.linkonce.d*)
  176. ${RELOCATING+. = ALIGN(2);}
  177. ${RELOCATING+ _edata = . ; }
  178. ${RELOCATING+ PROVIDE (__data_end = .) ; }
  179. } ${RELOCATING+ > data ${RELOCATING+AT> text}}
  180. .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
  181. {
  182. ${RELOCATING+ PROVIDE (__bss_start = .) ; }
  183. *(.bss)
  184. ${RELOCATING+ *(.bss*)}
  185. *(COMMON)
  186. ${RELOCATING+ PROVIDE (__bss_end = .) ; }
  187. } ${RELOCATING+ > data}
  188. ${RELOCATING+ __data_load_start = LOADADDR(.data); }
  189. ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); }
  190. /* Global data not cleared after reset. */
  191. .noinit ${RELOCATING-0}:
  192. {
  193. ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
  194. *(.noinit*)
  195. ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
  196. ${RELOCATING+ _end = . ; }
  197. ${RELOCATING+ PROVIDE (__heap_start = .) ; }
  198. } ${RELOCATING+ > data}
  199. .lock ${RELOCATING-0}:
  200. {
  201. KEEP(*(.lock*))
  202. } ${RELOCATING+ > lock}
  203. .signature ${RELOCATING-0}:
  204. {
  205. KEEP(*(.signature*))
  206. } ${RELOCATING+ > signature}
  207. .config ${RELOCATING-0}:
  208. {
  209. KEEP(*(.config*))
  210. } ${RELOCATING+ > config}
  211. /* Stabs debugging sections. */
  212. .stab 0 : { *(.stab) }
  213. .stabstr 0 : { *(.stabstr) }
  214. .stab.excl 0 : { *(.stab.excl) }
  215. .stab.exclstr 0 : { *(.stab.exclstr) }
  216. .stab.index 0 : { *(.stab.index) }
  217. .stab.indexstr 0 : { *(.stab.indexstr) }
  218. .comment 0 : { *(.comment) }
  219. .note.gnu.build-id : { *(.note.gnu.build-id) }
  220. EOF
  221. . $srcdir/scripttempl/DWARF.sc
  222. cat <<EOF
  223. }
  224. EOF