kernel.ld 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Simple linker script for the ROS kernel.
  2. See the GNU ld 'info' manual ("info ld") to learn the syntax. */
  3. /* This script needs to be invoked with -z max-page-size=0x1000. Otherwise,
  4. * ld will offset our first section to 1MB within the actual file. Multiboot
  5. * requires the header to be in the first two pages. */
  6. OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
  7. ENTRY(_start)
  8. /* start the kernel at 0x110000.
  9. * That way we can use lower ram for critical structures
  10. */
  11. KERN_LOAD_ADDR = 0xfffffffff0000000;
  12. SECTIONS
  13. {
  14. /* Entry Linked and loaded at 0x00100000 (includes multiboot) */
  15. . = 0x00110000;
  16. .bootstrap : {
  17. *(.boottext .bootdata)
  18. }
  19. /* Link the main kernel for the space after entry + KERN_LOAD_ADDR. We'll
  20. * still load it adjacent in physical memory */
  21. . += KERN_LOAD_ADDR;
  22. .text : AT(ADDR(.text) - KERN_LOAD_ADDR) {
  23. *(.text .stub .text.* .gnu.linkonce.t.*)
  24. }
  25. PROVIDE(etext = .); /* Define the 'etext' symbol to this value */
  26. /* Linker-made tables. Our tables (e.g. devtab) are 2^6 aligned,
  27. * independently of us aligning '.'. We align '.' to get the right start,
  28. * e.g. __devtabstart. */
  29. . = ALIGN(64);
  30. /* We shouldn't have to use PROVIDE, but if we don't, we get the wrong
  31. * value for '.'. And items with empty tables get the KLA (basically 0) */
  32. PROVIDE(__devtabstart = .);
  33. PROVIDE(devtab = .);
  34. .devtab : {
  35. *(.devtab)
  36. }
  37. PROVIDE(__devtabend = .);
  38. .rodata : {
  39. *(.rodata .rodata.* .gnu.linkonce.r.*)
  40. }
  41. /* TODO: add some debug info. i hear stabs are 32 bit only, so we'll need
  42. * to bring in some dwarves. for now, hack in the symbols to compile. */
  43. PROVIDE(__STAB_BEGIN__ = .);
  44. PROVIDE(__STAB_END__ = .);
  45. PROVIDE(__STABSTR_BEGIN__ = .);
  46. PROVIDE(__STABSTR_END__ = .);
  47. /* Adjust the address for the data segment to the next page */
  48. . = ALIGN(0x1000);
  49. /* The data segment */
  50. .data : {
  51. *(.data)
  52. }
  53. PROVIDE(edata = .);
  54. .bss : {
  55. *(.bss)
  56. *(COMMON)
  57. }
  58. PROVIDE(end = .);
  59. /DISCARD/ : {
  60. *(.eh_frame .note.GNU-stack)
  61. }
  62. }