1/* Huawei Technologies Co.,Ltd. */ 2 3/* 4 Panda linker script for placement of sections above 4GB. 5*/ 6ENTRY(_start) 7SECTIONS { 8 /* 9 According to asan_mapping.h mem range lower ~2G is safe for usage on all platforms. 10 So memory map is set up for data in 0..1G and ELF in 1..2G. 11 12 Typical shadow mapping on Linux/x86_64 with SHADOW_OFFSET == 0x00007fff8000: 13 || `[0x10007fff8000, 0x7fffffffffff]` || HighMem || 14 || `[0x02008fff7000, 0x10007fff7fff]` || HighShadow || 15 || `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap || 16 || `[0x00007fff8000, 0x00008fff6fff]` || LowShadow || 17 || `[0x000000000000, 0x00007fff7fff]` || LowMem || 18 19 When SHADOW_OFFSET is zero (-pie): 20 || `[0x100000000000, 0x7fffffffffff]` || HighMem || 21 || `[0x020000000000, 0x0fffffffffff]` || HighShadow || 22 || `[0x000000040000, 0x01ffffffffff]` || ShadowGap || 23 24 Special case when something is already mapped between 25 0x003000000000 and 0x005000000000 (e.g. when prelink is installed): 26 || `[0x10007fff8000, 0x7fffffffffff]` || HighMem || 27 || `[0x02008fff7000, 0x10007fff7fff]` || HighShadow || 28 || `[0x005000000000, 0x02008fff6fff]` || ShadowGap3 || 29 || `[0x003000000000, 0x004fffffffff]` || MidMem || 30 || `[0x000a7fff8000, 0x002fffffffff]` || ShadowGap2 || 31 || `[0x00067fff8000, 0x000a7fff7fff]` || MidShadow || 32 || `[0x00008fff7000, 0x00067fff7fff]` || ShadowGap || 33 || `[0x00007fff8000, 0x00008fff6fff]` || LowShadow || 34 || `[0x000000000000, 0x00007fff7fff]` || LowMem || 35 36 Default Linux/i386 mapping on x86_64 machine: 37 || `[0x40000000, 0xffffffff]` || HighMem || 38 || `[0x28000000, 0x3fffffff]` || HighShadow || 39 || `[0x24000000, 0x27ffffff]` || ShadowGap || 40 || `[0x20000000, 0x23ffffff]` || LowShadow || 41 || `[0x00000000, 0x1fffffff]` || LowMem || 42 43 Default Linux/i386 mapping on i386 machine 44 (addresses starting with 0xc0000000 are reserved 45 for kernel and thus not sanitized): 46 || `[0x38000000, 0xbfffffff]` || HighMem || 47 || `[0x27000000, 0x37ffffff]` || HighShadow || 48 || `[0x24000000, 0x26ffffff]` || ShadowGap || 49 || `[0x20000000, 0x23ffffff]` || LowShadow || 50 || `[0x00000000, 0x1fffffff]` || LowMem || 51 52 Default Linux/MIPS32 mapping: 53 || `[0x2aaa0000, 0xffffffff]` || HighMem || 54 || `[0x0fff4000, 0x2aa9ffff]` || HighShadow || 55 || `[0x0bff4000, 0x0fff3fff]` || ShadowGap || 56 || `[0x0aaa0000, 0x0bff3fff]` || LowShadow || 57 || `[0x00000000, 0x0aa9ffff]` || LowMem || 58 59 Default Linux/MIPS64 mapping: 60 || `[0x4000000000, 0xffffffffff]` || HighMem || 61 || `[0x2800000000, 0x3fffffffff]` || HighShadow || 62 || `[0x2400000000, 0x27ffffffff]` || ShadowGap || 63 || `[0x2000000000, 0x23ffffffff]` || LowShadow || 64 || `[0x0000000000, 0x1fffffffff]` || LowMem || 65 66 Default Linux/AArch64 (39-bit VMA) mapping: 67 || `[0x2000000000, 0x7fffffffff]` || highmem || 68 || `[0x1400000000, 0x1fffffffff]` || highshadow || 69 || `[0x1200000000, 0x13ffffffff]` || shadowgap || 70 || `[0x1000000000, 0x11ffffffff]` || lowshadow || 71 || `[0x0000000000, 0x0fffffffff]` || lowmem || 72 73 Default Linux/AArch64 (42-bit VMA) mapping: 74 || `[0x10000000000, 0x3ffffffffff]` || highmem || 75 || `[0x0a000000000, 0x0ffffffffff]` || highshadow || 76 || `[0x09000000000, 0x09fffffffff]` || shadowgap || 77 || `[0x08000000000, 0x08fffffffff]` || lowshadow || 78 || `[0x00000000000, 0x07fffffffff]` || lowmem || 79 80 Default Linux/S390 mapping: 81 || `[0x30000000, 0x7fffffff]` || HighMem || 82 || `[0x26000000, 0x2fffffff]` || HighShadow || 83 || `[0x24000000, 0x25ffffff]` || ShadowGap || 84 || `[0x20000000, 0x23ffffff]` || LowShadow || 85 || `[0x00000000, 0x1fffffff]` || LowMem || 86 87 Default Linux/SystemZ mapping: 88 || `[0x14000000000000, 0x1fffffffffffff]` || HighMem || 89 || `[0x12800000000000, 0x13ffffffffffff]` || HighShadow || 90 || `[0x12000000000000, 0x127fffffffffff]` || ShadowGap || 91 || `[0x10000000000000, 0x11ffffffffffff]` || LowShadow || 92 || `[0x00000000000000, 0x0fffffffffffff]` || LowMem || 93 94 Shadow mapping on FreeBSD/x86-64 with SHADOW_OFFSET == 0x400000000000: 95 || `[0x500000000000, 0x7fffffffffff]` || HighMem || 96 || `[0x4a0000000000, 0x4fffffffffff]` || HighShadow || 97 || `[0x480000000000, 0x49ffffffffff]` || ShadowGap || 98 || `[0x400000000000, 0x47ffffffffff]` || LowShadow || 99 || `[0x000000000000, 0x3fffffffffff]` || LowMem || 100 101 Shadow mapping on FreeBSD/i386 with SHADOW_OFFSET == 0x40000000: 102 || `[0x60000000, 0xffffffff]` || HighMem || 103 || `[0x4c000000, 0x5fffffff]` || HighShadow || 104 || `[0x48000000, 0x4bffffff]` || ShadowGap || 105 || `[0x40000000, 0x47ffffff]` || LowShadow || 106 || `[0x00000000, 0x3fffffff]` || LowMem || 107 108 Shadow mapping on NetBSD/x86-64 with SHADOW_OFFSET == 0x400000000000: 109 || `[0x4feffffffe01, 0x7f7ffffff000]` || HighMem || 110 || `[0x49fdffffffc0, 0x4feffffffe00]` || HighShadow || 111 || `[0x480000000000, 0x49fdffffffbf]` || ShadowGap || 112 || `[0x400000000000, 0x47ffffffffff]` || LowShadow || 113 || `[0x000000000000, 0x3fffffffffff]` || LowMem || 114 115 Default Windows/i386 mapping: 116 (the exact location of HighShadow/HighMem may vary depending 117 on WoW64, /LARGEADDRESSAWARE, etc). 118 || `[0x50000000, 0xffffffff]` || HighMem || 119 || `[0x3a000000, 0x4fffffff]` || HighShadow || 120 || `[0x36000000, 0x39ffffff]` || ShadowGap || 121 || `[0x30000000, 0x35ffffff]` || LowShadow || 122 || `[0x00000000, 0x2fffffff]` || LowMem || 123 124 125 NB: this mapping imposes limit on available memory limit in ~1G for Panda VM. 126 */ 127 128 . = 0x40000000 + SIZEOF_HEADERS; 129 130 .interp : { *(.interp) } 131 .note.gnu.build-id : { *(.note.gnu.build-id) } 132 .hash : { *(.hash) } 133 .gnu.hash : { *(.gnu.hash) } 134 .dynsym : { *(.dynsym) } 135 .dynstr : { *(.dynstr) } 136 .gnu.version : { *(.gnu.version) } 137 .gnu.version_d : { *(.gnu.version_d) } 138 .gnu.version_r : { *(.gnu.version_r) } 139 .rela.dyn : 140 { 141 *(.rela.init) 142 *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) 143 *(.rela.fini) 144 *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) 145 *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) 146 *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) 147 *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) 148 *(.rela.ctors) 149 *(.rela.dtors) 150 *(.rela.got) 151 *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) 152 *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) 153 *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) 154 *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) 155 *(.rela.ifunc) 156 } 157 .rela.plt : 158 { 159 *(.rela.plt) 160 PROVIDE_HIDDEN (__rela_iplt_start = .); 161 *(.rela.iplt) 162 PROVIDE_HIDDEN (__rela_iplt_end = .); 163 } 164 .init : 165 { 166 KEEP (*(SORT_NONE(.init))) 167 } 168 .plt : { *(.plt) *(.iplt) } 169.plt.got : { *(.plt.got) } 170.plt.sec : { *(.plt.sec) } 171 .text : 172 { 173 *(.text.unlikely .text.*_unlikely .text.unlikely.*) 174 *(.text.exit .text.exit.*) 175 *(.text.startup .text.startup.*) 176 *(.text.hot .text.hot.*) 177 *(.text .stub .text.* .gnu.linkonce.t.*) 178 /* .gnu.warning sections are handled specially by elf32.em. */ 179 *(.gnu.warning) 180 } 181 .fini : 182 { 183 KEEP (*(SORT_NONE(.fini))) 184 } 185 PROVIDE (__etext = .); 186 PROVIDE (_etext = .); 187 PROVIDE (etext = .); 188 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 189 .rodata1 : { *(.rodata1) } 190 .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } 191 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } 192 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table 193 .gcc_except_table.*) } 194 .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } 195 /* These sections are generated by the Sun/Oracle C++ compiler. */ 196 .exception_ranges : ONLY_IF_RO { *(.exception_ranges 197 .exception_ranges*) } 198 /* Adjust the address for the data segment. We want to adjust up to 199 the same address within the page on the next page up. */ 200 . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); 201 /* Exception handling */ 202 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } 203 .gnu_extab : ONLY_IF_RW { *(.gnu_extab) } 204 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 205 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } 206 /* Thread Local Storage sections */ 207 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } 208 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 209 .preinit_array : 210 { 211 PROVIDE_HIDDEN (__preinit_array_start = .); 212 KEEP (*(.preinit_array)) 213 PROVIDE_HIDDEN (__preinit_array_end = .); 214 } 215 .init_array : 216 { 217 PROVIDE_HIDDEN (__init_array_start = .); 218 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 219 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) 220 PROVIDE_HIDDEN (__init_array_end = .); 221 } 222 .fini_array : 223 { 224 PROVIDE_HIDDEN (__fini_array_start = .); 225 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 226 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) 227 PROVIDE_HIDDEN (__fini_array_end = .); 228 } 229 .ctors : 230 { 231 /* gcc uses crtbegin.o to find the start of 232 the constructors, so we make sure it is 233 first. Because this is a wildcard, it 234 doesn't matter if the user does not 235 actually link against crtbegin.o; the 236 linker won't look for a file to match a 237 wildcard. The wildcard also means that it 238 doesn't matter which directory crtbegin.o 239 is in. */ 240 KEEP (*crtbegin.o(.ctors)) 241 KEEP (*crtbegin?.o(.ctors)) 242 /* We don't want to include the .ctor section from 243 the crtend.o file until after the sorted ctors. 244 The .ctor section from the crtend file contains the 245 end of ctors marker and it must be last */ 246 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 247 KEEP (*(SORT(.ctors.*))) 248 KEEP (*(.ctors)) 249 } 250 .dtors : 251 { 252 KEEP (*crtbegin.o(.dtors)) 253 KEEP (*crtbegin?.o(.dtors)) 254 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 255 KEEP (*(SORT(.dtors.*))) 256 KEEP (*(.dtors)) 257 } 258 .jcr : { KEEP (*(.jcr)) } 259 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) } 260 .dynamic : { *(.dynamic) } 261 .got : { *(.got) *(.igot) } 262 . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .); 263 .got.plt : { *(.got.plt) *(.igot.plt) } 264 .data : 265 { 266 *(.data .data.* .gnu.linkonce.d.*) 267 SORT(CONSTRUCTORS) 268 } 269 .data1 : { *(.data1) } 270 _edata = .; PROVIDE (edata = .); 271 . = .; 272 __bss_start = .; 273 .bss : 274 { 275 *(.dynbss) 276 *(.bss .bss.* .gnu.linkonce.b.*) 277 *(COMMON) 278 /* Align here to ensure that the .bss section occupies space up to 279 _end. Align after .bss to ensure correct alignment even if the 280 .bss section disappears because there are no input sections. 281 FIXME: Why do we need it? When there is no .bss section, we don't 282 pad the .data section. */ 283 . = ALIGN(. != 0 ? 64 / 8 : 1); 284 } 285 .lbss : 286 { 287 *(.dynlbss) 288 *(.lbss .lbss.* .gnu.linkonce.lb.*) 289 *(LARGE_COMMON) 290 } 291 . = ALIGN(64 / 8); 292 . = SEGMENT_START("ldata-segment", .); 293 .lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) : 294 { 295 *(.lrodata .lrodata.* .gnu.linkonce.lr.*) 296 } 297 .ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) : 298 { 299 *(.ldata .ldata.* .gnu.linkonce.l.*) 300 . = ALIGN(. != 0 ? 64 / 8 : 1); 301 } 302 . = ALIGN(64 / 8); 303 _end = .; PROVIDE (end = .); 304 . = DATA_SEGMENT_END (.); 305 /* Stabs debugging sections. */ 306 .stab 0 : { *(.stab) } 307 .stabstr 0 : { *(.stabstr) } 308 .stab.excl 0 : { *(.stab.excl) } 309 .stab.exclstr 0 : { *(.stab.exclstr) } 310 .stab.index 0 : { *(.stab.index) } 311 .stab.indexstr 0 : { *(.stab.indexstr) } 312 .comment 0 : { *(.comment) } 313 /* DWARF debug sections. 314 Symbols in the DWARF debugging sections are relative to the beginning 315 of the section so we begin them at 0. */ 316 /* DWARF 1 */ 317 .debug 0 : { *(.debug) } 318 .line 0 : { *(.line) } 319 /* GNU DWARF 1 extensions */ 320 .debug_srcinfo 0 : { *(.debug_srcinfo) } 321 .debug_sfnames 0 : { *(.debug_sfnames) } 322 /* DWARF 1.1 and DWARF 2 */ 323 .debug_aranges 0 : { *(.debug_aranges) } 324 .debug_pubnames 0 : { *(.debug_pubnames) } 325 /* DWARF 2 */ 326 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 327 .debug_abbrev 0 : { *(.debug_abbrev) } 328 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } 329 .debug_frame 0 : { *(.debug_frame) } 330 .debug_str 0 : { *(.debug_str) } 331 .debug_loc 0 : { *(.debug_loc) } 332 .debug_macinfo 0 : { *(.debug_macinfo) } 333 /* SGI/MIPS DWARF 2 extensions */ 334 .debug_weaknames 0 : { *(.debug_weaknames) } 335 .debug_funcnames 0 : { *(.debug_funcnames) } 336 .debug_typenames 0 : { *(.debug_typenames) } 337 .debug_varnames 0 : { *(.debug_varnames) } 338 /* DWARF 3 */ 339 .debug_pubtypes 0 : { *(.debug_pubtypes) } 340 .debug_ranges 0 : { *(.debug_ranges) } 341 /* DWARF Extension. */ 342 .debug_macro 0 : { *(.debug_macro) } 343 .debug_addr 0 : { *(.debug_addr) } 344 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } 345 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } 346 347} 348