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