link.x 2.0 KB

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