basic_sdk_app.ld.S 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*
  2. * Copyright (c) 2010-2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. OUTPUT_FORMAT("elf32-littlearm")
  31. OUTPUT_ARCH(arm)
  32. ENTRY(_start)
  33. /*
  34. * OCRAM
  35. */
  36. #if defined(CHIP_MX6SDL) || defined(CHIP_MX6SL)
  37. // mx6sl and mx6sdl both have 128kB of OCRAM.
  38. #define OCRAM_LEN 128K
  39. #elif defined(CHIP_MX6DQ)
  40. // mx6dq has 256kB of OCRAM
  41. #define OCRAM_LEN 256K
  42. #else
  43. #error Unknown chip!
  44. #endif
  45. /*
  46. * External DDR
  47. */
  48. #if defined(CHIP_MX6SL)
  49. // mx6sl has only one DDR chip select that starts at a different address
  50. #define DDR_ORG 0x80000000
  51. #elif defined(CHIP_MX6SDL) || defined(CHIP_MX6DQ)
  52. // mx6dq and mx6sdl DDR memory starts at this address
  53. #define DDR_ORG 0x10000000
  54. #else
  55. #error Unknown chip!
  56. #endif
  57. #if defined(BOARD_SABRE_AI)
  58. // mx6dq and mx6sdl sabre-ai board has 2GB of DDR3
  59. #define DDR_LEN 2048M
  60. #else
  61. // all other boards have 1GB of DDR3
  62. #define DDR_LEN 1024M
  63. #endif
  64. // Maximum size of the signed image
  65. #if !defined(MAX_IMAGE_SIZE)
  66. #define MAX_IMAGE_SIZE 4M
  67. #endif
  68. // Maximum size of HAB CSF data
  69. #if !defined(MAX_HAB_CSF_DATA_SIZE)
  70. #define MAX_HAB_CSF_DATA_SIZE 8K
  71. #endif
  72. // Size of stacks section
  73. #if !defined(STACK_SIZE)
  74. #define STACK_SIZE 48K
  75. #endif
  76. // Size of the malloc heap, defaults to 128MB
  77. #if !defined(HEAP_SIZE)
  78. #define HEAP_SIZE 128M
  79. #endif
  80. // Size of the L1 page table.
  81. #define L1_PAGE_TABLE_SIZE 16K
  82. // Size of the RAM vectors table at the top of OCRAM.
  83. //
  84. // The vectors in ROM at address 0 point to these RAM vectors.
  85. #define RAM_VECTORS_SIZE 72
  86. INPUT (crtbegin.o crti.o crtend.o crtn.o)
  87. MEMORY
  88. {
  89. OCRAM (rwx) : ORIGIN = 0x00900000, LENGTH = OCRAM_LEN
  90. DDR (rwx) : ORIGIN = DDR_ORG, LENGTH = DDR_LEN
  91. }
  92. SECTIONS
  93. {
  94. /*
  95. * -- OCRAM --
  96. *
  97. * Nothing in OCRAM can be loaded at boot, because the boot image must be a contiguous
  98. * region of memory.
  99. */
  100. /* MMU L1 page table */
  101. .l1_page_table (NOLOAD) :
  102. {
  103. __l1_page_table_start = .;
  104. . += L1_PAGE_TABLE_SIZE;
  105. } > OCRAM
  106. /* allocate a heap in ocram */
  107. .heap.ocram (NOLOAD) : ALIGN(4)
  108. {
  109. __heap_ocram_start = .;
  110. . += LENGTH(OCRAM) - L1_PAGE_TABLE_SIZE - RAM_VECTORS_SIZE ;
  111. __heap_ocram_end = .;
  112. } > OCRAM
  113. /* RAM vector table comes at the end of OCRAM */
  114. .ram_vectors (ORIGIN(OCRAM) + LENGTH(OCRAM) - RAM_VECTORS_SIZE) (NOLOAD) :
  115. {
  116. __ram_vectors_start = .;
  117. . += RAM_VECTORS_SIZE;
  118. __ram_vectors_end = .;
  119. } > OCRAM
  120. /*
  121. * -- DDR --
  122. */
  123. /* -- read-only sections -- */
  124. _start_image_add = ORIGIN(DDR);
  125. .ivt (ORIGIN(DDR)) :
  126. {
  127. . = . + 0x400;
  128. *(.ivt)
  129. } > DDR
  130. .boot_data :
  131. {
  132. __start_boot_data = .;
  133. *(.boot_data)
  134. } > DDR
  135. /* aligned to ease the hexdump read of generated binary */
  136. .dcd_hdr : ALIGN(16)
  137. {
  138. __start_dcd = .;
  139. *(.dcd_hdr)
  140. } > DDR
  141. .dcd_wrt_cmd :
  142. {
  143. *(.dcd_wrt_cmd)
  144. } > DDR
  145. .dcd_data :
  146. {
  147. *(.dcd_data)
  148. } > DDR
  149. .text : ALIGN(8)
  150. {
  151. CREATE_OBJECT_SYMBOLS
  152. *(.startup)
  153. *(.text .text.* .gnu.linkonce.t.*)
  154. *(.glue_7t) *(.glue_7) *(.vfp11_veneer)
  155. *(.ARM.extab* .gnu.linkonce.armextab.*)
  156. *(.gcc_except_table)
  157. } > DDR
  158. .ctors :
  159. {
  160. /* gcc uses crtbegin.o to find the start of
  161. the constructors, so we make sure it is
  162. first. Because this is a wildcard, it
  163. doesn't matter if the user does not
  164. actually link against crtbegin.o; the
  165. linker won't look for a file to match a
  166. wildcard. The wildcard also means that it
  167. doesn't matter which directory crtbegin.o
  168. is in. */
  169. KEEP (*crtbegin.o(.ctors))
  170. KEEP (*crtbegin?.o(.ctors))
  171. /* We don't want to include the .ctor section from
  172. the crtend.o file until after the sorted ctors.
  173. The .ctor section from the crtend file contains the
  174. end of ctors marker and it must be last */
  175. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  176. KEEP (*(SORT(.ctors.*)))
  177. KEEP (*(.ctors))
  178. } > DDR
  179. .dtors :
  180. {
  181. KEEP (*crtbegin.o(.dtors))
  182. KEEP (*crtbegin?.o(.dtors))
  183. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  184. KEEP (*(SORT(.dtors.*)))
  185. KEEP (*(.dtors))
  186. } > DDR
  187. .rodata :
  188. {
  189. *(.rodata .rodata.* .gnu.linkonce.r.*)
  190. . = ALIGN(4);
  191. KEEP(*(.init))
  192. . = ALIGN(4);
  193. __init_array_start = .;
  194. KEEP (*(SORT(.init_array.*)))
  195. KEEP (*(.init_array))
  196. __init_array_end = .;
  197. . = ALIGN(4);
  198. KEEP(*(.fini))
  199. . = ALIGN(4);
  200. __fini_array_start = .;
  201. KEEP (*(.fini_array))
  202. KEEP (*(SORT(.fini_array.*)))
  203. __fini_array_end = .;
  204. } > DDR
  205. /* Unwind index. This section is related to C++ exceptions, and is required even
  206. though exceptions are disabled with -fno-exceptions. */
  207. PROVIDE_HIDDEN(__exidx_start = .);
  208. .ARM.exidx :
  209. {
  210. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  211. } > DDR
  212. PROVIDE_HIDDEN(__exidx_end = .);
  213. /* -- read-write sections -- */
  214. .data : ALIGN(8)
  215. {
  216. *(.data .data.* .gnu.linkonce.d.*)
  217. SORT(CONSTRUCTORS)
  218. } > DDR
  219. /* Reserve some space for HAB CSF data */
  220. .hab.data (_start_image_add + MAX_IMAGE_SIZE) : ALIGN(4)
  221. {
  222. __hab_data = .;
  223. . += MAX_HAB_CSF_DATA_SIZE;
  224. . = ALIGN (32);
  225. __hab_data_end = .;
  226. } > DDR
  227. /* End of HAB reserved space (must place it before BSS section) */
  228. _image_size = . - _start_image_add;
  229. /* The .bss section comes after the hab data because it is not signed */
  230. .bss :
  231. {
  232. __bss_start__ = .;
  233. *(.shbss)
  234. *(.bss .bss.* .gnu.linkonce.b.*)
  235. *(COMMON)
  236. *(.bss)
  237. __bss_end__ = .;
  238. } > DDR
  239. /* Region to contain exception handler stacks */
  240. .stacks (NOLOAD) :
  241. {
  242. __stacks_start = .;
  243. . += STACK_SIZE;
  244. __stacks_end = .;
  245. top_of_stacks = .;
  246. } > DDR
  247. /* define range of the malloc heap */
  248. free_memory_start = ALIGN(32); /* malloc starts allocating from here */
  249. . += HEAP_SIZE;
  250. free_memory_end = .;
  251. _end = .;
  252. }