kernel.ld (1572B)
1 /* Simple linker script for the JOS kernel. 2 See the GNU ld 'info' manual ("info ld") to learn the syntax. */ 3 4 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") 5 OUTPUT_ARCH(i386) 6 ENTRY(_start) 7 8 SECTIONS 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 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 /* Conventionally, Unix linkers provide pseudo-symbols 45 * etext, edata, and end, at the end of the text, data, and bss. 46 * For the kernel mapping, we need the address at the beginning 47 * of the data section, but that's not one of the conventional 48 * symbols, because the convention started before there was a 49 * read-only rodata section between text and data. */ 50 PROVIDE(data = .); 51 52 /* The data segment */ 53 .data : { 54 *(.data) 55 } 56 57 PROVIDE(edata = .); 58 59 .bss : { 60 *(.bss) 61 } 62 63 PROVIDE(end = .); 64 65 /DISCARD/ : { 66 *(.eh_frame .note.GNU-stack) 67 } 68 }