refactor: rewrite kernel's make script
[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
15     .hhk_init_text BLOCK(4K) : {
16         * (.multiboot)
17         arch/*.o (.hhk_init)
18         arch/*.o (.text)
19     }
20
21     .hhk_init_bss BLOCK(4K) : {
22         arch/*.o (.bss)
23     }
24
25     .hhk_init_data BLOCK(4K) : {
26         arch/*.o (.data)
27     }
28
29     .hhk_init_rodata BLOCK(4K) : {
30         arch/*.o (.rodata)
31     }
32     __init_hhk_end = ALIGN(4K);
33
34     /* Relocation of our higher half kernel */
35     . += 0xC0000000;
36
37     /* 好了,我们的内核…… */
38     .text BLOCK(4K) : AT ( ADDR(.text) - 0xC0000000 ) {
39         __kernel_start = .;
40         kernel/*.o (.text)
41         hal/*.o (.text)
42         debug/*.o (.text)
43         libs/*.o (.text)
44     }
45
46     __usrtext_start = ALIGN(4K);
47     .usrtext BLOCK(4K) : AT ( ADDR(.usrtext) - 0xC0000000 ) {
48         * (.usrtext)
49     }
50     __usrtext_end = ALIGN(4K);
51
52     .data BLOCK(4K) : AT ( ADDR(.data) - 0xC0000000 ) {
53         kernel/*.o (.data)
54         hal/*.o (.data)
55         debug/*.o (.data)
56         libs/*.o (.data)
57     }
58
59     .rodata BLOCK(4K) : AT ( ADDR(.rodata) - 0xC0000000 ) {
60         kernel/*.o (.rodata)
61         hal/*.o (.rodata)
62         debug/*.o (.rodata)
63         libs/*.o (.rodata)
64     }
65
66     .kpg BLOCK(4K) : AT ( ADDR(.kpg) - 0xC0000000 ) {
67         arch/*.o (.kpg)
68     }
69
70     .bss BLOCK(4K) : AT ( ADDR(.bss) - 0xC0000000 ) {
71         kernel/*.o (.bss)
72         hal/*.o (.bss)
73         debug/*.o (.bss)
74         libs/*.o (.bss)
75     }
76
77     __kernel_end = ALIGN(4K);
78 }