at91sam7se512_xram.ld 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (C) 2008 by egnite Software GmbH
  3. * Copyright (C) 2011 by egnite GmbH
  4. *
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the name of the copyright holders nor the names of
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  27. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  28. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  30. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. * SUCH DAMAGE.
  32. *
  33. * For additional information see http://www.ethernut.de/
  34. */
  35. /*
  36. * $Id$
  37. *
  38. * This is a GNU ld linker script of the AT91SAM7SE512 for executables,
  39. * which are loaded and started in external RAM. Parts of the executable
  40. * need to be located in internal RAM, specifically the exception vectors.
  41. * On the other hand, some loaders, like Atmel's SAM-BA tool, need pure
  42. * binary files, which are created during Nut/OS application build by
  43. * default. Such binaries do not support address gaps, which appears here
  44. * between internal and external RAM. One solution might be to use
  45. * binutils objcopy to create two separate binaries. The solution chosen
  46. * here is to include the internal RAM contents in an external RAM
  47. * area and let the runtime initialization code move it to the internal
  48. * RAM. During runtime, this area is re-used by the .bss segment.
  49. *
  50. * The current version of this linker script will not work with C++.
  51. */
  52. /* Specifies the related runtime initialization code. */
  53. STARTUP(crtat91sam7se512_xram.o)
  54. SEARCH_DIR(.)
  55. /*
  56. * The MEMORY command specifies available memory regions. Note, that
  57. * we make no assumption about the actual size of the external RAM,
  58. * but simply occupy the whole address space. To make sure, that no
  59. * overflow occurs, you need to check the linker map file.
  60. */
  61. MEMORY
  62. {
  63. iram : org = 0x00000000, len = 32k
  64. xram : org = 0x20000000, len = 256M
  65. }
  66. /*
  67. * First time we use region aliases in a Nut/OS linker script. They
  68. * don't really help much in this script, but are included for
  69. * consistency and may make sense in other scripts.
  70. */
  71. REGION_ALIAS("REGION_TEXT", xram);
  72. REGION_ALIAS("REGION_RODATA", xram);
  73. REGION_ALIAS("REGION_DATA", xram);
  74. REGION_ALIAS("REGION_BSS", xram);
  75. REGION_ALIAS("REGION_RELOC", iram);
  76. /*
  77. * The SECTIONS command tells the linker how to map input sections
  78. * from the compiled object files into output sections of the final
  79. * executable.
  80. */
  81. SECTIONS
  82. {
  83. /* Our .text section contains executable code. */
  84. .text :
  85. {
  86. . = ALIGN(4);
  87. /* The KEEP command makes sure, that the unreferenced init code will
  88. not be removed by linker optimization strategies. */
  89. KEEP(*(.init0));
  90. . = ALIGN(4);
  91. *(.text);
  92. . = ALIGN(4);
  93. *(.text.*);
  94. . = ALIGN(4);
  95. *(.eh_frame*);
  96. . = ALIGN(4);
  97. *(.glue_7t);
  98. . = ALIGN(4);
  99. *(.glue_7);
  100. } > REGION_TEXT
  101. /* Read-only data is stored in the .rodata section. Not sure, if we
  102. can include it into the .data section. The debugger may distinguish
  103. between these types of memory. */
  104. .rodata :
  105. {
  106. . = ALIGN(4);
  107. *(.rodata*);
  108. } > REGION_RODATA
  109. /* Explicitly initialized data goes into the .data section. */
  110. .data :
  111. {
  112. . = ALIGN(4);
  113. *(.data)
  114. . = ALIGN(4);
  115. *(.data.*);
  116. . = ALIGN(4);
  117. /* Marks the end of non relocatable code and data. */
  118. PROVIDE (__data_end = .);
  119. } > REGION_DATA
  120. /* This section will be moved to internal RAM. */
  121. .init : AT (__data_end)
  122. {
  123. /* Marks the target start address for the relocation.
  124. Used by the runtime initialization. */
  125. PROVIDE (__reloc_start = .);
  126. KEEP(*(.vectors));
  127. . = ALIGN(4);
  128. *(.ramfunc)
  129. /* Any idea how to add uninitialized RAM buffers? These may be
  130. required, because some peripherals will fail with DMA (PDC)
  131. buffers located in external SDRAM. */
  132. . = ALIGN(4);
  133. /* Also used by the runtime initialization. */
  134. PROVIDE (__reloc_end = .);
  135. } > REGION_RELOC
  136. /* This section will be filled with zeros. It typically contains not
  137. explicitly initialized global and static data. Note, that it over-
  138. laps the relocatable section. Thus, the runtime initialization must
  139. move the relocatable segment before clearing the .bss section. */
  140. .bss : AT (__data_end)
  141. {
  142. . = ALIGN(4);
  143. PROVIDE (__bss_start = .);
  144. *(.bss)
  145. *(COMMON)
  146. . = ALIGN(8);
  147. PROVIDE (__bss_end = .);
  148. /* Used by the Nut/OS initialization to setup heap memory. */
  149. PROVIDE (__heap_start = .);
  150. } > REGION_BSS
  151. .stab 0 (NOLOAD) :
  152. {
  153. [ .stab ]
  154. }
  155. .stabstr 0 (NOLOAD) :
  156. {
  157. [ .stabstr ]
  158. }
  159. }