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