gcc_nrf51_common.ld 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* Linker script for Nordic Semiconductor nRF5 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. * __HeapLimit
  41. * __StackLimit
  42. * __StackTop
  43. * __stack
  44. */
  45. ENTRY(Reset_Handler)
  46. SECTIONS
  47. {
  48. .text :
  49. {
  50. KEEP(*(.Vectors))
  51. *(.text*)
  52. KEEP(*(.init))
  53. KEEP(*(.fini))
  54. /* .ctors */
  55. *crtbegin.o(.ctors)
  56. *crtbegin?.o(.ctors)
  57. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  58. *(SORT(.ctors.*))
  59. *(.ctors)
  60. /* .dtors */
  61. *crtbegin.o(.dtors)
  62. *crtbegin?.o(.dtors)
  63. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  64. *(SORT(.dtors.*))
  65. *(.dtors)
  66. *(.rodata*)
  67. *(.eh_frame*)
  68. . = ALIGN(4);
  69. } > FLASH
  70. .ARM.extab :
  71. {
  72. *(.ARM.extab* .gnu.linkonce.armextab.*)
  73. . = ALIGN(4);
  74. } > FLASH
  75. __exidx_start = .;
  76. .ARM.exidx :
  77. {
  78. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  79. . = ALIGN(4);
  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. *(.preinit_array)
  92. PROVIDE_HIDDEN (__preinit_array_end = .);
  93. . = ALIGN(4);
  94. /* init data */
  95. PROVIDE_HIDDEN (__init_array_start = .);
  96. *(SORT(.init_array.*))
  97. *(.init_array)
  98. PROVIDE_HIDDEN (__init_array_end = .);
  99. . = ALIGN(4);
  100. /* finit data */
  101. PROVIDE_HIDDEN (__fini_array_start = .);
  102. *(SORT(.fini_array.*))
  103. *(.fini_array)
  104. PROVIDE_HIDDEN (__fini_array_end = .);
  105. *(.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. __end__ = .;
  122. end = __end__;
  123. *(.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. *(.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. }