stm32f1_flash.ld.in 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 = ${STM32_STACK_ADDRESS}; /* end of RAM */
  17. /* Generate a link error if heap and stack don't fit into RAM */
  18. _Min_Heap_Size = ${STM32_MIN_HEAP_SIZE}; /* required amount of heap */
  19. _Min_Stack_Size = ${STM32_MIN_STACK_SIZE}; /* required amount of stack */
  20. /* Specify the memory areas */
  21. MEMORY
  22. {
  23. FLASH (rx) : ORIGIN = ${STM32_FLASH_ORIGIN}, LENGTH = ${STM32_FLASH_SIZE}
  24. RAM (xrw) : ORIGIN = ${STM32_RAM_ORIGIN}, LENGTH = ${STM32_RAM_SIZE}
  25. }
  26. /* Define output sections */
  27. SECTIONS
  28. {
  29. /* The startup code goes first into FLASH */
  30. .isr_vector :
  31. {
  32. . = ALIGN(4);
  33. KEEP(*(.isr_vector)) /* Startup code */
  34. . = ALIGN(4);
  35. } >FLASH
  36. /* The program code and other data goes into FLASH */
  37. .text :
  38. {
  39. . = ALIGN(4);
  40. *(.text) /* .text sections (code) */
  41. *(.text*) /* .text* sections (code) */
  42. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  43. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  44. *(.glue_7) /* glue arm to thumb code */
  45. *(.glue_7t) /* glue thumb to arm code */
  46. KEEP (*(.init))
  47. KEEP (*(.fini))
  48. . = ALIGN(4);
  49. _etext = .; /* define a global symbols at end of code */
  50. } >FLASH
  51. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  52. .ARM : {
  53. __exidx_start = .;
  54. *(.ARM.exidx*)
  55. __exidx_end = .;
  56. } >FLASH
  57. .ARM.attributes : { *(.ARM.attributes) } > FLASH
  58. .preinit_array :
  59. {
  60. PROVIDE_HIDDEN (__preinit_array_start = .);
  61. KEEP (*(.preinit_array*))
  62. PROVIDE_HIDDEN (__preinit_array_end = .);
  63. } >FLASH
  64. .init_array :
  65. {
  66. PROVIDE_HIDDEN (__init_array_start = .);
  67. KEEP (*(SORT(.init_array.*)))
  68. KEEP (*(.init_array*))
  69. PROVIDE_HIDDEN (__init_array_end = .);
  70. } >FLASH
  71. .fini_array :
  72. {
  73. PROVIDE_HIDDEN (__fini_array_start = .);
  74. KEEP (*(.fini_array*))
  75. KEEP (*(SORT(.fini_array.*)))
  76. PROVIDE_HIDDEN (__fini_array_end = .);
  77. } >FLASH
  78. /* used by the startup to initialize data */
  79. _sidata = .;
  80. /* Initialized data sections goes into RAM, load LMA copy after code */
  81. .data : AT ( _sidata )
  82. {
  83. . = ALIGN(4);
  84. _sdata = .; /* create a global symbol at data start */
  85. *(.data) /* .data sections */
  86. *(.data*) /* .data* sections */
  87. . = ALIGN(4);
  88. _edata = .; /* define a global symbol at data end */
  89. } >RAM
  90. /* Uninitialized data section */
  91. . = ALIGN(4);
  92. .bss :
  93. {
  94. /* This is used by the startup in order to initialize the .bss secion */
  95. _sbss = .; /* define a global symbol at bss start */
  96. __bss_start__ = _sbss;
  97. *(.bss)
  98. *(.bss*)
  99. *(COMMON)
  100. . = ALIGN(4);
  101. _ebss = .; /* define a global symbol at bss end */
  102. __bss_end__ = _ebss;
  103. } >RAM
  104. PROVIDE ( end = _ebss );
  105. PROVIDE ( _end = _ebss );
  106. /* User_heap_stack section, used to check that there is enough RAM left */
  107. ._user_heap_stack :
  108. {
  109. . = ALIGN(4);
  110. . = . + _Min_Heap_Size;
  111. . = . + _Min_Stack_Size;
  112. . = ALIGN(4);
  113. } >RAM
  114. /* Remove information from the standard libraries */
  115. /DISCARD/ :
  116. {
  117. libc.a ( * )
  118. libm.a ( * )
  119. libgcc.a ( * )
  120. }
  121. }