1/* Script for -pie -z separate-code */ 2/* Copyright (C) 2014-2021 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("elf32-bigarm", "elf32-bigarm", 7 "elf32-littlearm") 8OUTPUT_ARCH(arm) 9ENTRY(_start) 10SEARCH_DIR("=/aarch64-none-linux-gnu/lib"); 11SECTIONS 12{ 13 PROVIDE (__executable_start = SEGMENT_START("text-segment", 0)); . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; 14 .interp : { *(.interp) } 15 .note.gnu.build-id : { *(.note.gnu.build-id) } 16 .hash : { *(.hash) } 17 .gnu.hash : { *(.gnu.hash) } 18 .dynsym : { *(.dynsym) } 19 .dynstr : { *(.dynstr) } 20 .gnu.version : { *(.gnu.version) } 21 .gnu.version_d : { *(.gnu.version_d) } 22 .gnu.version_r : { *(.gnu.version_r) } 23 .rel.init : { *(.rel.init) } 24 .rela.init : { *(.rela.init) } 25 .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } 26 .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } 27 .rel.fini : { *(.rel.fini) } 28 .rela.fini : { *(.rela.fini) } 29 .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } 30 .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } 31 .rel.data.rel.ro : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) } 32 .rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) } 33 .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } 34 .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } 35 .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } 36 .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } 37 .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } 38 .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } 39 .rel.ctors : { *(.rel.ctors) } 40 .rela.ctors : { *(.rela.ctors) } 41 .rel.dtors : { *(.rel.dtors) } 42 .rela.dtors : { *(.rela.dtors) } 43 .rel.got : { *(.rel.got) } 44 .rela.got : { *(.rela.got) } 45 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } 46 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } 47 .rel.iplt : 48 { 49 *(.rel.iplt) 50 } 51 .rela.iplt : 52 { 53 *(.rela.iplt) 54 } 55 .rel.plt : 56 { 57 *(.rel.plt) 58 } 59 .rela.plt : 60 { 61 *(.rela.plt) 62 } 63 . = ALIGN(CONSTANT (MAXPAGESIZE)); 64 .init : 65 { 66 KEEP (*(SORT_NONE(.init))) 67 } 68 .plt : { *(.plt) } 69 .iplt : { *(.iplt) } 70 .text : 71 { 72 *(.text.unlikely .text.*_unlikely .text.unlikely.*) 73 *(.text.exit .text.exit.*) 74 *(.text.startup .text.startup.*) 75 *(.text.hot .text.hot.*) 76 *(SORT(.text.sorted.*)) 77 *(.text .stub .text.* .gnu.linkonce.t.*) 78 /* .gnu.warning sections are handled specially by elf.em. */ 79 *(.gnu.warning) 80 *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) 81 } 82 .fini : 83 { 84 KEEP (*(SORT_NONE(.fini))) 85 } 86 PROVIDE (__etext = .); 87 PROVIDE (_etext = .); 88 PROVIDE (etext = .); 89 . = ALIGN(CONSTANT (MAXPAGESIZE)); 90 /* Adjust the address for the rodata segment. We want to adjust up to 91 the same address within the page on the next page up. */ 92 . = SEGMENT_START("rodata-segment", ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1))); 93 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 94 .rodata1 : { *(.rodata1) } 95 .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } 96 .ARM.exidx : 97 { 98 PROVIDE_HIDDEN (__exidx_start = .); 99 *(.ARM.exidx* .gnu.linkonce.armexidx.*) 100 PROVIDE_HIDDEN (__exidx_end = .); 101 } 102 .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } 103 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } 104 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } 105 .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } 106 /* These sections are generated by the Sun/Oracle C++ compiler. */ 107 .exception_ranges : ONLY_IF_RO { *(.exception_ranges*) } 108 /* Adjust the address for the data segment. We want to adjust up to 109 the same address within the page on the next page up. */ 110 . = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)); 111 /* Exception handling */ 112 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } 113 .gnu_extab : ONLY_IF_RW { *(.gnu_extab) } 114 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 115 .exception_ranges : ONLY_IF_RW { *(.exception_ranges*) } 116 /* Thread Local Storage sections */ 117 .tdata : 118 { 119 PROVIDE_HIDDEN (__tdata_start = .); 120 *(.tdata .tdata.* .gnu.linkonce.td.*) 121 } 122 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 123 .preinit_array : 124 { 125 PROVIDE_HIDDEN (__preinit_array_start = .); 126 KEEP (*(.preinit_array)) 127 PROVIDE_HIDDEN (__preinit_array_end = .); 128 } 129 .init_array : 130 { 131 PROVIDE_HIDDEN (__init_array_start = .); 132 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 133 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) 134 PROVIDE_HIDDEN (__init_array_end = .); 135 } 136 .fini_array : 137 { 138 PROVIDE_HIDDEN (__fini_array_start = .); 139 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 140 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) 141 PROVIDE_HIDDEN (__fini_array_end = .); 142 } 143 .ctors : 144 { 145 /* gcc uses crtbegin.o to find the start of 146 the constructors, so we make sure it is 147 first. Because this is a wildcard, it 148 doesn't matter if the user does not 149 actually link against crtbegin.o; the 150 linker won't look for a file to match a 151 wildcard. The wildcard also means that it 152 doesn't matter which directory crtbegin.o 153 is in. */ 154 KEEP (*crtbegin.o(.ctors)) 155 KEEP (*crtbegin?.o(.ctors)) 156 /* We don't want to include the .ctor section from 157 the crtend.o file until after the sorted ctors. 158 The .ctor section from the crtend file contains the 159 end of ctors marker and it must be last */ 160 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 161 KEEP (*(SORT(.ctors.*))) 162 KEEP (*(.ctors)) 163 } 164 .dtors : 165 { 166 KEEP (*crtbegin.o(.dtors)) 167 KEEP (*crtbegin?.o(.dtors)) 168 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 169 KEEP (*(SORT(.dtors.*))) 170 KEEP (*(.dtors)) 171 } 172 .jcr : { KEEP (*(.jcr)) } 173 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) } 174 .dynamic : { *(.dynamic) } 175 .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } 176 .data : 177 { 178 __data_start = .; 179 *(.data .data.* .gnu.linkonce.d.*) 180 SORT(CONSTRUCTORS) 181 } 182 .data1 : { *(.data1) } 183 _edata = .; PROVIDE (edata = .); 184 /* This section contains data that is initialized during load, 185 but not during the application's initialization sequence. */ 186 .persistent : 187 { 188 . = ALIGN(32 / 8); 189 PROVIDE (__persistent_start = .); 190 *(.persistent .persistent.* .gnu.linkonce.p.*) 191 . = ALIGN(32 / 8); 192 PROVIDE (__persistent_end = .); 193 } 194 . = .; 195 __bss_start = .; 196 __bss_start__ = .; 197 .bss : 198 { 199 *(.dynbss) 200 *(.bss .bss.* .gnu.linkonce.b.*) 201 *(COMMON) 202 /* Align here to ensure that the .bss section occupies space up to 203 _end. Align after .bss to ensure correct alignment even if the 204 .bss section disappears because there are no input sections. 205 FIXME: Why do we need it? When there is no .bss section, we do not 206 pad the .data section. */ 207 . = ALIGN(. != 0 ? 32 / 8 : 1); 208 } 209 _bss_end__ = .; __bss_end__ = .; 210 /* This section contains data that is not initialized during load, 211 or during the application's initialization sequence. */ 212 .noinit (NOLOAD) : 213 { 214 . = ALIGN(32 / 8); 215 PROVIDE (__noinit_start = .); 216 *(.noinit .noinit.* .gnu.linkonce.n.*) 217 . = ALIGN(32 / 8); 218 PROVIDE (__noinit_end = .); 219 } 220 . = ALIGN(32 / 8); 221 . = SEGMENT_START("ldata-segment", .); 222 . = ALIGN(32 / 8); 223 __end__ = .; 224 _end = .; PROVIDE (end = .); 225 .stack 0x80000 : 226 { 227 _stack = .; 228 *(.stack) 229 } 230 /* Stabs debugging sections. */ 231 .stab 0 : { *(.stab) } 232 .stabstr 0 : { *(.stabstr) } 233 .stab.excl 0 : { *(.stab.excl) } 234 .stab.exclstr 0 : { *(.stab.exclstr) } 235 .stab.index 0 : { *(.stab.index) } 236 .stab.indexstr 0 : { *(.stab.indexstr) } 237 .comment 0 : { *(.comment) } 238 .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) } 239 /* DWARF debug sections. 240 Symbols in the DWARF debugging sections are relative to the beginning 241 of the section so we begin them at 0. */ 242 /* DWARF 1. */ 243 .debug 0 : { *(.debug) } 244 .line 0 : { *(.line) } 245 /* GNU DWARF 1 extensions. */ 246 .debug_srcinfo 0 : { *(.debug_srcinfo) } 247 .debug_sfnames 0 : { *(.debug_sfnames) } 248 /* DWARF 1.1 and DWARF 2. */ 249 .debug_aranges 0 : { *(.debug_aranges) } 250 .debug_pubnames 0 : { *(.debug_pubnames) } 251 /* DWARF 2. */ 252 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 253 .debug_abbrev 0 : { *(.debug_abbrev) } 254 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) } 255 .debug_frame 0 : { *(.debug_frame) } 256 .debug_str 0 : { *(.debug_str) } 257 .debug_loc 0 : { *(.debug_loc) } 258 .debug_macinfo 0 : { *(.debug_macinfo) } 259 /* SGI/MIPS DWARF 2 extensions. */ 260 .debug_weaknames 0 : { *(.debug_weaknames) } 261 .debug_funcnames 0 : { *(.debug_funcnames) } 262 .debug_typenames 0 : { *(.debug_typenames) } 263 .debug_varnames 0 : { *(.debug_varnames) } 264 /* DWARF 3. */ 265 .debug_pubtypes 0 : { *(.debug_pubtypes) } 266 .debug_ranges 0 : { *(.debug_ranges) } 267 /* DWARF 5. */ 268 .debug_addr 0 : { *(.debug_addr) } 269 .debug_line_str 0 : { *(.debug_line_str) } 270 .debug_loclists 0 : { *(.debug_loclists) } 271 .debug_macro 0 : { *(.debug_macro) } 272 .debug_names 0 : { *(.debug_names) } 273 .debug_rnglists 0 : { *(.debug_rnglists) } 274 .debug_str_offsets 0 : { *(.debug_str_offsets) } 275 .debug_sup 0 : { *(.debug_sup) } 276 .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) } 277 .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } 278 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } 279} 280