linker.ld 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* The bootloader will look at this image and start execution at the symbol
  2. designated as the entry point. */
  3. ENTRY(_start)
  4. /* Tell where the various sections of the object files will be put in the final
  5. kernel image. */
  6. SECTIONS
  7. {
  8. /* Begin putting sections at 1 MiB, a conventional place for kernels to be
  9. loaded at by the bootloader. */
  10. . = 1M;
  11. /* First put the multiboot header, as it is required to be put very early
  12. early in the image or the bootloader won't recognize the file format.
  13. Next we'll put the .text section. */
  14. .text BLOCK(4K) : ALIGN(4K)
  15. {
  16. *(.multiboot)
  17. *(.text)
  18. }
  19. /* Make sure the GNU notes information is placed after .text. Failure to
  20. to do so may push the GRUB multiboot information beyond the first 8k
  21. and GRUB will not identify this kernel as multiboot capable.
  22. Alternative to this is to compile the final binary with this linker
  23. option to exclude this unqiue header:
  24. -Wl,--build-id=none */
  25. .note.gnu.build-id BLOCK(4K) : ALIGN(4K)
  26. {
  27. *(.note.gnu.build-id)
  28. }
  29. /* Read-only data. */
  30. .rodata BLOCK(4K) : ALIGN(4K)
  31. {
  32. *(.rodata)
  33. }
  34. /* Read-write data (initialized) */
  35. .data BLOCK(4K) : ALIGN(4K)
  36. {
  37. *(.data)
  38. }
  39. /* Read-write data (uninitialized) and stack */
  40. .bss BLOCK(4K) : ALIGN(4K)
  41. {
  42. *(COMMON)
  43. *(.bss)
  44. *(.bootstrap_stack)
  45. }
  46. /* The compiler may produce other sections, by default it will put them in
  47. a segment with the same name. Simply add stuff here as needed. */
  48. }