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