link.x 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* NOTE: Adapted from cortex-m/link.x */
  2. INCLUDE memory.x
  3. PROVIDE(_stack_start = ORIGIN(RAM) + LENGTH(RAM));
  4. SECTIONS
  5. {
  6. PROVIDE(_stext = ORIGIN(FLASH));
  7. .text ALIGN(_stext,4) :
  8. {
  9. /* Put reset handler first in .text section so it ends up as the entry */
  10. /* point of the program. */
  11. KEEP(*(.init));
  12. KEEP(*(.init.rust));
  13. KEEP(*(.trap));
  14. KEEP(*(.trap.rust));
  15. *(.text .text.*);
  16. } > FLASH
  17. .rodata ALIGN(4) :
  18. {
  19. *(.rodata .rodata.*);
  20. } > FLASH
  21. PROVIDE(_sbss = ORIGIN(RAM));
  22. .bss ALIGN(_sbss,4) :
  23. {
  24. *(.bss .bss.*);
  25. . = ALIGN(4);
  26. _ebss = .;
  27. } > RAM
  28. .data _ebss :
  29. {
  30. _sidata = LOADADDR(.data);
  31. _sdata = .;
  32. /* Must be called __global_pointer$ for linker relaxations to work. */
  33. PROVIDE(__global_pointer$ = . + 0x800);
  34. *(.data .data.*);
  35. . = ALIGN(4);
  36. _edata = .;
  37. } > RAM AT > FLASH /* LLD fails on AT > FLASH */
  38. PROVIDE(_heap_size = 0);
  39. /* fictitious region that represents the memory available for the heap */
  40. .heap _edata (INFO) : ALIGN(4)
  41. {
  42. _sheap = .;
  43. . += _heap_size;
  44. . = ALIGN(4);
  45. _eheap = .;
  46. }
  47. /* fictitious region that represents the memory available for the stack */
  48. .stack _eheap (INFO) : ALIGN(4)
  49. {
  50. _estack = .;
  51. . = _stack_start;
  52. _sstack = .;
  53. }
  54. /* fake output .got section */
  55. /* Dynamic relocations are unsupported. This section is only used to detect
  56. relocatable code in the input files and raise an error if relocatable code
  57. is found */
  58. .got :
  59. {
  60. _sgot = .;
  61. KEEP(*(.got .got.*));
  62. _egot = .;
  63. } > RAM AT > FLASH /* LLD fails on AT > FLASH */
  64. }
  65. /* Do not exceed this mark in the error messages below | */
  66. ASSERT(_sgot == _egot, "
  67. .got section detected in the input files. Dynamic relocations are not
  68. supported. If you are linking to C code compiled using the `gcc` crate
  69. then modify your build script to compile the C code _without_ the
  70. -fPIC flag. See the documentation of the `gcc::Config.fpic` method for
  71. details.");