* Make the ksym table built-in with kernel image, thus remove the need
[lunaix-os.git] / lunaix-os / link / linker.ld
index f61e368f19483ee54d69c467bcb9678d9a452819..c3d57dac72cf24b6fdbd9fa7e1f2b8b134be8d3c 100644 (file)
 ENTRY(start_)
 
-/*
-    FUTURE: Use disk reader
-    A bit of messy here.
-    We will pull our higher half kernel out of this shit
-      and load it separately once we have our disk reader.
-*/
-
 SECTIONS {
     . = 0x100000;
+    __kboot_start = .;
 
     /* 这里是我们的高半核初始化代码段和数据段 */
+    .boot.text BLOCK(4K) : 
+    {
+        *(.multiboot)
+        *(.boot.text)
+    }
 
-    .hhk_init_text BLOCK(4K) : {
-        * (.multiboot)
-        build/obj/arch/x86/*.o (.hhk_init)
-        build/obj/arch/x86/*.o (.text)
+    .boot.bss BLOCK(4K) : 
+    {
+        *(.boot.bss)
     }
 
-    .hhk_init_bss BLOCK(4K) : {
-        build/obj/arch/x86/*.o (.bss)
+    .boot.data BLOCK(4K) : 
+    {
+        *(.boot.data)
     }
 
-    .hhk_init_data BLOCK(4K) : {
-        build/obj/arch/x86/*.o (.data)
+    .boot.rodata BLOCK(4K) : 
+    {
+        *(.boot.rodata)
     }
 
-    .hhk_init_rodata BLOCK(4K) : {
-        build/obj/arch/x86/*.o (.rodata)
+    .boot.bss BLOCK(4K) : 
+    {
+        *(.boot.rodata)
     }
-    __init_hhk_end = ALIGN(4K);
+    __kboot_end = ALIGN(4K);
+
+    /* ---- boot end ---- */
+
+    /* ---- kernel start ---- */
 
-    /* Relocation of our higher half kernel */
     . += 0xC0000000;
 
     /* 好了,我们的内核…… */
-    .text BLOCK(4K) : AT ( ADDR(.text) - 0xC0000000 ) {
-        __kernel_start = .;
-        build/obj/kernel/*.o (.text)
-        build/obj/hal/*.o (.text)
+    
+    PROVIDE(__kexec_text_start = ALIGN(4K));
+    
+    .text BLOCK(4K) : AT ( ADDR(.text) - 0xC0000000 ) 
+    {
+        __kexec_start = .;
+        
+        *(.text)
+    }
+
+    .kf.preempt BLOCK(4K) : AT ( ADDR(.kf.preempt) - 0xC0000000 ) 
+    {
+        PROVIDE(__kf_preempt_start = .);
+        
+        KEEP(*(.kf.preempt));
+
+        PROVIDE(__kf_preempt_end = .);
+    }
+
+    PROVIDE(__kexec_text_end = .);
+
+    .data BLOCK(4K) : AT ( ADDR(.data) - 0xC0000000 ) 
+    {
+        *(.data)
+    }
+
+    .rodata BLOCK(4K) : AT ( ADDR(.rodata) - 0xC0000000 ) 
+    {
+        *(.rodata)
+    }
+
+    .kpg BLOCK(4K) : AT ( ADDR(.kpg) - 0xC0000000 ) 
+    {
+        *(.kpg)
     }
 
-    .bss BLOCK(4K) : AT ( ADDR(.bss) - 0xC0000000 ) {
-        build/obj/kernel/*.o (.bss)
-        build/obj/hal/*.o (.bss)
+    . = ALIGN(4K);
+
+    /* for generated array, we align to address line size */
+
+    .lga BLOCK(4K) : AT ( ADDR(.lga) - 0xC0000000 ) 
+    {
+        PROVIDE(__lga_twiplugin_inits_start = .);
+        
+        KEEP(*(.lga.twiplugin_inits));
+
+        PROVIDE(__lga_twiplugin_inits_end = .);
+
+        /* ---- */
+
+        /* align to 8 bytes, so it can cover both 32 and 64 bits address line*/
+        . = ALIGN(8);
+
+        PROVIDE(__lga_devdefs_start = .);
+        
+        KEEP(*(.lga.devdefs));
+
+        PROVIDE(__lga_devdefs_end = .);
+
+        /* ---- */
+
+        . = ALIGN(8);
+
+        PROVIDE(__lga_dev_ld_kboot_start = .);
+        
+        KEEP(*(.lga.devdefs.ld_kboot));
+
+        PROVIDE(__lga_dev_ld_kboot_end = .);
+
+        /* ---- */
+
+        . = ALIGN(8);
+
+        PROVIDE(__lga_dev_ld_sysconf_start = .);
+        
+        KEEP(*(.lga.devdefs.ld_sysconf));
+
+        PROVIDE(__lga_dev_ld_sysconf_end = .);
+
+        /* ---- */
+
+        . = ALIGN(8);
+
+        PROVIDE(__lga_dev_ld_timedev_start = .);
+        
+        KEEP(*(.lga.devdefs.ld_timedev));
+
+        PROVIDE(__lga_dev_ld_timedev_end = .);
+
+        /* ---- */
+
+        . = ALIGN(8);
+
+        PROVIDE(__lga_dev_ld_post_start = .);
+        
+        KEEP(*(.lga.devdefs.ld_post));
+
+        PROVIDE(__lga_dev_ld_post_end = .);
+
+        /* ---- */
+
+        . = ALIGN(8);
+
+        PROVIDE(__lga_fs_start = .);
+        
+        KEEP(*(.lga.fs));
+
+        PROVIDE(__lga_fs_end = .);
+
+        /* ---- */
+
+        . = ALIGN(8);
+
+        PROVIDE(__lga_lunainit_on_earlyboot_start = .);
+        
+        KEEP(*(.lga.lunainit.c_earlyboot));
+
+        PROVIDE(__lga_lunainit_on_earlyboot_end = .);
+
+        /* ---- */
+
+        . = ALIGN(8);
+
+        PROVIDE(__lga_lunainit_on_boot_start = .);
+        
+        KEEP(*(.lga.lunainit.c_boot));
+
+        PROVIDE(__lga_lunainit_on_boot_end = .);
+
+        /* ---- */
+
+        . = ALIGN(8);
+
+        PROVIDE(__lga_lunainit_on_postboot_start = .);
+        
+        KEEP(*(.lga.lunainit.c_postboot));
+
+        PROVIDE(__lga_lunainit_on_postboot_end = .);
+
     }
 
-    .data BLOCK(4k) : AT ( ADDR(.data) - 0xC0000000 ) {
-        build/obj/kernel/*.o (.data)
-        build/obj/hal/*.o (.data)
+    .ksymtable BLOCK(4K) : AT ( ADDR(.ksymtable) - 0xC0000000 )
+    {
+        *(.ksymtable)
     }
 
-    .rodata BLOCK(4K) : AT ( ADDR(.rodata) - 0xC0000000 ) {
-        build/obj/kernel/*.o (.rodata)
-        build/obj/hal/*.o (.rodata)
+    .bss BLOCK(4K) : AT ( ADDR(.bss) - 0xC0000000 ) 
+    {
+        *(.bss)
     }
 
-    .kpg BLOCK(4K) : AT ( ADDR(.kpg) - 0xC0000000 ) {
-        build/obj/arch/x86/*.o (.kpg)
+    .bss.kstack BLOCK(4K) : AT ( ADDR(.bss.kstack) - 0xC0000000)
+    {
+        PROVIDE(__bsskstack_start = .);
+
+        *(.bss.kstack)
+
+        PROVIDE(__bsskstack_end = .);
     }
 
-    __kernel_end = ALIGN(4K);
-    __proc_table = ALIGN(4K);
-    . += 128M;
-    __kernel_heap_start = ALIGN(4K);    /* 内核结束的地方即堆开始的地方 */
+    __kexec_end = ALIGN(4K);
 }
\ No newline at end of file