xref: /xv6-public/kernel.ld (revision 67d4254d)
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	. = 0xF0100000;
12
13	.text : AT(0x100000) {
14		*(.text .stub .text.* .gnu.linkonce.t.*)
15	}
16
17	PROVIDE(etext = .);	/* Define the 'etext' symbol to this value */
18
19	.rodata : {
20		*(.rodata .rodata.* .gnu.linkonce.r.*)
21	}
22
23	/* Include debugging information in kernel memory */
24	.stab : {
25		PROVIDE(__STAB_BEGIN__ = .);
26		*(.stab);
27		PROVIDE(__STAB_END__ = .);
28		BYTE(0)		/* Force the linker to allocate space
29				   for this section */
30	}
31
32	.stabstr : {
33		PROVIDE(__STABSTR_BEGIN__ = .);
34		*(.stabstr);
35		PROVIDE(__STABSTR_END__ = .);
36		BYTE(0)		/* Force the linker to allocate space
37				   for this section */
38	}
39
40	/* Adjust the address for the data segment to the next page */
41	. = ALIGN(0x1000);
42
43	/* The data segment */
44	.data : {
45		*(.data)
46	}
47
48	PROVIDE(edata = .);
49
50	.bss : {
51		*(.bss)
52	}
53
54	PROVIDE(end = .);
55
56	/DISCARD/ : {
57		*(.eh_frame .note.GNU-stack)
58	}
59}
60