nrf_common.ld 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. __etext = .;
  81. .data : AT (__etext)
  82. {
  83. __data_start__ = .;
  84. *(vtable)
  85. *(.data*)
  86. . = ALIGN(4);
  87. /* preinit data */
  88. PROVIDE_HIDDEN (__preinit_array_start = .);
  89. KEEP(*(.preinit_array))
  90. PROVIDE_HIDDEN (__preinit_array_end = .);
  91. . = ALIGN(4);
  92. /* init data */
  93. PROVIDE_HIDDEN (__init_array_start = .);
  94. KEEP(*(SORT(.init_array.*)))
  95. KEEP(*(.init_array))
  96. PROVIDE_HIDDEN (__init_array_end = .);
  97. . = ALIGN(4);
  98. /* finit data */
  99. PROVIDE_HIDDEN (__fini_array_start = .);
  100. KEEP(*(SORT(.fini_array.*)))
  101. KEEP(*(.fini_array))
  102. PROVIDE_HIDDEN (__fini_array_end = .);
  103. KEEP(*(.jcr*))
  104. . = ALIGN(4);
  105. /* All data end */
  106. __data_end__ = .;
  107. } > RAM
  108. .bss :
  109. {
  110. . = ALIGN(4);
  111. __bss_start__ = .;
  112. *(.bss*)
  113. *(COMMON)
  114. . = ALIGN(4);
  115. __bss_end__ = .;
  116. } > RAM
  117. .heap (COPY):
  118. {
  119. __HeapBase = .;
  120. __end__ = .;
  121. PROVIDE(end = .);
  122. KEEP(*(.heap*))
  123. __HeapLimit = .;
  124. } > RAM
  125. /* .stack_dummy section doesn't contains any symbols. It is only
  126. * used for linker to calculate size of stack sections, and assign
  127. * values to stack symbols later */
  128. .stack_dummy (COPY):
  129. {
  130. KEEP(*(.stack*))
  131. } > RAM
  132. /* Set stack top to end of RAM, and stack limit move down by
  133. * size of stack_dummy section */
  134. __StackTop = ORIGIN(RAM) + LENGTH(RAM);
  135. __StackLimit = __StackTop - SIZEOF(.stack_dummy);
  136. PROVIDE(__stack = __StackTop);
  137. /* Check if data + heap + stack exceeds RAM limit */
  138. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  139. /* Check if text sections + data exceeds FLASH limit */
  140. DataInitFlashUsed = __bss_start__ - __data_start__;
  141. CodeFlashUsed = __etext - ORIGIN(FLASH);
  142. TotalFlashUsed = CodeFlashUsed + DataInitFlashUsed;
  143. ASSERT(TotalFlashUsed <= LENGTH(FLASH), "region FLASH overflowed with .data and user data")
  144. }