link.x 2.0 KB

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