link.ld 1.6 KB

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