stm32f1_flash.ld.in 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. *****************************************************************************
  3. **
  4. ** Linker script for STM32F10x devices
  5. **
  6. ** Set heap size, stack size and stack location according
  7. ** to application requirements.
  8. **
  9. ** Set memory bank area and size if external memory is used.
  10. **
  11. *****************************************************************************
  12. */
  13. /* Entry Point */
  14. ENTRY(Reset_Handler)
  15. /* Highest address of the user mode stack */
  16. _estack = ${STACK_ADDRESS}; /* end of RAM */
  17. /* Generate a link error if heap and stack don't fit into RAM */
  18. _Min_Heap_Size = ${MIN_HEAP_SIZE}; /* required amount of heap */
  19. _Min_Stack_Size = ${MIN_STACK_SIZE}; /* required amount of stack */
  20. /* Specify the memory areas */
  21. MEMORY
  22. {
  23. FLASH (rx) : ORIGIN = ${FLASH_ORIGIN}, LENGTH = ${FLASH_SIZE}
  24. RAM (xrw) : ORIGIN = ${RAM_ORIGIN}, LENGTH = ${RAM_SIZE}
  25. MEMORY_B1 (rx) : ORIGIN = ${EXT_RAM_ORIGIN}, LENGTH = ${EXT_RAM_SIZE}
  26. }
  27. /* Define output sections */
  28. SECTIONS
  29. {
  30. /* The startup code goes first into FLASH */
  31. .isr_vector :
  32. {
  33. . = ALIGN(4);
  34. KEEP(*(.isr_vector)) /* Startup code */
  35. . = ALIGN(4);
  36. } >FLASH
  37. /* The program code and other data goes into FLASH */
  38. .text :
  39. {
  40. . = ALIGN(4);
  41. *(.text) /* .text sections (code) */
  42. *(.text*) /* .text* sections (code) */
  43. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  44. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  45. *(.glue_7) /* glue arm to thumb code */
  46. *(.glue_7t) /* glue thumb to arm code */
  47. KEEP (*(.init))
  48. KEEP (*(.fini))
  49. . = ALIGN(4);
  50. _etext = .; /* define a global symbols at end of code */
  51. } >FLASH
  52. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  53. .ARM : {
  54. __exidx_start = .;
  55. *(.ARM.exidx*)
  56. __exidx_end = .;
  57. } >FLASH
  58. .ARM.attributes : { *(.ARM.attributes) } > FLASH
  59. .preinit_array :
  60. {
  61. PROVIDE_HIDDEN (__preinit_array_start = .);
  62. KEEP (*(.preinit_array*))
  63. PROVIDE_HIDDEN (__preinit_array_end = .);
  64. } >FLASH
  65. .init_array :
  66. {
  67. PROVIDE_HIDDEN (__init_array_start = .);
  68. KEEP (*(SORT(.init_array.*)))
  69. KEEP (*(.init_array*))
  70. PROVIDE_HIDDEN (__init_array_end = .);
  71. } >FLASH
  72. .fini_array :
  73. {
  74. PROVIDE_HIDDEN (__fini_array_start = .);
  75. KEEP (*(.fini_array*))
  76. KEEP (*(SORT(.fini_array.*)))
  77. PROVIDE_HIDDEN (__fini_array_end = .);
  78. } >FLASH
  79. /* used by the startup to initialize data */
  80. _sidata = .;
  81. /* Initialized data sections goes into RAM, load LMA copy after code */
  82. .data : AT ( _sidata )
  83. {
  84. . = ALIGN(4);
  85. _sdata = .; /* create a global symbol at data start */
  86. *(.data) /* .data sections */
  87. *(.data*) /* .data* sections */
  88. . = ALIGN(4);
  89. _edata = .; /* define a global symbol at data end */
  90. } >RAM
  91. /* Uninitialized data section */
  92. . = ALIGN(4);
  93. .bss :
  94. {
  95. /* This is used by the startup in order to initialize the .bss secion */
  96. _sbss = .; /* define a global symbol at bss start */
  97. __bss_start__ = _sbss;
  98. *(.bss)
  99. *(.bss*)
  100. *(COMMON)
  101. . = ALIGN(4);
  102. _ebss = .; /* define a global symbol at bss end */
  103. __bss_end__ = _ebss;
  104. } >RAM
  105. PROVIDE ( end = _ebss );
  106. PROVIDE ( _end = _ebss );
  107. /* User_heap_stack section, used to check that there is enough RAM left */
  108. ._user_heap_stack :
  109. {
  110. . = ALIGN(4);
  111. . = . + _Min_Heap_Size;
  112. . = . + _Min_Stack_Size;
  113. . = ALIGN(4);
  114. } >RAM
  115. /* MEMORY_bank1 section, code must be located here explicitly */
  116. /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
  117. .memory_b1_text :
  118. {
  119. *(.mb1text) /* .mb1text sections (code) */
  120. *(.mb1text*) /* .mb1text* sections (code) */
  121. *(.mb1rodata) /* read-only data (constants) */
  122. *(.mb1rodata*)
  123. } >MEMORY_B1
  124. /* Remove information from the standard libraries */
  125. /DISCARD/ :
  126. {
  127. libc.a ( * )
  128. libm.a ( * )
  129. libgcc.a ( * )
  130. }
  131. }