nrf51_common.ld 4.5 KB

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