source: mainline/kernel/arch/amd64/_link.ld.in

Last change on this file was 6677acb, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 19 months ago

Emit .text/.data/.eh_frame sections in kernel ELF files

Gives tools like objdump an easier time interpreting contents of
the file, and allows kernel to find .eh_frame_hdr since the linker
emits a program header for it when it's present under the standard
name.

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[c245372b]1/** AMD64 linker script
[2ddcc7b]2 *
[1141c1a]3 * umapped section:
[2ddcc7b]4 * kernel text
5 * kernel data
[1141c1a]6 * mapped section:
[2ddcc7b]7 * kernel text
8 * kernel data
[1141c1a]9 */
10
[4f1475d4]11#include <arch/boot/boot.h>
12#include <arch/mm/page.h>
13
[1141c1a]14SECTIONS {
[8a1afd2]15 kernel_load_address = PA2KA(BOOT_OFFSET);
16
[15639ec]17 .unmapped (BOOT_OFFSET + SIZEOF_HEADERS): AT (BOOT_OFFSET + SIZEOF_HEADERS) {
[bae43dc]18 unmapped_start = .;
[c89ae25]19 KEEP(*(K_TEXT_START));
20 KEEP(*(K_DATA_START));
21 KEEP(*(K_INI_PTLS));
[bae43dc]22 unmapped_end = .;
[1141c1a]23 }
[f1380b7]24
[6677acb]25 .text (PA2KA(BOOT_OFFSET) + SIZEOF_HEADERS + SIZEOF(.unmapped)) : AT (BOOT_OFFSET + SIZEOF_HEADERS + SIZEOF(.unmapped)) {
[1141c1a]26 ktext_start = .;
[d21e72db]27 *(.text .text.*);
[1141c1a]28 ktext_end = .;
[6677acb]29 }
30
31 /* stack unwinding data */
32 .eh_frame_hdr : {
33 eh_frame_hdr_start = .;
34 *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*);
35 eh_frame_hdr_end = .;
36 }
37 .eh_frame : {
38 eh_frame_start = .;
39 KEEP(*(.eh_frame .eh_frame.*));
40 eh_frame_end = .;
41 }
[f1380b7]42
[6677acb]43 .data : {
[1141c1a]44 kdata_start = .;
[6677acb]45 *(.rodata .rodata.*); /* read-only global variables */
46 *(.data .data.*); /* non-zero initialized global variables */
47
48 /*
49 * When .bss is not physically present in the ELF file (MemSz > FileSz)
50 * the kernel crashes during early boot. Not sure which part of the
51 * boot process is to blame, for now just keep .bss packaged with .data
52 * so that FileSz == MemSz.
53 */
54
55 *(.bss .bss.*); /* uninitialized global variables */
56 *(COMMON); /* non-`static` global variables without an extern declaration */
[1141c1a]57 kdata_end = .;
58 }
[f1380b7]59
[9ded977]60 .comment 0 : { *(.comment); }
61 .debug_abbrev 0 : { *(.debug_abbrev); }
[da13982]62 .debug_abbrev.dwo 0 : { *( .debug_abbrev.dwo); }
63 .debug_addr 0 : { *(.debug_addr); }
[9ded977]64 .debug_aranges 0 : { *(.debug_aranges); }
[da13982]65 .debug_cu_index 0 : { *(.debug_cu_index); }
66 .debug_frame 0 : { *(.debug_frame); }
67 .debug_frame_hdr 0 : { *(.debug_frame_hdr); }
[9ded977]68 .debug_info 0 : { *(.debug_info); }
[da13982]69 .debug_info.dwo 0 : { *(.debug_info.dwo); }
[9ded977]70 .debug_line 0 : { *(.debug_line); }
[da13982]71 .debug_line.dwo 0 : { *(.debug_line.dwo); }
72 .debug_line_str 0 : { *(.debug_line_str); }
[9ded977]73 .debug_loc 0 : { *(.debug_loc); }
[da13982]74 .debug_loclists 0 : { *(.debug_loclists); }
75 .debug_loclists.dwo 0 : { *(.debug_loclists.dwo); }
76 .debug_macinfo 0 : { *(.debug_macinfo); }
77 .debug_macro 0 : { *(.debug_macro); }
78 .debug_macro.dwo 0 : { *(.debug_macro.dwo); }
79 .debug_names 0 : { *(.debug_names); }
[9ded977]80 .debug_pubnames 0 : { *(.debug_pubnames); }
81 .debug_pubtypes 0 : { *(.debug_pubtypes); }
82 .debug_ranges 0 : { *(.debug_ranges); }
[da13982]83 .debug_rnglists 0 : { *(.debug_rnglists); }
[9ded977]84 .debug_str 0 : { *(.debug_str); }
[da13982]85 .debug_str.dwo 0 : { *(.debug_str.dwo); }
86 .debug_str_offsets 0 : { *(.debug_str_offsets); }
87 .debug_str_offsets.dwo 0 : { *(.debug_str_offsets.dwo); }
88 .debug_tu_index 0 : { *(.debug_tu_index); }
89 .debug_types 0 : { *(.debug_types); }
[f1380b7]90
[5b8c75a]91 /DISCARD/ : {
92 *(*);
93 }
[f1380b7]94
[2ddcc7b]95#ifdef CONFIG_SMP
[42edee68]96 ap_boot = unmapped_ap_boot - BOOT_OFFSET + AP_BOOT_OFFSET;
97 ap_gdtr = unmapped_ap_gdtr - BOOT_OFFSET + AP_BOOT_OFFSET;
98 protected_ap_gdtr = PA2KA(ap_gdtr);
99#endif /* CONFIG_SMP */
[f1380b7]100
[1141c1a]101}
Note: See TracBrowser for help on using the repository browser.