source: mainline/kernel/arch/ia32/_link.ld.in@ 482f968

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 482f968 was cfdeedc, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Keep kernel in ELF format

By keeping kernel in an ELF file (instead of converting it to
a flat binary), we can use the information it contains, like
symbol table and debug info.

We can also later implement more advanced functionality, like
loading kernel at multiple discontiguous blocks, or loading
a position-independent kernel at a randomized address.

Currently the functionality is quite restricted, to keep changes
to a minimum. Code in boot/generic/src/kernel.c validates that
the kernel image was built with the same addresses as the boot
loader uses, giving an extra level of sanity checking compared
to a flat binary.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/** IA-32 linker script
2 *
3 * umapped section:
4 * kernel text
5 * kernel data
6 * mapped section:
7 * kernel text
8 * kernel data
9 */
10
11#include <arch/boot/boot.h>
12#include <arch/mm/page.h>
13
14SECTIONS {
15 kernel_load_address = PA2KA(BOOT_OFFSET);
16
17 .unmapped BOOT_OFFSET: AT (0) {
18 unmapped_start = .;
19 *(K_TEXT_START);
20 *(K_DATA_START);
21 unmapped_end = .;
22 }
23
24 .mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)): AT (SIZEOF(.unmapped)) {
25 ktext_start = .;
26 *(.text .text.*);
27 ktext_end = .;
28
29 kdata_start = .;
30 *(.data); /* initialized data */
31 *(.rodata .rodata.*); /* string literals */
32 *(COMMON); /* global variables */
33
34 /* XXX: bss can't be omitted from the ELF image. */
35 *(.bss); /* uninitialized static variables */
36
37 . = ALIGN(8);
38 symbol_table = .;
39 *(symtab.*); /* Symbol table, must be LAST symbol! */
40 kdata_end = .;
41 }
42
43#ifdef CONFIG_LINE_DEBUG
44 .comment 0 : { *(.comment); }
45 .debug_abbrev 0 : { *(.debug_abbrev); }
46 .debug_aranges 0 : { *(.debug_aranges); }
47 .debug_info 0 : { *(.debug_info); }
48 .debug_line 0 : { *(.debug_line); }
49 .debug_loc 0 : { *(.debug_loc); }
50 .debug_pubnames 0 : { *(.debug_pubnames); }
51 .debug_pubtypes 0 : { *(.debug_pubtypes); }
52 .debug_ranges 0 : { *(.debug_ranges); }
53 .debug_str 0 : { *(.debug_str); }
54#endif
55
56 /DISCARD/ : {
57 *(*);
58 }
59
60#ifdef CONFIG_SMP
61
62 ap_boot = unmapped_ap_boot - BOOT_OFFSET + AP_BOOT_OFFSET;
63 ap_gdtr = unmapped_ap_gdtr - BOOT_OFFSET + AP_BOOT_OFFSET;
64 protected_ap_gdtr = PA2KA(ap_gdtr);
65
66#endif /* CONFIG_SMP */
67
68}
Note: See TracBrowser for help on using the repository browser.