1/* ----------------------------------------------------------------------- 2 * 3 * Copyright 2008-2009 H. Peter Anvin - All Rights Reserved 4 * Copyright 2009 Intel Corporation; author: H. Peter Anvin 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 9 * Boston MA 02110-1301, USA; either version 2 of the License, or 10 * (at your option) any later version; incorporated herein by reference. 11 * 12 * ----------------------------------------------------------------------- */ 13 14/* 15 * Linker script for the SYSLINUX core 16 */ 17 18OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") 19OUTPUT_ARCH(i386:x86-64) 20EXTERN(_start) 21ENTRY(_start) 22 23STACK32_LEN = 65536; 24 25SECTIONS 26{ 27 /* Prefix structure for the compression program */ 28 . = 0; 29 __module_start = .; 30 .prefix : { 31 *(.prefix) 32 } 33 34 /* "Early" sections (before the load) */ 35 . = 0x1000; 36 37 .earlybss (NOLOAD) : { 38 __earlybss_start = .; 39 *(.earlybss) 40 __earlybss_end = .; 41 } 42 __earlybss_len = ABSOLUTE(__earlybss_end) - ABSOLUTE(__earlybss_start); 43 __earlybss_dwords = (__earlybss_len + 3) >> 2; 44 45 . = ALIGN(4); 46 .bss16 (NOLOAD) : { 47 __bss16_start = .; 48 *(.bss16) 49 __bss16_end = .; 50 } 51 __bss16_len = ABSOLUTE(__bss16_end) - ABSOLUTE(__bss16_start); 52 __bss16_dwords = (__bss16_len + 3) >> 2; 53 54 . = ALIGN(4); 55 .config : AT (__config_lma) { 56 __config_start = .; 57 *(.config) 58 __config_end = .; 59 } 60 __config_len = ABSOLUTE(__config_end) - ABSOLUTE(__config_start); 61 __config_dwords = (__config_len + 3) >> 2; 62 63 /* Generated and/or copied code */ 64 65 . = ALIGN(128); /* Minimum separation from mutable data */ 66 .replacestub : AT (__replacestub_lma) { 67 __replacestub_start = .; 68 *(.replacestub) 69 __replacestub_end = .; 70 } 71 __replacestub_len = ABSOLUTE(__replacestub_end) - ABSOLUTE(__replacestub_start); 72 __replacestub_dwords = (__replacestub_len + 3) >> 2; 73 74 . = ALIGN(16); 75 __gentextnr_lma = .; 76 .gentextnr : AT(__gentextnr_lma) { 77 __gentextnr_start = .; 78 *(.gentextnr) 79 __gentextnr_end = .; 80 } 81 __gentextnr_len = ABSOLUTE(__gentextnr_end) - ABSOLUTE(__gentextnr_start); 82 __gentextnr_dwords = (__gentextnr_len + 3) >> 2; 83 84 . = STACK_BASE; 85 .stack16 : AT(STACK_BASE) { 86 __stack16_start = .; 87 . += STACK_LEN; 88 __stack16_end = .; 89 } 90 __stack16_len = ABSOLUTE(__stack16_end) - ABSOLUTE(__stack16_start); 91 __stack16_dwords = (__stack16_len + 3) >> 2; 92 93 /* Initialized sections */ 94 95 . = 0x7c00; 96 .init : { 97 FILL(0x90909090) 98 __init_start = .; 99 *(.init) 100 __init_end = .; 101 } 102 __init_len = ABSOLUTE(__init_end) - ABSOLUTE(__init_start); 103 __init_dwords = (__init_len + 3) >> 2; 104 105 .text16 : { 106 FILL(0x90909090) 107 __text16_start = .; 108 *(.text16) 109 __text16_end = .; 110 } 111 __text16_len = ABSOLUTE(__text16_end) - ABSOLUTE(__text16_start); 112 __text16_dwords = (__text16_len + 3) >> 2; 113 114 /* 115 * .textnr is used for 32-bit code that is used on the code 116 * path to initialize the .text segment 117 */ 118 . = ALIGN(16); 119 .textnr : { 120 FILL(0x90909090) 121 __textnr_start = .; 122 *(.textnr) 123 __textnr_end = .; 124 } 125 __textnr_len = ABSOLUTE(__textnr_end) - ABSOLUTE(__textnr_start); 126 __textnr_dwords = (__textnr_len + 3) >> 2; 127 128 . = ALIGN(16); 129 __bcopyxx_start = .; 130 131 .bcopyxx.text : { 132 FILL(0x90909090) 133 __bcopyxx_text_start = .; 134 *(.bcopyxx.text) 135 __bcopyxx_text_end = .; 136 } 137 __bcopyxx_text_len = ABSOLUTE(__bcopyxx_text_end) - ABSOLUTE(__bcopyxx_text_start); 138 __bcopyxx_text_dwords = (__bcopyxx_text_len + 3) >> 2; 139 140 .bcopyxx.data : { 141 __bcopyxx_data_start = .; 142 *(.bcopyxx.text) 143 __bcopyxx_data_end = .; 144 } 145 __bcopyxx_data_len = ABSOLUTE(__bcopyxx_data_end) - ABSOLUTE(__bcopyxx_data_start); 146 __bcopyxx_data_dwords = (__bcopyxx_data_len + 3) >> 2; 147 148 __bcopyxx_end = .; 149 __bcopyxx_len = ABSOLUTE(__bcopyxx_end) - ABSOLUTE(__bcopyxx_start); 150 __bcopyxx_dwords = (__bcopyxx_len + 3) >> 2; 151 152 . = ALIGN(4); 153 .data16 : { 154 __data16_start = .; 155 *(.data16) 156 __data16_end = .; 157 } 158 __data16_len = ABSOLUTE(__data16_end) - ABSOLUTE(__data16_start); 159 __data16_dwords = (__data16_len + 3) >> 2; 160 161 . = ALIGN(4); 162 __config_lma = .; 163 . += SIZEOF(.config); 164 165 . = ALIGN(4); 166 __replacestub_lma = .; 167 . += SIZEOF(.replacestub); 168 169 /* The 32-bit code loads above the non-progbits sections */ 170 171 . = ALIGN(16); 172 __pm_code_lma = .; 173 174 __high_clear_start = .; 175 176 . = ALIGN(512); 177 .adv (NOLOAD) : { 178 __adv_start = .; 179 *(.adv) 180 __adv_end = .; 181 } 182 __adv_len = ABSOLUTE(__adv_end) - ABSOLUTE(__adv_start); 183 __adv_dwords = (__adv_len + 3) >> 2; 184 185 /* Late uninitialized sections */ 186 187 . = ALIGN(4); 188 .uibss (NOLOAD) : { 189 __uibss_start = .; 190 *(.uibss) 191 __uibss_end = .; 192 } 193 __uibss_len = ABSOLUTE(__uibss_end) - ABSOLUTE(__uibss_start); 194 __uibss_dwords = (__uibss_len + 3) >> 2; 195 196 _end16 = .; 197 __assert_end16 = ASSERT(_end16 <= 0x10000, "64K overflow"); 198 199 /* 200 * Special 16-bit segments 201 */ 202 203 . = ALIGN(65536); 204 .real_mode (NOLOAD) : { 205 *(.real_mode) 206 } 207 real_mode_seg = core_real_mode >> 4; 208 209 . = ALIGN(65536); 210 .xfer_buf (NOLOAD) : { 211 *(.xfer_buf) 212 } 213 xfer_buf_seg = core_xfer_buf >> 4; 214 215 /* 216 * The auxilliary data segment is used by the 16-bit code 217 * for items that don't need to live in the bottom 64K. 218 */ 219 220 . = ALIGN(16); 221 .auxseg (NOLOAD) : { 222 __auxseg_start = .; 223 *(.auxseg) 224 __auxseg_end = .; 225 } 226 __auxseg_len = ABSOLUTE(__auxseg_end) - ABSOLUTE(__auxseg_start); 227 __auxseg_dwords = (__auxseg_len + 3) >> 2; 228 aux_seg = __auxseg_start >> 4; 229 230 /* 231 * Used to allocate lowmem buffers from 32-bit code 232 */ 233 .lowmem (NOLOAD) : { 234 __lowmem_start = .; 235 *(.lowmem) 236 __lowmem_end = .; 237 } 238 __lowmem_len = ABSOLUTE(__lowmem_end) - ABSOLUTE(__lowmem_start); 239 __lowmem_dwords = (__lowmem_len + 3) >> 2; 240 241 __high_clear_end = .; 242 243 __high_clear_len = ABSOLUTE(__high_clear_end) - ABSOLUTE(__high_clear_start); 244 __high_clear_dwords = (__high_clear_len + 3) >> 2; 245 246 /* Start of the lowmem heap */ 247 . = ALIGN(16); 248 __lowmem_heap = .; 249 250 /* 251 * 32-bit code. This is a hack for the moment due to the 252 * real-mode segments also allocated. 253 */ 254 255 . = 0x100000; 256 257 __pm_code_start = .; 258 259 __text_vma = .; 260 __text_lma = __pm_code_lma; 261 .text : AT(__text_lma) { 262 FILL(0x90909090) 263 __text_start = .; 264 *(.text) 265 *(.text.*) 266 __text_end = .; 267 } 268 269 . = ALIGN(16); 270 271 __rodata_vma = .; 272 __rodata_lma = __rodata_vma + __text_lma - __text_vma; 273 .rodata : AT(__rodata_lma) { 274 __rodata_start = .; 275 *(.rodata) 276 *(.rodata.*) 277 __rodata_end = .; 278 } 279 280 . = ALIGN(4); 281 282 __ctors_vma = .; 283 __ctors_lma = __ctors_vma + __text_lma - __text_vma; 284 .ctors : AT(__ctors_lma) { 285 __ctors_start = .; 286 KEEP (*(SORT(.ctors.*))) 287 KEEP (*(.ctors)) 288 __ctors_end = .; 289 } 290 291 __dtors_vma = .; 292 __dtors_lma = __dtors_vma + __text_lma - __text_vma; 293 .dtors : AT(__dtors_lma) { 294 __dtors_start = .; 295 KEEP (*(SORT(.dtors.*))) 296 KEEP (*(.dtors)) 297 __dtors_end = .; 298 } 299 300 . = ALIGN(4); 301 302 __dynsym_vma = .; 303 __dynsym_lma = __dynsym_vma + __text_lma - __text_vma; 304 .dynsym : AT(__dynsym_lma) { 305 __dynsym_start = .; 306 *(.dynsym) 307 __dynsym_end = .; 308 } 309 __dynsym_len = __dynsym_end - __dynsym_start; 310 311 . = ALIGN(4); 312 313 __dynstr_vma = .; 314 __dynstr_lma = __dynstr_vma + __text_lma - __text_vma; 315 .dynstr : AT(__dynstr_lma) { 316 __dynstr_start = .; 317 *(.dynstr) 318 __dynstr_end = .; 319 } 320 __dynstr_len = __dynstr_end - __dynstr_start; 321 322 . = ALIGN(4); 323 324 __gnu_hash_vma = .; 325 __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma; 326 .gnu.hash : AT(__gnu_hash_lma) { 327 __gnu_hash_start = .; 328 *(.gnu.hash) 329 __gnu_hash_end = .; 330 } 331 332 333 . = ALIGN(4); 334 335 __dynlink_vma = .; 336 __dynlink_lma = __dynlink_vma + __text_lma - __text_vma; 337 .dynlink : AT(__dynlink_lma) { 338 __dynlink_start = .; 339 *(.dynlink) 340 __dynlink_end = .; 341 } 342 343 . = ALIGN(4); 344 345 __got_vma = .; 346 __got_lma = __got_vma + __text_lma - __text_vma; 347 .got : AT(__got_lma) { 348 __got_start = .; 349 KEEP (*(.got.plt)) 350 KEEP (*(.got)) 351 __got_end = .; 352 } 353 354 . = ALIGN(4); 355 356 __dynamic_vma = .; 357 __dynamic_lma = __dynamic_vma + __text_lma - __text_vma; 358 .dynamic : AT(__dynamic_lma) { 359 __dynamic_start = .; 360 *(.dynamic) 361 __dynamic_end = .; 362 } 363 364 . = ALIGN(16); 365 366 __data_vma = .; 367 __data_lma = __data_vma + __text_lma - __text_vma; 368 .data : AT(__data_lma) { 369 __data_start = .; 370 *(.data) 371 *(.data.*) 372 __data_end = .; 373 } 374 375 __pm_code_end = .; 376 __pm_code_len = ABSOLUTE(__pm_code_end) - ABSOLUTE(__pm_code_start); 377 __pm_code_dwords = (__pm_code_len + 3) >> 2; 378 379 . = ALIGN(128); 380 381 __bss_vma = .; 382 __bss_lma = .; /* Dummy */ 383 .bss (NOLOAD) : AT (__bss_lma) { 384 __bss_start = .; 385 *(.bss) 386 *(.bss.*) 387 *(COMMON) 388 __bss_end = .; 389 } 390 __bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start); 391 __bss_dwords = (__bss_len + 3) >> 2; 392 393 /* Very large objects which don't need to be zeroed */ 394 395 __hugebss_vma = .; 396 __hugebss_lma = .; /* Dummy */ 397 .hugebss (NOLOAD) : AT (__hugebss_lma) { 398 __hugebss_start = .; 399 *(.hugebss) 400 *(.hugebss.*) 401 __hugebss_end = .; 402 } 403 __hugebss_len = ABSOLUTE(__hugebss_end) - ABSOLUTE(__hugebss_start); 404 __hugebss_dwords = (__hugebss_len + 3) >> 2; 405 406 407 /* XXX: This stack should be unified with the COM32 stack */ 408 __stack_vma = .; 409 __stack_lma = .; /* Dummy */ 410 .stack (NOLOAD) : AT(__stack_lma) { 411 __stack_start = .; 412 *(.stack) 413 __stack_end = .; 414 } 415 __stack_len = ABSOLUTE(__stack_end) - ABSOLUTE(__stack_start); 416 __stack_dwords = (__stack_len + 3) >> 2; 417 418 _end = .; 419 420 /* COM32R and kernels are loaded after our own PM code */ 421 . = ALIGN(65536); 422 free_high_memory = .; 423 424 /* Stuff we don't need... */ 425 /DISCARD/ : { 426 *(.eh_frame) 427 } 428} 429