kernel.ld 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* VESA real-mode stage at 0x7E00, then kernel_main follows. */
  2. ENTRY(_vesa_stage)
  3. SECTIONS
  4. {
  5. . = 0x7E00;
  6. .text : AT(0x7E00) {
  7. *(.text.stage2)
  8. *(.text .text.*)
  9. }
  10. .rodata : { *(.rodata .rodata.*) }
  11. .data : { *(.data .data.*) }
  12. .bss : {
  13. __bss_start = .;
  14. *(.bss .bss.*) *(COMMON)
  15. __bss_end = .;
  16. }
  17. /* Bootstrap/protected-mode stack: inside the image's RAM footprint
  18. * (NOLOAD, so it costs no file bytes), which means its address travels
  19. * with the kernel instead of being a fixed one that kernel growth has
  20. * to be scheduled around. It must sit *after* __bss_end: the BSS clear
  21. * would otherwise wipe the stack kernel_main is running on. */
  22. .stack (NOLOAD) : {
  23. . = ALIGN(16);
  24. __boot_stack_bottom = .;
  25. . += 0x2000; /* 8 KB */
  26. __boot_stack_top = .;
  27. }
  28. _end = .;
  29. }
  30. /* The legacy stage stages the compressed rootfs at 0x60000 before copying it
  31. * to PACK_HIGH_ADDR; the loaded image (text/rodata/data) must not reach that
  32. * staging area. BSS and the boot stack may extend past it: the stage copy
  33. * happens before the kernel clears BSS and starts using its stack. Keep the
  34. * kernel end below 0x90000 so the top of the staging gap and the EBDA stay
  35. * untouched. */
  36. ASSERT(__bss_start <= 0x60000, "Kernel image too large: legacy pack staging would overwrite it");
  37. ASSERT(_end <= 0x90000, "Kernel too large: would reach the top of the low-memory staging gap");