stm32f4_flash.ld.in 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. Default linker script for STM32F4xx_1024K_192K
  3. */
  4. /* include the common STM32F4xx sub-script */
  5. /* Common part of the linker scripts for STM32F devices*/
  6. /* default stack sizes.
  7. These are used by the startup in order to allocate stacks for the different modes.
  8. */
  9. __Stack_Size = 1024 ;
  10. PROVIDE ( _Stack_Size = __Stack_Size ) ;
  11. __Stack_Init = _estack - __Stack_Size ;
  12. /*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/
  13. PROVIDE ( _Stack_Init = __Stack_Init ) ;
  14. /*
  15. There will be a link error if there is not this amount of RAM free at the end.
  16. */
  17. _Minimum_Stack_Size = ${STM32_MIN_STACK_SIZE} ;
  18. /* include the memory spaces definitions sub-script */
  19. /*
  20. Linker subscript for STM32F4xx definitions with 1024 Flash and 192 Onchip SRAM */
  21. /* Memory Spaces Definitions */
  22. MEMORY
  23. {
  24. RAM (xrw) : ORIGIN = ${STM32_RAM_ORIGIN}, LENGTH = ${STM32_RAM_SIZE}
  25. CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
  26. FLASH (rx) : ORIGIN = ${STM32_FLASH_ORIGIN}, LENGTH = ${STM32_FLASH_SIZE}
  27. MEMORY_ARRAY (xrw) : ORIGIN = 0x20002000, LENGTH = 32
  28. }
  29. /* higher address of the user mode stack (end of 128K RAM on AHB bus)*/
  30. _estack = ${STM32_STACK_ADDRESS};
  31. /* include the sections management sub-script for FLASH mode */
  32. /* Sections Definitions */
  33. SECTIONS
  34. {
  35. /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */
  36. .isr_vector :
  37. {
  38. . = ALIGN(4);
  39. KEEP(*(.isr_vector)) /* Startup code */
  40. . = ALIGN(4);
  41. } >FLASH
  42. /* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */
  43. .flashtext :
  44. {
  45. . = ALIGN(4);
  46. *(.flashtext) /* Startup code */
  47. . = ALIGN(4);
  48. } >FLASH
  49. /* the program code is stored in the .text section, which goes to Flash */
  50. .text :
  51. {
  52. . = ALIGN(4);
  53. *(.text) /* remaining code */
  54. *(.text.*) /* remaining code */
  55. *(.rodata) /* read-only data (constants) */
  56. *(.rodata*)
  57. *(.glue_7)
  58. *(.glue_7t)
  59. . = ALIGN(4);
  60. _etext = .;
  61. /* This is used by the startup in order to initialize the .data secion */
  62. _sidata = _etext;
  63. } >FLASH
  64. /* MEMORY_ARRAY */
  65. .ROarraySection :
  66. {
  67. *(.ROarraySection)
  68. } >MEMORY_ARRAY
  69. /* This is the initialized data section
  70. The program executes knowing that the data is in the RAM
  71. but the loader puts the initial values in the FLASH (inidata).
  72. It is one task of the startup to copy the initial values from FLASH to RAM. */
  73. .data : AT ( _sidata )
  74. {
  75. . = ALIGN(4);
  76. /* This is used by the startup in order to initialize the .data secion */
  77. _sdata = . ;
  78. *(.data)
  79. *(.data.*)
  80. . = ALIGN(4);
  81. /* This is used by the startup in order to initialize the .data secion */
  82. _edata = . ;
  83. } >RAM
  84. /* This is the uninitialized data section */
  85. .bss :
  86. {
  87. . = ALIGN(4);
  88. /* This is used by the startup in order to initialize the .bss secion */
  89. _sbss = .;
  90. *(.bss)
  91. *(COMMON)
  92. . = ALIGN(4);
  93. /* This is used by the startup in order to initialize the .bss secion */
  94. _ebss = . ;
  95. } >RAM
  96. PROVIDE ( end = _ebss );
  97. PROVIDE ( _end = _ebss );
  98. /* This is the user stack section
  99. This is just to check that there is enough RAM left for the User mode stack
  100. It should generate an error if it's full.
  101. */
  102. ._usrstack :
  103. {
  104. . = ALIGN(4);
  105. _susrstack = . ;
  106. . = . + _Minimum_Stack_Size ;
  107. . = ALIGN(4);
  108. _eusrstack = . ;
  109. } >RAM
  110. /* after that it's only debugging information. */
  111. /* remove the debugging information from the standard libraries */
  112. DISCARD :
  113. {
  114. libc.a ( * )
  115. libm.a ( * )
  116. libgcc.a ( * )
  117. }
  118. /* Stabs debugging sections. */
  119. .stab 0 : { *(.stab) }
  120. .stabstr 0 : { *(.stabstr) }
  121. .stab.excl 0 : { *(.stab.excl) }
  122. .stab.exclstr 0 : { *(.stab.exclstr) }
  123. .stab.index 0 : { *(.stab.index) }
  124. .stab.indexstr 0 : { *(.stab.indexstr) }
  125. .comment 0 : { *(.comment) }
  126. /* DWARF debug sections.
  127. Symbols in the DWARF debugging sections are relative to the beginning
  128. of the section so we begin them at 0. */
  129. /* DWARF 1 */
  130. .debug 0 : { *(.debug) }
  131. .line 0 : { *(.line) }
  132. /* GNU DWARF 1 extensions */
  133. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  134. .debug_sfnames 0 : { *(.debug_sfnames) }
  135. /* DWARF 1.1 and DWARF 2 */
  136. .debug_aranges 0 : { *(.debug_aranges) }
  137. .debug_pubnames 0 : { *(.debug_pubnames) }
  138. /* DWARF 2 */
  139. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  140. .debug_abbrev 0 : { *(.debug_abbrev) }
  141. .debug_line 0 : { *(.debug_line) }
  142. .debug_frame 0 : { *(.debug_frame) }
  143. .debug_str 0 : { *(.debug_str) }
  144. .debug_loc 0 : { *(.debug_loc) }
  145. .debug_macinfo 0 : { *(.debug_macinfo) }
  146. /* SGI/MIPS DWARF 2 extensions */
  147. .debug_weaknames 0 : { *(.debug_weaknames) }
  148. .debug_funcnames 0 : { *(.debug_funcnames) }
  149. .debug_typenames 0 : { *(.debug_typenames) }
  150. .debug_varnames 0 : { *(.debug_varnames) }
  151. }