avr.sc 8.1 KB

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