nrf_common.ld 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* Linker script for Nordic Semiconductor nRF devices
  2. *
  3. * Version: Sourcery G++ 4.5-1
  4. * Support: https://support.codesourcery.com/GNUToolchain/
  5. *
  6. * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc.
  7. *
  8. * The authors hereby grant permission to use, copy, modify, distribute,
  9. * and license this software and its documentation for any purpose, provided
  10. * that existing copyright notices are retained in all copies and that this
  11. * notice is included verbatim in any distributions. No written agreement,
  12. * license, or royalty fee is required for any of the authorized uses.
  13. * Modifications to this software may be copyrighted by their authors
  14. * and need not follow the licensing terms described here, provided that
  15. * the new terms are clearly indicated on the first page of each file where
  16. * they apply.
  17. */
  18. OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
  19. /* Linker script to place sections and symbol values. Should be used together
  20. * with other linker script that defines memory regions FLASH and RAM.
  21. * It references following symbols, which must be defined in code:
  22. * Reset_Handler : Entry of reset handler
  23. *
  24. * It defines following symbols, which code can use without definition:
  25. * __exidx_start
  26. * __exidx_end
  27. * __etext
  28. * __data_start__
  29. * __preinit_array_start
  30. * __preinit_array_end
  31. * __init_array_start
  32. * __init_array_end
  33. * __fini_array_start
  34. * __fini_array_end
  35. * __data_end__
  36. * __bss_start__
  37. * __bss_end__
  38. * __end__
  39. * end
  40. * __HeapBase
  41. * __HeapLimit
  42. * __StackLimit
  43. * __StackTop
  44. * __stack
  45. */
  46. ENTRY(Reset_Handler)
  47. SECTIONS
  48. {
  49. .text :
  50. {
  51. KEEP(*(.isr_vector))
  52. *(.text*)
  53. KEEP(*(.init))
  54. KEEP(*(.fini))
  55. /* .ctors */
  56. *crtbegin.o(.ctors)
  57. *crtbegin?.o(.ctors)
  58. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  59. *(SORT(.ctors.*))
  60. *(.ctors)
  61. /* .dtors */
  62. *crtbegin.o(.dtors)
  63. *crtbegin?.o(.dtors)
  64. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  65. *(SORT(.dtors.*))
  66. *(.dtors)
  67. *(.rodata*)
  68. KEEP(*(.eh_frame*))
  69. } > FLASH
  70. .ARM.extab :
  71. {
  72. *(.ARM.extab* .gnu.linkonce.armextab.*)
  73. } > FLASH
  74. __exidx_start = .;
  75. .ARM.exidx :
  76. {
  77. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  78. } > FLASH
  79. __exidx_end = .;
  80. . = ALIGN(4);
  81. __etext = .;
  82. .data : AT (__etext)
  83. {
  84. __data_start__ = .;
  85. *(vtable)
  86. *(.data*)
  87. . = ALIGN(4);
  88. /* preinit data */
  89. PROVIDE_HIDDEN (__preinit_array_start = .);
  90. KEEP(*(.preinit_array))
  91. PROVIDE_HIDDEN (__preinit_array_end = .);
  92. . = ALIGN(4);
  93. /* init data */
  94. PROVIDE_HIDDEN (__init_array_start = .);
  95. KEEP(*(SORT(.init_array.*)))
  96. KEEP(*(.init_array))
  97. PROVIDE_HIDDEN (__init_array_end = .);
  98. . = ALIGN(4);
  99. /* finit data */
  100. PROVIDE_HIDDEN (__fini_array_start = .);
  101. KEEP(*(SORT(.fini_array.*)))
  102. KEEP(*(.fini_array))
  103. PROVIDE_HIDDEN (__fini_array_end = .);
  104. KEEP(*(.jcr*))
  105. . = ALIGN(4);
  106. /* All data end */
  107. __data_end__ = .;
  108. } > RAM
  109. .bss :
  110. {
  111. . = ALIGN(4);
  112. __bss_start__ = .;
  113. *(.bss*)
  114. *(COMMON)
  115. . = ALIGN(4);
  116. __bss_end__ = .;
  117. } > RAM
  118. .heap (COPY):
  119. {
  120. __HeapBase = .;
  121. __end__ = .;
  122. PROVIDE(end = .);
  123. KEEP(*(.heap*))
  124. __HeapLimit = .;
  125. } > RAM
  126. /* .stack_dummy section doesn't contains any symbols. It is only
  127. * used for linker to calculate size of stack sections, and assign
  128. * values to stack symbols later */
  129. .stack_dummy (COPY):
  130. {
  131. KEEP(*(.stack*))
  132. } > RAM
  133. /* Set stack top to end of RAM, and stack limit move down by
  134. * size of stack_dummy section */
  135. __StackTop = ORIGIN(RAM) + LENGTH(RAM);
  136. __StackLimit = __StackTop - SIZEOF(.stack_dummy);
  137. PROVIDE(__stack = __StackTop);
  138. /* Check if data + heap + stack exceeds RAM limit */
  139. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  140. /* Check if text sections + data exceeds FLASH limit */
  141. DataInitFlashUsed = __bss_start__ - __data_start__;
  142. CodeFlashUsed = __etext - ORIGIN(FLASH);
  143. TotalFlashUsed = CodeFlashUsed + DataInitFlashUsed;
  144. ASSERT(TotalFlashUsed <= LENGTH(FLASH), "region FLASH overflowed with .data and user data")
  145. }