1/* Default linker script, for normal executables */ 2/* Copyright (C) 2014-2018 Free Software Foundation, Inc. 3 Copying and distribution of this script, with or without modification, 4 are permitted in any medium without royalty provided the copyright 5 notice and this notice are preserved. */ 6OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", 7 "elf64-x86-64") 8OUTPUT_ARCH(i386:x86-64) 9ENTRY(_start) 10 11PHDRS 12{ 13 phdr PT_PHDR PHDRS; 14 interp PT_INTERP; 15 ro PT_LOAD FILEHDR PHDRS; 16 rw PT_LOAD; 17 dyn PT_DYNAMIC; 18 tls PT_TLS; 19 ehf PT_GNU_EH_FRAME; 20 L4_DEFINE_L4PHDRS 21} 22 23 24SECTIONS 25{ 26 L4_DEFINE_X86_KERNEL_ENTRY_SYMS 27 28 /* No program code/data before _stext/_prog_img_start! */ 29 30 /* Read-only sections, merged into text segment: */ 31 PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS; 32 .interp : { *(.interp) } :ro :interp 33 .note.gnu.build-id : { *(.note.gnu.build-id) } :ro 34 .hash : { *(.hash) } 35 .gnu.hash : { *(.gnu.hash) } 36 .dynsym : { *(.dynsym) } 37 .dynstr : { *(.dynstr) } 38 .gnu.version : { *(.gnu.version) } 39 .gnu.version_d : { *(.gnu.version_d) } 40 .gnu.version_r : { *(.gnu.version_r) } 41 .rel.init : { *(.rel.init) } 42 .rela.init : { *(.rela.init) } 43 .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } 44 .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } 45 .rel.fini : { *(.rel.fini) } 46 .rela.fini : { *(.rela.fini) } 47 .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } 48 .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } 49 .rel.data.rel.ro : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) } 50 .rela.data.rel.ro : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) } 51 .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } 52 .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } 53 .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } 54 .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } 55 .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } 56 .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } 57 .rel.ctors : { *(.rel.ctors) } 58 .rela.ctors : { *(.rela.ctors) } 59 .rel.dtors : { *(.rel.dtors) } 60 .rela.dtors : { *(.rela.dtors) } 61 .rel.got : { *(.rel.got) } 62 .rela.got : { *(.rela.got) } 63 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } 64 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } 65 .rel.ldata : { *(.rel.ldata .rel.ldata.* .rel.gnu.linkonce.l.*) } 66 .rela.ldata : { *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) } 67 .rel.lbss : { *(.rel.lbss .rel.lbss.* .rel.gnu.linkonce.lb.*) } 68 .rela.lbss : { *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) } 69 .rel.lrodata : { *(.rel.lrodata .rel.lrodata.* .rel.gnu.linkonce.lr.*) } 70 .rela.lrodata : { *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) } 71 .rel.plt : { *(.rel.plt) } 72 .rela.plt : { *(.rela.plt) } 73 .init : 74 { 75 KEEP (*(SORT_NONE(.init))) 76 } 77 .plt : { *(.plt) *(.iplt) } 78.plt.got : { *(.plt.got) } 79.plt.sec : { *(.plt.sec) } 80 .text : 81 { 82 _stext = .; 83 _prog_img_start = _stext; 84 *(.text .stub .text.* .gnu.linkonce.t.*) 85 KEEP (*(.text.*personality*)) 86 /* .gnu.warning sections are handled specially by elf32.em. */ 87 *(.gnu.warning) 88 } =0x90909090 89 .fini : 90 { 91 KEEP (*(SORT_NONE(.fini))) 92 } 93 PROVIDE (__etext = .); 94 PROVIDE (_etext = .); 95 PROVIDE (etext = .); 96 .rol4re_elf_aux : { 97 KEEP (*(.rol4re_elf_aux)) 98 } : ro : l4re_aux 99 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } : ro 100 .rodata1 : { *(.rodata1) } 101 .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } :ehf :ro 102 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } :ro 103 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table 104 .gcc_except_table.*) } :ro 105 .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } :ro 106 /* These sections are generated by the Sun/Oracle C++ compiler. */ 107 .exception_ranges : ONLY_IF_RO { *(.exception_ranges 108 .exception_ranges*) } :ro 109 /* Adjust the address for the data segment. We want to adjust up to 110 the same address within the page on the next page up. */ 111 . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); 112 /* Exception handling */ 113 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } :rw 114 .gnu_extab : ONLY_IF_RW { *(.gnu_extab) } :rw 115 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } :rw 116 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } :rw 117 /* Thread Local Storage sections */ 118 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } :rw : tls 119 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 120 .preinit_array : 121 { 122 PROVIDE_HIDDEN (__preinit_array_start = .); 123 KEEP (*(.preinit_array)) 124 PROVIDE_HIDDEN (__preinit_array_end = .); 125 } : rw 126 .init_array : 127 { 128 PROVIDE_HIDDEN (__init_array_start = .); 129 KEEP (*(SORT(.init_array.*))) 130 KEEP (*(.init_array)) 131 PROVIDE_HIDDEN (__init_array_end = .); 132 } 133 .fini_array : 134 { 135 PROVIDE_HIDDEN (__fini_array_start = .); 136 KEEP (*(.fini_array)) 137 KEEP (*(SORT(.fini_array.*))) 138 PROVIDE_HIDDEN (__fini_array_end = .); 139 } 140 .ctors : 141 { 142 /* gcc uses crtbegin.o to find the start of 143 the constructors, so we make sure it is 144 first. Because this is a wildcard, it 145 doesn't matter if the user does not 146 actually link against crtbegin.o; the 147 linker won't look for a file to match a 148 wildcard. The wildcard also means that it 149 doesn't matter which directory crtbegin.o 150 is in. */ 151 KEEP (*crtbegin.o(.ctors)) 152 KEEP (*crtbegin?.o(.ctors)) 153 /* We don't want to include the .ctor section from 154 the crtend.o file until after the sorted ctors. 155 The .ctor section from the crtend file contains the 156 end of ctors marker and it must be last */ 157 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 158 KEEP (*(SORT(.ctors.*))) 159 KEEP (*(.ctors)) 160 } 161 .dtors : 162 { 163 KEEP (*crtbegin.o(.dtors)) 164 KEEP (*crtbegin?.o(.dtors)) 165 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 166 KEEP (*(SORT(.dtors.*))) 167 KEEP (*(.dtors)) 168 } 169 .jcr : { KEEP (*(.jcr)) } 170 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } 171 .dynamic : { *(.dynamic) } :dyn :rw 172 .got : { *(.got) *(.igot) } :rw 173 . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .); 174 .got.plt : { *(.got.plt) *(.igot.plt) } 175 .data : 176 { 177 *(.data .data.* .gnu.linkonce.d.*) 178 KEEP (*(.gnu.linkonce.d.*personality*)) 179 SORT(CONSTRUCTORS) 180 } 181 .data1 : { *(.data1) } 182 _edata = .; PROVIDE (edata = .); 183 __bss_start = .; 184 .bss : 185 { 186 *(.dynbss) 187 *(.bss .bss.* .gnu.linkonce.b.*) 188 *(COMMON) 189 /* Align here to ensure that the .bss section occupies space up to 190 _end. Align after .bss to ensure correct alignment even if the 191 .bss section disappears because there are no input sections. 192 FIXME: Why do we need it? When there is no .bss section, we don't 193 pad the .data section. */ 194 . = ALIGN(. != 0 ? 64 / 8 : 1); 195 } 196 .lbss : 197 { 198 *(.dynlbss) 199 *(.lbss .lbss.* .gnu.linkonce.lb.*) 200 *(LARGE_COMMON) 201 } 202 . = ALIGN(64 / 8); 203 .lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) : 204 { 205 *(.lrodata .lrodata.* .gnu.linkonce.lr.*) 206 } 207 .ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) : 208 { 209 *(.ldata .ldata.* .gnu.linkonce.l.*) 210 . = ALIGN(. != 0 ? 64 / 8 : 1); 211 } 212 . = ALIGN(64 / 8); 213 _end = .; PROVIDE (end = .); 214 . = DATA_SEGMENT_END (.); 215 /* Stabs debugging sections. */ 216 .stab 0 : { *(.stab) } :NONE 217 .stabstr 0 : { *(.stabstr) } 218 .stab.excl 0 : { *(.stab.excl) } 219 .stab.exclstr 0 : { *(.stab.exclstr) } 220 .stab.index 0 : { *(.stab.index) } 221 .stab.indexstr 0 : { *(.stab.indexstr) } 222 .comment 0 : { *(.comment) } 223 /* DWARF debug sections. 224 Symbols in the DWARF debugging sections are relative to the beginning 225 of the section so we begin them at 0. */ 226 /* DWARF 1 */ 227 .debug 0 : { *(.debug) } 228 .line 0 : { *(.line) } 229 /* GNU DWARF 1 extensions */ 230 .debug_srcinfo 0 : { *(.debug_srcinfo) } 231 .debug_sfnames 0 : { *(.debug_sfnames) } 232 /* DWARF 1.1 and DWARF 2 */ 233 .debug_aranges 0 : { *(.debug_aranges) } 234 .debug_pubnames 0 : { *(.debug_pubnames) } 235 /* DWARF 2 */ 236 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 237 .debug_abbrev 0 : { *(.debug_abbrev) } 238 .debug_line 0 : { *(.debug_line) } 239 .debug_frame 0 : { *(.debug_frame) } 240 .debug_str 0 : { *(.debug_str) } 241 .debug_loc 0 : { *(.debug_loc) } 242 .debug_macinfo 0 : { *(.debug_macinfo) } 243 /* SGI/MIPS DWARF 2 extensions */ 244 .debug_weaknames 0 : { *(.debug_weaknames) } 245 .debug_funcnames 0 : { *(.debug_funcnames) } 246 .debug_typenames 0 : { *(.debug_typenames) } 247 .debug_varnames 0 : { *(.debug_varnames) } 248 /* DWARF 3 */ 249 .debug_pubtypes 0 : { *(.debug_pubtypes) } 250 .debug_ranges 0 : { *(.debug_ranges) } 251 /* DWARF Extension. */ 252 .debug_macro 0 : { *(.debug_macro) } 253 .debug_addr 0 : { *(.debug_addr) } 254 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } 255 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) } 256} 257