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