xref: /xv6-public/kernel.ld (revision f043ac66)
1/* Simple linker script for the JOS kernel.
2   See the GNU ld 'info' manual ("info ld") to learn the syntax. */
3
4OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
5OUTPUT_ARCH(i386)
6ENTRY(_start)
7
8SECTIONS
9{
10	/* Link the kernel at this address: "." means the current address */
11        /* Must be equal to KERNLINK */
12	. = 0x80100000;
13
14	.text : AT(0x100000) {
15		*(.text .stub .text.* .gnu.linkonce.t.*)
16	}
17
18	PROVIDE(etext = .);	/* Define the 'etext' symbol to this value */
19
20	.rodata : {
21		*(.rodata .rodata.* .gnu.linkonce.r.*)
22	}
23
24	/* Include debugging information in kernel memory */
25	.stab : {
26		PROVIDE(__STAB_BEGIN__ = .);
27		*(.stab);
28		PROVIDE(__STAB_END__ = .);
29	}
30
31	.stabstr : {
32		PROVIDE(__STABSTR_BEGIN__ = .);
33		*(.stabstr);
34		PROVIDE(__STABSTR_END__ = .);
35	}
36
37	/* Adjust the address for the data segment to the next page */
38	. = ALIGN(0x1000);
39
40	/* Conventionally, Unix linkers provide pseudo-symbols
41	 * etext, edata, and end, at the end of the text, data, and bss.
42	 * For the kernel mapping, we need the address at the beginning
43	 * of the data section, but that's not one of the conventional
44	 * symbols, because the convention started before there was a
45	 * read-only rodata section between text and data. */
46	PROVIDE(data = .);
47
48	/* The data segment */
49	.data : {
50		*(.data)
51	}
52
53	PROVIDE(edata = .);
54
55	.bss : {
56		*(.bss)
57	}
58
59	PROVIDE(end = .);
60
61	/DISCARD/ : {
62		*(.eh_frame .note.GNU-stack)
63	}
64}
65