nrf52_common.ld 4.5 KB

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