link.lds 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. OUTPUT_FORMAT("elf64-x86-64","elf64-x86-64","elf64-x86-64")
  2. OUTPUT_ARCH(i386:x86-64)
  3. ENTRY(_start)
  4. SECTIONS
  5. {
  6. KERNEL_VMA = 0xffff800000000000;
  7. //KERNEL_VMA = 0;
  8. . = 0;
  9. . = 0x100000;
  10. .boot.text :
  11. {
  12. KEEP(*(.multiboot_header))
  13. *(.bootstrap)
  14. *(.bootstrap.code64)
  15. *(.bootstrap.data)
  16. . = ALIGN(4096);
  17. }
  18. . += KERNEL_VMA;
  19. . = ALIGN(32768);
  20. text_start_pa = .;
  21. .text (text_start_pa): AT(text_start_pa - KERNEL_VMA)
  22. {
  23. _text = .;
  24. /* any files' .text */
  25. *(.text)
  26. /* any files' .text.*, for example: rust .text._ZN* */
  27. *(.text.*)
  28. _etext = .;
  29. }
  30. . = ALIGN(32768);
  31. data_start_pa = .;
  32. .data (data_start_pa): AT(data_start_pa - KERNEL_VMA)
  33. {
  34. _data = .;
  35. *(.data)
  36. _edata = .;
  37. }
  38. . = ALIGN(32768);
  39. rodata_start_pa = .;
  40. .rodata (rodata_start_pa): AT(rodata_start_pa - KERNEL_VMA)
  41. {
  42. _rodata = .;
  43. *(.rodata)
  44. *(.rodata.*)
  45. _erodata = .;
  46. }
  47. . = ALIGN(32768);
  48. init_proc_union_start_pa = .;
  49. .data.init_proc_union (init_proc_union_start_pa): AT(init_proc_union_start_pa - KERNEL_VMA)
  50. { *(.data.init_proc_union) }
  51. . = ALIGN(32768);
  52. bss_start_pa = .;
  53. .bss (bss_start_pa): AT(bss_start_pa - KERNEL_VMA)
  54. {
  55. _bss = .;
  56. *(.bss)
  57. *(.bss.*)
  58. _ebss = .;
  59. }
  60. eh_frame = .;
  61. .eh_frame (eh_frame): AT(eh_frame - KERNEL_VMA)
  62. {
  63. __eh_frame_hdr_start = .;
  64. *(.eh_frame_hdr)
  65. __eh_frame_hdr_end = .;
  66. __eh_frame_start = .;
  67. *(.eh_frame)
  68. *(.rela.eh_frame)
  69. __eh_frame_end = .;
  70. }
  71. _end = .;
  72. /DISCARD/ : {
  73. /* *(.eh_frame) */
  74. }
  75. }