refactor: one more step towards arch-agnostic design
[lunaix-os.git] / lunaix-os / link / linker.ld
1 ENTRY(start_)
2
3 /*
4     FUTURE: Use disk reader
5     A bit of messy here.
6     We will pull our higher half kernel out of this shit
7       and load it separately once we have our disk reader.
8 */
9
10 SECTIONS {
11     . = 0x100000;
12
13     /* 这里是我们的高半核初始化代码段和数据段 */
14     .boot.text BLOCK(4K) : {
15         *(.multiboot)
16         *(.boot.text)
17     }
18
19     .boot.bss BLOCK(4K) : {
20         *(.boot.bss)
21     }
22
23     .boot.data BLOCK(4K) : {
24         *(.boot.data)
25     }
26
27     .boot.rodata BLOCK(4K) : {
28         *(.boot.rodata)
29     }
30
31     .boot.bss BLOCK(4K) : {
32         *(.boot.rodata)
33     }
34     __kexec_boot_end = ALIGN(4K);
35
36     /* Relocation of our higher half kernel */
37     . += 0xC0000000;
38
39     /* 好了,我们的内核…… */
40     .text BLOCK(4K) : AT ( ADDR(.text) - 0xC0000000 ) {
41         __kexec_start = .;
42         PROVIDE(__kexec_text_start = .);
43         
44         *(.text)
45
46         PROVIDE(__kexec_text_end = .);
47     }
48
49     .data BLOCK(4K) : AT ( ADDR(.data) - 0xC0000000 ) {
50         *(.data)
51     }
52
53     .rodata BLOCK(4K) : AT ( ADDR(.rodata) - 0xC0000000 ) {
54         *(.rodata)
55     }
56
57     .kpg BLOCK(4K) : AT ( ADDR(.kpg) - 0xC0000000 ) {
58         *(.kpg)
59     }
60
61     . = ALIGN(4K);
62
63     /* for generated array, we align to address line size */
64
65     .lga BLOCK(4K) : AT ( ADDR(.lga) - 0xC0000000 ) {
66         PROVIDE(__lga_twiplugin_inits_start = .);
67         
68         KEEP(*(.lga.twiplugin_inits));
69
70         PROVIDE(__lga_twiplugin_inits_end = .);
71
72         /* ---- */
73
74         PROVIDE(__lga_pci_dev_drivers_start = .);
75         
76         KEEP(*(.lga.pci_dev_drivers));
77
78         PROVIDE(__lga_pci_dev_drivers_end = .);
79     }
80
81     .bss BLOCK(4K) : AT ( ADDR(.bss) - 0xC0000000 ) {
82         *(.bss)
83     }
84
85     __kexec_end = ALIGN(4K);
86 }