link.ld 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* https://cirosantilli.com/linux-kernel-module-cheat#baremetal-linker-script */
  2. ENTRY(_start)
  3. SECTIONS
  4. {
  5. .text : {
  6. */bootloader.o(.text)
  7. *(.text)
  8. *(.rodata)
  9. *(.data)
  10. *(COMMON)
  11. }
  12. /* gem5 uses the bss as a measure of the kernel size.
  13. * b7887ac06bd7fc8011fbf595b1d50ea67960d28c required __bss_start__
  14. * when doing ./build-dhrystone --arch aarch64 --mode baremetal
  15. */
  16. __bss_start__ = .;
  17. .bss : { *(.bss) }
  18. __bss_end__ = .;
  19. /* Fix the addresses of everything that comes after, no matter
  20. * the exact size of the code present in .text. This allows us to
  21. * place CLI arguments in memory at a known location! */
  22. /* TODO would be better like this with --section-start=.lkmc_memory= on CLI,
  23. * so that Python controls this value, but I can't that fucking working.
  24. * baremetal_max_size from the Python must match this offset for now.
  25. */
  26. /*. = SEGMENT_START(.lkmc_memory, .);*/
  27. . = ADDR(.text) + 0x1000000;
  28. lkmc_heap_low = .;
  29. . = . + 0x1000000;
  30. lkmc_heap_top = .;
  31. . = . + 0x1000000;
  32. lkmc_stack_top = .;
  33. lkmc_argc = .;
  34. . = . + 0x4;
  35. lkmc_argv = .;
  36. }