Guest User

Untitled

a guest
Apr 6th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.51 KB | None | 0 0
  1. /*
  2. * Default linker script for Cortex-M (it includes specifics for STM32F[34]xx).
  3. *
  4. * To make use of the multi-region initialisations, define
  5. * OS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS for the _startup.c file.
  6. */
  7.  
  8. /*
  9. * The '__stack' definition is required by crt0, do not remove it.
  10. */
  11. __stack = ORIGIN(RAM) + LENGTH(RAM);
  12.  
  13. _estack = __stack; /* STM specific definition */
  14.  
  15. /*
  16. * Default stack sizes.
  17. * These are used by the startup in order to allocate stacks
  18. * for the different modes.
  19. */
  20.  
  21. __Main_Stack_Size = 1024 ;
  22.  
  23. PROVIDE ( _Main_Stack_Size = __Main_Stack_Size ) ;
  24.  
  25. __Main_Stack_Limit = __stack - __Main_Stack_Size ;
  26.  
  27. /* "PROVIDE" allows to easily override these values from an
  28. * object file or the command line. */
  29. PROVIDE ( _Main_Stack_Limit = __Main_Stack_Limit ) ;
  30.  
  31. /*
  32. * There will be a link error if there is not this amount of
  33. * RAM free at the end.
  34. */
  35. _Minimum_Stack_Size = 256 ;
  36.  
  37. /*
  38. * Default heap definitions.
  39. * The heap start immediately after the last statically allocated
  40. * .sbss/.noinit section, and extends up to the main stack limit.
  41. */
  42. PROVIDE ( _Heap_Begin = _end_noinit ) ;
  43. PROVIDE ( _Heap_Limit = __stack - __Main_Stack_Size ) ;
  44.  
  45. /*
  46. * The entry point is informative, for debuggers and simulators,
  47. * since the Cortex-M vector points to it anyway.
  48. */
  49. ENTRY(_start)
  50.  
  51.  
  52. /* Sections Definitions */
  53.  
  54. SECTIONS
  55. {
  56. /*
  57. * For Cortex-M devices, the beginning of the startup code is stored in
  58. * the .isr_vector section, which goes to FLASH.
  59. */
  60. .isr_vector : ALIGN(4)
  61. {
  62. FILL(0xFF)
  63.  
  64. __vectors_start = ABSOLUTE(.) ;
  65. __vectors_start__ = ABSOLUTE(.) ; /* STM specific definition */
  66. KEEP(*(.isr_vector)) /* Interrupt vectors */
  67.  
  68. KEEP(*(.cfmconfig)) /* Freescale configuration words */
  69.  
  70. /*
  71. * This section is here for convenience, to store the
  72. * startup code at the beginning of the flash area, hoping that
  73. * this will increase the readability of the listing.
  74. */
  75. *(.after_vectors .after_vectors.*) /* Startup code and ISR */
  76.  
  77. } >FLASH
  78.  
  79. .inits : ALIGN(4)
  80. {
  81. /*
  82. * Memory regions initialisation arrays.
  83. *
  84. * Thee are two kinds of arrays for each RAM region, one for
  85. * data and one for bss. Each is iterrated at startup and the
  86. * region initialisation is performed.
  87. *
  88. * The data array includes:
  89. * - from (LOADADDR())
  90. * - region_begin (ADDR())
  91. * - region_end (ADDR()+SIZEOF())
  92. *
  93. * The bss array includes:
  94. * - region_begin (ADDR())
  95. * - region_end (ADDR()+SIZEOF())
  96. *
  97. * WARNING: It is mandatory that the regions are word aligned,
  98. * since the initialisation code works only on words.
  99. */
  100.  
  101. __data_regions_array_start = .;
  102.  
  103. LONG(LOADADDR(.data));
  104. LONG(ADDR(.data));
  105. LONG(ADDR(.data)+SIZEOF(.data));
  106.  
  107. LONG(LOADADDR(.data_CCMRAM));
  108. LONG(ADDR(.data_CCMRAM));
  109. LONG(ADDR(.data_CCMRAM)+SIZEOF(.data_CCMRAM));
  110.  
  111. __data_regions_array_end = .;
  112.  
  113. __bss_regions_array_start = .;
  114.  
  115. LONG(ADDR(.bss));
  116. LONG(ADDR(.bss)+SIZEOF(.bss));
  117.  
  118. LONG(ADDR(.bss_CCMRAM));
  119. LONG(ADDR(.bss_CCMRAM)+SIZEOF(.bss_CCMRAM));
  120.  
  121. __bss_regions_array_end = .;
  122.  
  123. /* End of memory regions initialisation arrays. */
  124.  
  125. /*
  126. * These are the old initialisation sections, intended to contain
  127. * naked code, with the prologue/epilogue added by crti.o/crtn.o
  128. * when linking with startup files. The standalone startup code
  129. * currently does not run these, better use the init arrays below.
  130. */
  131. KEEP(*(.init))
  132. KEEP(*(.fini))
  133.  
  134. . = ALIGN(4);
  135.  
  136. /*
  137. * The preinit code, i.e. an array of pointers to initialisation
  138. * functions to be performed before constructors.
  139. */
  140. PROVIDE_HIDDEN (__preinit_array_start = .);
  141.  
  142. /*
  143. * Used to run the SystemInit() before anything else.
  144. */
  145. KEEP(*(.preinit_array_sysinit .preinit_array_sysinit.*))
  146.  
  147. /*
  148. * Used for other platform inits.
  149. */
  150. KEEP(*(.preinit_array_platform .preinit_array_platform.*))
  151.  
  152. /*
  153. * The application inits. If you need to enforce some order in
  154. * execution, create new sections, as before.
  155. */
  156. KEEP(*(.preinit_array .preinit_array.*))
  157.  
  158. PROVIDE_HIDDEN (__preinit_array_end = .);
  159.  
  160. . = ALIGN(4);
  161.  
  162. /*
  163. * The init code, i.e. an array of pointers to static constructors.
  164. */
  165. PROVIDE_HIDDEN (__init_array_start = .);
  166. KEEP(*(SORT(.init_array.*)))
  167. KEEP(*(.init_array))
  168. PROVIDE_HIDDEN (__init_array_end = .);
  169.  
  170. . = ALIGN(4);
  171.  
  172. /*
  173. * The fini code, i.e. an array of pointers to static destructors.
  174. */
  175. PROVIDE_HIDDEN (__fini_array_start = .);
  176. KEEP(*(SORT(.fini_array.*)))
  177. KEEP(*(.fini_array))
  178. PROVIDE_HIDDEN (__fini_array_end = .);
  179.  
  180. } >FLASH
  181.  
  182. /*
  183. * For some STRx devices, the beginning of the startup code
  184. * is stored in the .flashtext section, which goes to FLASH.
  185. */
  186. .flashtext : ALIGN(4)
  187. {
  188. *(.flashtext .flashtext.*) /* Startup code */
  189. } >FLASH
  190.  
  191.  
  192. /*
  193. * The program code is stored in the .text section,
  194. * which goes to FLASH.
  195. */
  196. .text : ALIGN(4)
  197. {
  198. *(.text .text.*) /* all remaining code */
  199.  
  200. /* read-only data (constants) */
  201. *(.rodata .rodata.* .constdata .constdata.*)
  202.  
  203. *(vtable) /* C++ virtual tables */
  204.  
  205. KEEP(*(.eh_frame*))
  206.  
  207. /*
  208. * Stub sections generated by the linker, to glue together
  209. * ARM and Thumb code. .glue_7 is used for ARM code calling
  210. * Thumb code, and .glue_7t is used for Thumb code calling
  211. * ARM code. Apparently always generated by the linker, for some
  212. * architectures, so better leave them here.
  213. */
  214. *(.glue_7)
  215. *(.glue_7t)
  216.  
  217. } >FLASH
  218.  
  219. /* ARM magic sections */
  220. .ARM.extab : ALIGN(4)
  221. {
  222. *(.ARM.extab* .gnu.linkonce.armextab.*)
  223. } > FLASH
  224.  
  225. . = ALIGN(4);
  226. __exidx_start = .;
  227. .ARM.exidx : ALIGN(4)
  228. {
  229. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  230. } > FLASH
  231. __exidx_end = .;
  232.  
  233. . = ALIGN(4);
  234. _etext = .;
  235. __etext = .;
  236.  
  237. /* MEMORY_ARRAY */
  238. /*
  239. .ROarraySection :
  240. {
  241. *(.ROarraySection .ROarraySection.*)
  242. } >MEMORY_ARRAY
  243. */
  244.  
  245. /*
  246. * The secondary initialised data section.
  247. */
  248. .data_CCMRAM : ALIGN(4)
  249. {
  250. FILL(0xFF)
  251. *(.data.CCMRAM .data.CCMRAM.*)
  252. . = ALIGN(4) ;
  253. } > CCMRAM AT>FLASH
  254.  
  255. /*
  256. * This address is used by the startup code to
  257. * initialise the .data section.
  258. */
  259. _sidata = LOADADDR(.data);
  260.  
  261. /*
  262. * The initialised data section.
  263. *
  264. * The program executes knowing that the data is in the RAM
  265. * but the loader puts the initial values in the FLASH (inidata).
  266. * It is one task of the startup to copy the initial values from
  267. * FLASH to RAM.
  268. */
  269. .data : ALIGN(4)
  270. {
  271. FILL(0xFF)
  272. /* This is used by the startup code to initialise the .data section */
  273. _sdata = . ; /* STM specific definition */
  274. __data_start__ = . ;
  275. *(.data_begin .data_begin.*)
  276.  
  277. *(.data .data.*)
  278.  
  279. *(.data_end .data_end.*)
  280. . = ALIGN(4);
  281.  
  282. /* This is used by the startup code to initialise the .data section */
  283. _edata = . ; /* STM specific definition */
  284. __data_end__ = . ;
  285.  
  286. } >RAM AT>FLASH
  287.  
  288. /*
  289. * The uninitialised data sections. NOLOAD is used to avoid
  290. * the "section `.bss' type changed to PROGBITS" warning
  291. */
  292.  
  293. /* The secondary uninitialised data section. */
  294. .bss_CCMRAM (NOLOAD) : ALIGN(4)
  295. {
  296. *(.bss.CCMRAM .bss.CCMRAM.*)
  297. } > CCMRAM
  298.  
  299. /* The primary uninitialised data section. */
  300. .bss (NOLOAD) : ALIGN(4)
  301. {
  302. __bss_start__ = .; /* standard newlib definition */
  303. _sbss = .; /* STM specific definition */
  304. *(.bss_begin .bss_begin.*)
  305.  
  306. *(.bss .bss.*)
  307. *(COMMON)
  308.  
  309. *(.bss_end .bss_end.*)
  310. . = ALIGN(4);
  311. __bss_end__ = .; /* standard newlib definition */
  312. _ebss = . ; /* STM specific definition */
  313. } >RAM
  314.  
  315. .noinit_CCMRAM (NOLOAD) : ALIGN(4)
  316. {
  317. *(.noinit.CCMRAM .noinit.CCMRAM.*)
  318. } > CCMRAM
  319.  
  320. .noinit (NOLOAD) : ALIGN(4)
  321. {
  322. _noinit = .;
  323.  
  324. *(.noinit .noinit.*)
  325.  
  326. . = ALIGN(4) ;
  327. _end_noinit = .;
  328. } > RAM
  329.  
  330. /* Mandatory to be word aligned, _sbrk assumes this */
  331. PROVIDE ( end = _end_noinit ); /* was _ebss */
  332. PROVIDE ( _end = _end_noinit );
  333. PROVIDE ( __end = _end_noinit );
  334. PROVIDE ( __end__ = _end_noinit );
  335.  
  336. /*
  337. * Used for validation only, do not allocate anything here!
  338. *
  339. * This is just to check that there is enough RAM left for the Main
  340. * stack. It should generate an error if it's full.
  341. */
  342. ._check_stack : ALIGN(4)
  343. {
  344. . = . + _Minimum_Stack_Size ;
  345. } >RAM
  346.  
  347. /*
  348. * The FLASH Bank1.
  349. * The C or assembly source must explicitly place the code
  350. * or data there using the "section" attribute.
  351. */
  352. .b1text : ALIGN(4)
  353. {
  354. *(.b1text) /* remaining code */
  355. *(.b1rodata) /* read-only data (constants) */
  356. *(.b1rodata.*)
  357. } >FLASHB1
  358.  
  359. /*
  360. * The EXTMEM.
  361. * The C or assembly source must explicitly place the code or data there
  362. * using the "section" attribute.
  363. */
  364.  
  365. /* EXTMEM Bank0 */
  366. .eb0text : ALIGN(4)
  367. {
  368. *(.eb0text) /* remaining code */
  369. *(.eb0rodata) /* read-only data (constants) */
  370. *(.eb0rodata.*)
  371. } >EXTMEMB0
  372.  
  373. /* EXTMEM Bank1 */
  374. .eb1text : ALIGN(4)
  375. {
  376. *(.eb1text) /* remaining code */
  377. *(.eb1rodata) /* read-only data (constants) */
  378. *(.eb1rodata.*)
  379. } >EXTMEMB1
  380.  
  381. /* EXTMEM Bank2 */
  382. .eb2text : ALIGN(4)
  383. {
  384. *(.eb2text) /* remaining code */
  385. *(.eb2rodata) /* read-only data (constants) */
  386. *(.eb2rodata.*)
  387. } >EXTMEMB2
  388.  
  389. /* EXTMEM Bank0 */
  390. .eb3text : ALIGN(4)
  391. {
  392. *(.eb3text) /* remaining code */
  393. *(.eb3rodata) /* read-only data (constants) */
  394. *(.eb3rodata.*)
  395. } >EXTMEMB3
  396.  
  397.  
  398. /* After that there are only debugging sections. */
  399.  
  400. /* This can remove the debugging information from the standard libraries */
  401. /*
  402. DISCARD :
  403. {
  404. libc.a ( * )
  405. libm.a ( * )
  406. libgcc.a ( * )
  407. }
  408. */
  409.  
  410. /* Stabs debugging sections. */
  411. .stab 0 : { *(.stab) }
  412. .stabstr 0 : { *(.stabstr) }
  413. .stab.excl 0 : { *(.stab.excl) }
  414. .stab.exclstr 0 : { *(.stab.exclstr) }
  415. .stab.index 0 : { *(.stab.index) }
  416. .stab.indexstr 0 : { *(.stab.indexstr) }
  417. .comment 0 : { *(.comment) }
  418. /*
  419. * DWARF debug sections.
  420. * Symbols in the DWARF debugging sections are relative to the beginning
  421. * of the section so we begin them at 0.
  422. */
  423. /* DWARF 1 */
  424. .debug 0 : { *(.debug) }
  425. .line 0 : { *(.line) }
  426. /* GNU DWARF 1 extensions */
  427. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  428. .debug_sfnames 0 : { *(.debug_sfnames) }
  429. /* DWARF 1.1 and DWARF 2 */
  430. .debug_aranges 0 : { *(.debug_aranges) }
  431. .debug_pubnames 0 : { *(.debug_pubnames) }
  432. /* DWARF 2 */
  433. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  434. .debug_abbrev 0 : { *(.debug_abbrev) }
  435. .debug_line 0 : { *(.debug_line) }
  436. .debug_frame 0 : { *(.debug_frame) }
  437. .debug_str 0 : { *(.debug_str) }
  438. .debug_loc 0 : { *(.debug_loc) }
  439. .debug_macinfo 0 : { *(.debug_macinfo) }
  440. /* SGI/MIPS DWARF 2 extensions */
  441. .debug_weaknames 0 : { *(.debug_weaknames) }
  442. .debug_funcnames 0 : { *(.debug_funcnames) }
  443. .debug_typenames 0 : { *(.debug_typenames) }
  444. .debug_varnames 0 : { *(.debug_varnames) }
  445. }
Advertisement
Add Comment
Please, Sign In to add comment