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