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