lpc824.ld 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* source: gcc-arm-none-eabi-4_7-2013q1/share/gcc-arm-none-eabi/samples/ldscripts/mem.ld */
  2. /* Linker script to configure memory regions.
  3. * Need modifying for a specific board.
  4. * FLASH.ORIGIN: starting address of flash
  5. * FLASH.LENGTH: length of flash
  6. * RAM.ORIGIN: starting address of RAM bank 0
  7. * RAM.LENGTH: length of RAM bank 0
  8. */
  9. MEMORY
  10. {
  11. /* LPC82x User Manual Page 8 */
  12. FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 32K for LPC824 */
  13. RAM (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8K for LPC824 */
  14. }
  15. /* source: gcc-arm-none-eabi-4_7-2013q1/share/gcc-arm-none-eabi/samples/ldscripts/sections.ld */
  16. /* Linker script to place sections and symbol values. Should be used together
  17. * with other linker script that defines memory regions FLASH and RAM.
  18. * It references following symbols, which must be defined in code:
  19. * Reset_Handler : Entry of reset handler
  20. *
  21. * It defines following symbols, which code can use without definition:
  22. * __exidx_start
  23. * __exidx_end
  24. * __etext
  25. * __data_start__
  26. * __preinit_array_start
  27. * __preinit_array_end
  28. * __init_array_start
  29. * __init_array_end
  30. * __fini_array_start
  31. * __fini_array_end
  32. * __data_end__
  33. * __bss_start__
  34. * __bss_end__
  35. * __end__
  36. * end
  37. * __HeapLimit
  38. * __StackLimit
  39. * __StackTop
  40. * __stack
  41. */
  42. /* entry point */
  43. ENTRY(Reset_Handler)
  44. /* extern declaration so that the value appears correctly for the LPC checksum calculation */
  45. EXTERN(NMI_Handler)
  46. EXTERN(HardFault_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. __end__ = .;
  120. end = __end__;
  121. *(.heap*)
  122. __HeapLimit = .;
  123. } > RAM
  124. /* .stack_dummy section doesn't contains any symbols. It is only
  125. * used for linker to calculate size of stack sections, and assign
  126. * values to stack symbols later */
  127. .stack_dummy (COPY):
  128. {
  129. *(.stack*)
  130. } > RAM
  131. /* Set stack top to end of RAM, and stack limit move down by
  132. * size of stack_dummy section */
  133. __StackTop = ORIGIN(RAM) + LENGTH(RAM);
  134. __StackLimit = __StackTop - SIZEOF(.stack_dummy);
  135. PROVIDE(__stack = __StackTop);
  136. /* Check if data + heap + stack exceeds RAM limit */
  137. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  138. /*
  139. http://www.lpcware.com/content/forum/lpc1788-flash-signature-generation
  140. Section 3.5.2/page 12 of the LPC82x User Manual
  141. Linker works with even addresses, however to indicate thumb address mode,
  142. the lowest bit of the address is set to one. For the checksum calculation we
  143. only have the even addresses, however later in the isr table the compiler will
  144. store the odd addresses for the three handler subprocedures if compiled in
  145. thumb mode. Because of this, 3 is added to consider the three odd handler calls.
  146. */
  147. LPC_checksum = 0- (__StackTop + Reset_Handler + NMI_Handler + HardFault_Handler + 3 /* three entries */);
  148. }