xref: /xv6-public/kernel.ld (revision 15997d58)
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	/* Load 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		BYTE(0)		/* Force the linker to allocate space
30				   for this section */
31	}
32
33	.stabstr : {
34		PROVIDE(__STABSTR_BEGIN__ = .);
35		*(.stabstr);
36		PROVIDE(__STABSTR_END__ = .);
37		BYTE(0)		/* Force the linker to allocate space
38				   for this section */
39	}
40
41	/* Adjust the address for the data segment to the next page */
42	. = ALIGN(0x1000);
43
44	/* The data segment */
45	.data : {
46		*(.data)
47	}
48
49	PROVIDE(edata = .);
50
51	.bss : {
52		*(.bss)
53	}
54
55	PROVIDE(end = .);
56
57	/DISCARD/ : {
58		*(.eh_frame .note.GNU-stack)
59	}
60}
61