diff options
author | chandramouli narayanan <mouli@linux.intel.com> | 2012-06-25 12:43:03 -0700 |
---|---|---|
committer | chandramouli narayanan <mouli@linux.intel.com> | 2012-06-25 12:43:03 -0700 |
commit | d8eede3f2a360163235fad222a0190cd7c5bef38 (patch) | |
tree | 5e1b28e31fc14c44d8fdfffda00a30aaad2b7b7b | |
parent | b664835d1583be53f34b412b38df53f21f100e24 (diff) | |
download | syslinux-d8eede3f2a360163235fad222a0190cd7c5bef38.tar.gz syslinux-d8eede3f2a360163235fad222a0190cd7c5bef38.tar.xz syslinux-d8eede3f2a360163235fad222a0190cd7c5bef38.zip |
This is a giant patch that splits the linker scripts for libraries, modules and executables into
the architecture-dependent scripts to facilitate building syslinux modules/executables
for i386 and x86_64 environments. The x86_64 linker scripts are derived from the earlier i386
counterparts.
Subdirectories i386 and x86_64 hold the respective linker scripts mentioned below.
com32/lib/sylinux.ld
com32/lib/elf.ld
core/syslinux.ld
efi/syslinux.ld
mbr/mbr.ld
memdisk/memdisk.ld
Remanants of the unused old i386-only files, if any, need to be pruned.
-rw-r--r-- | com32/lib/i386/elf.ld | 184 | ||||
-rw-r--r-- | com32/lib/x86_64/elf.ld | 186 | ||||
-rw-r--r-- | core/i386/syslinux.ld | 428 | ||||
-rw-r--r-- | core/x86_64/syslinux.ld | 428 | ||||
-rw-r--r-- | efi/i386/syslinux.ld | 176 | ||||
-rw-r--r-- | efi/x86_64/syslinux.ld | 176 | ||||
-rw-r--r-- | mbr/i386/mbr.ld | 73 | ||||
-rw-r--r-- | mbr/x86_64/mbr.ld | 72 | ||||
-rw-r--r-- | memdisk/i386/memdisk.ld | 140 | ||||
-rw-r--r-- | memdisk/x86_64/memdisk.ld | 140 |
10 files changed, 2003 insertions, 0 deletions
diff --git a/com32/lib/i386/elf.ld b/com32/lib/i386/elf.ld new file mode 100644 index 00000000..158badbb --- /dev/null +++ b/com32/lib/i386/elf.ld @@ -0,0 +1,184 @@ +/* + * Linker script for ELF dynamic loaded modules. + */ + +/* Script for --shared -z combreloc: shared library, combine & sort relocs */ +OUTPUT_FORMAT("elf32-i386", "elf32-i386", + "elf32-i386") +OUTPUT_ARCH(i386) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0 + SIZEOF_HEADERS; + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : + { + KEEP (*(.init)) + } =0x90909090 + .plt : { *(.plt) } + .text : + { + *(.text .stub .text.* .gnu.linkonce.t.*) + KEEP (*(.text.*personality*)) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0x90909090 + .fini : + { + KEEP (*(.fini)) + } =0x90909090 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + . = ALIGN(4); + .preinit_array : + { + KEEP (*(.preinit_array)) + } + .init_array : + { + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + } + .fini_array : + { + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + } + + .ctors : + { + __ctors_start = .; + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + LONG(0x00000000) + __module_init_ptr = .; + KEEP (*(.ctors_modinit)) + LONG(0x00000000) + __module_main_ptr = .; + KEEP (*(.ctors_modmain)) + LONG(0x00000000) + } + + .dtors : + { + __dtors_start = .; + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + LONG(0x00000000) + __module_exit_ptr = .; + KEEP (*(.dtors_modexit)) + LONG(0x00000000) + } + + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + .got : { *(.got) } + /*. = DATA_SEGMENT_RELRO_END (12, .); -> This gives a "invalid assignment to location counter" error */ + .got.plt : { *(.got.plt) } + .data : + { + *(.data .data.* .gnu.linkonce.d.*) + KEEP (*(.gnu.linkonce.d.*personality*)) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + PROVIDE (edata = .); + PROVIDE (_edata = .); + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + PROVIDE (_end = .); + PROVIDE (end = .); + /*. = DATA_SEGMENT_END (.); -> This gives a "invalid assignment to location counter" error */ + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + /DISCARD/ : { *(.eh_frame) } +} diff --git a/com32/lib/x86_64/elf.ld b/com32/lib/x86_64/elf.ld new file mode 100644 index 00000000..bf9881f1 --- /dev/null +++ b/com32/lib/x86_64/elf.ld @@ -0,0 +1,186 @@ +/* + * Linker script for ELF dynamic loaded modules. + * This simply mirrors the 32bit linker script with minimal x86_64 changes + */ + +/* Script for --shared -z combreloc: shared library, combine & sort relocs */ +OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") +OUTPUT_ARCH(i386:x86-64) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0 + SIZEOF_HEADERS; + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } +/* mouli: introduce alignment for various segments */ + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + } + .rel.plt : { *(.rel.plt); } + .rela.plt : { *(.rela.plt) } + .init : + { + KEEP (*(.init)) + } =0x90909090 + .plt : { *(.plt) } + .text : + { + *(.text .stub .text.* .gnu.linkonce.t.*) + KEEP (*(.text.*personality*)) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0x90909090 + .fini : + { + KEEP (*(.fini)) + } =0x90909090 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + . = ALIGN(4); + .preinit_array : + { + KEEP (*(.preinit_array)) + } + .init_array : + { + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + } + .fini_array : + { + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + } + + .ctors : + { + __ctors_start = .; + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + LONG(0x00000000) + __module_init_ptr = .; + KEEP (*(.ctors_modinit)) + LONG(0x00000000) + __module_main_ptr = .; + KEEP (*(.ctors_modmain)) + LONG(0x00000000) + } + + .dtors : + { + __dtors_start = .; + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + LONG(0x00000000) + __module_exit_ptr = .; + KEEP (*(.dtors_modexit)) + LONG(0x00000000) + } + + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + .got : { *(.got) } + /*. = DATA_SEGMENT_RELRO_END (12, .); -> This gives a "invalid assignment to location counter" error */ + .got.plt : { *(.got.plt) } + .data : + { + *(.data .data.* .gnu.linkonce.d.*) + KEEP (*(.gnu.linkonce.d.*personality*)) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + PROVIDE (edata = .); + PROVIDE (_edata = .); + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + /*. = ALIGN(. != 0 ? 32 / 8 : 1);*/ + . = ALIGN(. != 0 ? 64 / 8 : 1); + } + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + PROVIDE (_end = .); + PROVIDE (end = .); + /*. = DATA_SEGMENT_END (.); -> This gives a "invalid assignment to location counter" error */ + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + /DISCARD/ : { *(.eh_frame) } +} diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld new file mode 100644 index 00000000..7b4e012c --- /dev/null +++ b/core/i386/syslinux.ld @@ -0,0 +1,428 @@ +/* ----------------------------------------------------------------------- + * + * Copyright 2008-2009 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston MA 02110-1301, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * Linker script for the SYSLINUX core + */ + +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") +OUTPUT_ARCH(i386) +EXTERN(_start) +ENTRY(_start) + +STACK32_LEN = 65536; + +SECTIONS +{ + /* Prefix structure for the compression program */ + . = 0; + __module_start = .; + .prefix : { + *(.prefix) + } + + /* "Early" sections (before the load) */ + . = 0x1000; + + .earlybss (NOLOAD) : { + __earlybss_start = .; + *(.earlybss) + __earlybss_end = .; + } + __earlybss_len = ABSOLUTE(__earlybss_end) - ABSOLUTE(__earlybss_start); + __earlybss_dwords = (__earlybss_len + 3) >> 2; + + . = ALIGN(4); + .bss16 (NOLOAD) : { + __bss16_start = .; + *(.bss16) + __bss16_end = .; + } + __bss16_len = ABSOLUTE(__bss16_end) - ABSOLUTE(__bss16_start); + __bss16_dwords = (__bss16_len + 3) >> 2; + + . = ALIGN(4); + .config : AT (__config_lma) { + __config_start = .; + *(.config) + __config_end = .; + } + __config_len = ABSOLUTE(__config_end) - ABSOLUTE(__config_start); + __config_dwords = (__config_len + 3) >> 2; + + /* Generated and/or copied code */ + + . = ALIGN(128); /* Minimum separation from mutable data */ + .replacestub : AT (__replacestub_lma) { + __replacestub_start = .; + *(.replacestub) + __replacestub_end = .; + } + __replacestub_len = ABSOLUTE(__replacestub_end) - ABSOLUTE(__replacestub_start); + __replacestub_dwords = (__replacestub_len + 3) >> 2; + + . = ALIGN(16); + __gentextnr_lma = .; + .gentextnr : AT(__gentextnr_lma) { + __gentextnr_start = .; + *(.gentextnr) + __gentextnr_end = .; + } + __gentextnr_len = ABSOLUTE(__gentextnr_end) - ABSOLUTE(__gentextnr_start); + __gentextnr_dwords = (__gentextnr_len + 3) >> 2; + + . = STACK_BASE; + .stack16 : AT(STACK_BASE) { + __stack16_start = .; + . += STACK_LEN; + __stack16_end = .; + } + __stack16_len = ABSOLUTE(__stack16_end) - ABSOLUTE(__stack16_start); + __stack16_dwords = (__stack16_len + 3) >> 2; + + /* Initialized sections */ + + . = 0x7c00; + .init : { + FILL(0x90909090) + __init_start = .; + *(.init) + __init_end = .; + } + __init_len = ABSOLUTE(__init_end) - ABSOLUTE(__init_start); + __init_dwords = (__init_len + 3) >> 2; + + .text16 : { + FILL(0x90909090) + __text16_start = .; + *(.text16) + __text16_end = .; + } + __text16_len = ABSOLUTE(__text16_end) - ABSOLUTE(__text16_start); + __text16_dwords = (__text16_len + 3) >> 2; + + /* + * .textnr is used for 32-bit code that is used on the code + * path to initialize the .text segment + */ + . = ALIGN(16); + .textnr : { + FILL(0x90909090) + __textnr_start = .; + *(.textnr) + __textnr_end = .; + } + __textnr_len = ABSOLUTE(__textnr_end) - ABSOLUTE(__textnr_start); + __textnr_dwords = (__textnr_len + 3) >> 2; + + . = ALIGN(16); + __bcopyxx_start = .; + + .bcopyxx.text : { + FILL(0x90909090) + __bcopyxx_text_start = .; + *(.bcopyxx.text) + __bcopyxx_text_end = .; + } + __bcopyxx_text_len = ABSOLUTE(__bcopyxx_text_end) - ABSOLUTE(__bcopyxx_text_start); + __bcopyxx_text_dwords = (__bcopyxx_text_len + 3) >> 2; + + .bcopyxx.data : { + __bcopyxx_data_start = .; + *(.bcopyxx.text) + __bcopyxx_data_end = .; + } + __bcopyxx_data_len = ABSOLUTE(__bcopyxx_data_end) - ABSOLUTE(__bcopyxx_data_start); + __bcopyxx_data_dwords = (__bcopyxx_data_len + 3) >> 2; + + __bcopyxx_end = .; + __bcopyxx_len = ABSOLUTE(__bcopyxx_end) - ABSOLUTE(__bcopyxx_start); + __bcopyxx_dwords = (__bcopyxx_len + 3) >> 2; + + . = ALIGN(4); + .data16 : { + __data16_start = .; + *(.data16) + __data16_end = .; + } + __data16_len = ABSOLUTE(__data16_end) - ABSOLUTE(__data16_start); + __data16_dwords = (__data16_len + 3) >> 2; + + . = ALIGN(4); + __config_lma = .; + . += SIZEOF(.config); + + . = ALIGN(4); + __replacestub_lma = .; + . += SIZEOF(.replacestub); + + /* The 32-bit code loads above the non-progbits sections */ + + . = ALIGN(16); + __pm_code_lma = .; + + __high_clear_start = .; + + . = ALIGN(512); + .adv (NOLOAD) : { + __adv_start = .; + *(.adv) + __adv_end = .; + } + __adv_len = ABSOLUTE(__adv_end) - ABSOLUTE(__adv_start); + __adv_dwords = (__adv_len + 3) >> 2; + + /* Late uninitialized sections */ + + . = ALIGN(4); + .uibss (NOLOAD) : { + __uibss_start = .; + *(.uibss) + __uibss_end = .; + } + __uibss_len = ABSOLUTE(__uibss_end) - ABSOLUTE(__uibss_start); + __uibss_dwords = (__uibss_len + 3) >> 2; + + _end16 = .; + __assert_end16 = ASSERT(_end16 <= 0x10000, "64K overflow"); + + /* + * Special 16-bit segments + */ + + . = ALIGN(65536); + .real_mode (NOLOAD) : { + *(.real_mode) + } + real_mode_seg = core_real_mode >> 4; + + . = ALIGN(65536); + .xfer_buf (NOLOAD) : { + *(.xfer_buf) + } + xfer_buf_seg = core_xfer_buf >> 4; + + /* + * The auxilliary data segment is used by the 16-bit code + * for items that don't need to live in the bottom 64K. + */ + + . = ALIGN(16); + .auxseg (NOLOAD) : { + __auxseg_start = .; + *(.auxseg) + __auxseg_end = .; + } + __auxseg_len = ABSOLUTE(__auxseg_end) - ABSOLUTE(__auxseg_start); + __auxseg_dwords = (__auxseg_len + 3) >> 2; + aux_seg = __auxseg_start >> 4; + + /* + * Used to allocate lowmem buffers from 32-bit code + */ + .lowmem (NOLOAD) : { + __lowmem_start = .; + *(.lowmem) + __lowmem_end = .; + } + __lowmem_len = ABSOLUTE(__lowmem_end) - ABSOLUTE(__lowmem_start); + __lowmem_dwords = (__lowmem_len + 3) >> 2; + + __high_clear_end = .; + + __high_clear_len = ABSOLUTE(__high_clear_end) - ABSOLUTE(__high_clear_start); + __high_clear_dwords = (__high_clear_len + 3) >> 2; + + /* Start of the lowmem heap */ + . = ALIGN(16); + __lowmem_heap = .; + + /* + * 32-bit code. This is a hack for the moment due to the + * real-mode segments also allocated. + */ + + . = 0x100000; + + __pm_code_start = .; + + __text_vma = .; + __text_lma = __pm_code_lma; + .text : AT(__text_lma) { + FILL(0x90909090) + __text_start = .; + *(.text) + *(.text.*) + __text_end = .; + } + + . = ALIGN(16); + + __rodata_vma = .; + __rodata_lma = __rodata_vma + __text_lma - __text_vma; + .rodata : AT(__rodata_lma) { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + __rodata_end = .; + } + + . = ALIGN(4); + + __ctors_vma = .; + __ctors_lma = __ctors_vma + __text_lma - __text_vma; + .ctors : AT(__ctors_lma) { + __ctors_start = .; + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __ctors_end = .; + } + + __dtors_vma = .; + __dtors_lma = __dtors_vma + __text_lma - __text_vma; + .dtors : AT(__dtors_lma) { + __dtors_start = .; + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __dtors_end = .; + } + + . = ALIGN(4); + + __dynsym_vma = .; + __dynsym_lma = __dynsym_vma + __text_lma - __text_vma; + .dynsym : AT(__dynsym_lma) { + __dynsym_start = .; + *(.dynsym) + __dynsym_end = .; + } + __dynsym_len = __dynsym_end - __dynsym_start; + + . = ALIGN(4); + + __dynstr_vma = .; + __dynstr_lma = __dynstr_vma + __text_lma - __text_vma; + .dynstr : AT(__dynstr_lma) { + __dynstr_start = .; + *(.dynstr) + __dynstr_end = .; + } + __dynstr_len = __dynstr_end - __dynstr_start; + + . = ALIGN(4); + + __gnu_hash_vma = .; + __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma; + .gnu.hash : AT(__gnu_hash_lma) { + __gnu_hash_start = .; + *(.gnu.hash) + __gnu_hash_end = .; + } + + + . = ALIGN(4); + + __dynlink_vma = .; + __dynlink_lma = __dynlink_vma + __text_lma - __text_vma; + .dynlink : AT(__dynlink_lma) { + __dynlink_start = .; + *(.dynlink) + __dynlink_end = .; + } + + . = ALIGN(4); + + __got_vma = .; + __got_lma = __got_vma + __text_lma - __text_vma; + .got : AT(__got_lma) { + __got_start = .; + KEEP (*(.got.plt)) + KEEP (*(.got)) + __got_end = .; + } + + . = ALIGN(4); + + __dynamic_vma = .; + __dynamic_lma = __dynamic_vma + __text_lma - __text_vma; + .dynamic : AT(__dynamic_lma) { + __dynamic_start = .; + *(.dynamic) + __dynamic_end = .; + } + + . = ALIGN(16); + + __data_vma = .; + __data_lma = __data_vma + __text_lma - __text_vma; + .data : AT(__data_lma) { + __data_start = .; + *(.data) + *(.data.*) + __data_end = .; + } + + __pm_code_end = .; + __pm_code_len = ABSOLUTE(__pm_code_end) - ABSOLUTE(__pm_code_start); + __pm_code_dwords = (__pm_code_len + 3) >> 2; + + . = ALIGN(128); + + __bss_vma = .; + __bss_lma = .; /* Dummy */ + .bss (NOLOAD) : AT (__bss_lma) { + __bss_start = .; + *(.bss) + *(.bss.*) + *(COMMON) + __bss_end = .; + } + __bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start); + __bss_dwords = (__bss_len + 3) >> 2; + + /* Very large objects which don't need to be zeroed */ + + __hugebss_vma = .; + __hugebss_lma = .; /* Dummy */ + .hugebss (NOLOAD) : AT (__hugebss_lma) { + __hugebss_start = .; + *(.hugebss) + *(.hugebss.*) + __hugebss_end = .; + } + __hugebss_len = ABSOLUTE(__hugebss_end) - ABSOLUTE(__hugebss_start); + __hugebss_dwords = (__hugebss_len + 3) >> 2; + + + /* XXX: This stack should be unified with the COM32 stack */ + __stack_vma = .; + __stack_lma = .; /* Dummy */ + .stack (NOLOAD) : AT(__stack_lma) { + __stack_start = .; + *(.stack) + __stack_end = .; + } + __stack_len = ABSOLUTE(__stack_end) - ABSOLUTE(__stack_start); + __stack_dwords = (__stack_len + 3) >> 2; + + _end = .; + + /* COM32R and kernels are loaded after our own PM code */ + . = ALIGN(65536); + free_high_memory = .; + + /* Stuff we don't need... */ + /DISCARD/ : { + *(.eh_frame) + } +} diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld new file mode 100644 index 00000000..10571120 --- /dev/null +++ b/core/x86_64/syslinux.ld @@ -0,0 +1,428 @@ +/* ----------------------------------------------------------------------- + * + * Copyright 2008-2009 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston MA 02110-1301, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * Linker script for the SYSLINUX core + */ + +OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") +OUTPUT_ARCH(i386:x86-64) +EXTERN(_start) +ENTRY(_start) + +STACK32_LEN = 65536; + +SECTIONS +{ + /* Prefix structure for the compression program */ + . = 0; + __module_start = .; + .prefix : { + *(.prefix) + } + + /* "Early" sections (before the load) */ + . = 0x1000; + + .earlybss (NOLOAD) : { + __earlybss_start = .; + *(.earlybss) + __earlybss_end = .; + } + __earlybss_len = ABSOLUTE(__earlybss_end) - ABSOLUTE(__earlybss_start); + __earlybss_dwords = (__earlybss_len + 3) >> 2; + + . = ALIGN(4); + .bss16 (NOLOAD) : { + __bss16_start = .; + *(.bss16) + __bss16_end = .; + } + __bss16_len = ABSOLUTE(__bss16_end) - ABSOLUTE(__bss16_start); + __bss16_dwords = (__bss16_len + 3) >> 2; + + . = ALIGN(4); + .config : AT (__config_lma) { + __config_start = .; + *(.config) + __config_end = .; + } + __config_len = ABSOLUTE(__config_end) - ABSOLUTE(__config_start); + __config_dwords = (__config_len + 3) >> 2; + + /* Generated and/or copied code */ + + . = ALIGN(128); /* Minimum separation from mutable data */ + .replacestub : AT (__replacestub_lma) { + __replacestub_start = .; + *(.replacestub) + __replacestub_end = .; + } + __replacestub_len = ABSOLUTE(__replacestub_end) - ABSOLUTE(__replacestub_start); + __replacestub_dwords = (__replacestub_len + 3) >> 2; + + . = ALIGN(16); + __gentextnr_lma = .; + .gentextnr : AT(__gentextnr_lma) { + __gentextnr_start = .; + *(.gentextnr) + __gentextnr_end = .; + } + __gentextnr_len = ABSOLUTE(__gentextnr_end) - ABSOLUTE(__gentextnr_start); + __gentextnr_dwords = (__gentextnr_len + 3) >> 2; + + . = STACK_BASE; + .stack16 : AT(STACK_BASE) { + __stack16_start = .; + . += STACK_LEN; + __stack16_end = .; + } + __stack16_len = ABSOLUTE(__stack16_end) - ABSOLUTE(__stack16_start); + __stack16_dwords = (__stack16_len + 3) >> 2; + + /* Initialized sections */ + + . = 0x7c00; + .init : { + FILL(0x90909090) + __init_start = .; + *(.init) + __init_end = .; + } + __init_len = ABSOLUTE(__init_end) - ABSOLUTE(__init_start); + __init_dwords = (__init_len + 3) >> 2; + + .text16 : { + FILL(0x90909090) + __text16_start = .; + *(.text16) + __text16_end = .; + } + __text16_len = ABSOLUTE(__text16_end) - ABSOLUTE(__text16_start); + __text16_dwords = (__text16_len + 3) >> 2; + + /* + * .textnr is used for 32-bit code that is used on the code + * path to initialize the .text segment + */ + . = ALIGN(16); + .textnr : { + FILL(0x90909090) + __textnr_start = .; + *(.textnr) + __textnr_end = .; + } + __textnr_len = ABSOLUTE(__textnr_end) - ABSOLUTE(__textnr_start); + __textnr_dwords = (__textnr_len + 3) >> 2; + + . = ALIGN(16); + __bcopyxx_start = .; + + .bcopyxx.text : { + FILL(0x90909090) + __bcopyxx_text_start = .; + *(.bcopyxx.text) + __bcopyxx_text_end = .; + } + __bcopyxx_text_len = ABSOLUTE(__bcopyxx_text_end) - ABSOLUTE(__bcopyxx_text_start); + __bcopyxx_text_dwords = (__bcopyxx_text_len + 3) >> 2; + + .bcopyxx.data : { + __bcopyxx_data_start = .; + *(.bcopyxx.text) + __bcopyxx_data_end = .; + } + __bcopyxx_data_len = ABSOLUTE(__bcopyxx_data_end) - ABSOLUTE(__bcopyxx_data_start); + __bcopyxx_data_dwords = (__bcopyxx_data_len + 3) >> 2; + + __bcopyxx_end = .; + __bcopyxx_len = ABSOLUTE(__bcopyxx_end) - ABSOLUTE(__bcopyxx_start); + __bcopyxx_dwords = (__bcopyxx_len + 3) >> 2; + + . = ALIGN(4); + .data16 : { + __data16_start = .; + *(.data16) + __data16_end = .; + } + __data16_len = ABSOLUTE(__data16_end) - ABSOLUTE(__data16_start); + __data16_dwords = (__data16_len + 3) >> 2; + + . = ALIGN(4); + __config_lma = .; + . += SIZEOF(.config); + + . = ALIGN(4); + __replacestub_lma = .; + . += SIZEOF(.replacestub); + + /* The 32-bit code loads above the non-progbits sections */ + + . = ALIGN(16); + __pm_code_lma = .; + + __high_clear_start = .; + + . = ALIGN(512); + .adv (NOLOAD) : { + __adv_start = .; + *(.adv) + __adv_end = .; + } + __adv_len = ABSOLUTE(__adv_end) - ABSOLUTE(__adv_start); + __adv_dwords = (__adv_len + 3) >> 2; + + /* Late uninitialized sections */ + + . = ALIGN(4); + .uibss (NOLOAD) : { + __uibss_start = .; + *(.uibss) + __uibss_end = .; + } + __uibss_len = ABSOLUTE(__uibss_end) - ABSOLUTE(__uibss_start); + __uibss_dwords = (__uibss_len + 3) >> 2; + + _end16 = .; + __assert_end16 = ASSERT(_end16 <= 0x10000, "64K overflow"); + + /* + * Special 16-bit segments + */ + + . = ALIGN(65536); + .real_mode (NOLOAD) : { + *(.real_mode) + } + real_mode_seg = core_real_mode >> 4; + + . = ALIGN(65536); + .xfer_buf (NOLOAD) : { + *(.xfer_buf) + } + xfer_buf_seg = core_xfer_buf >> 4; + + /* + * The auxilliary data segment is used by the 16-bit code + * for items that don't need to live in the bottom 64K. + */ + + . = ALIGN(16); + .auxseg (NOLOAD) : { + __auxseg_start = .; + *(.auxseg) + __auxseg_end = .; + } + __auxseg_len = ABSOLUTE(__auxseg_end) - ABSOLUTE(__auxseg_start); + __auxseg_dwords = (__auxseg_len + 3) >> 2; + aux_seg = __auxseg_start >> 4; + + /* + * Used to allocate lowmem buffers from 32-bit code + */ + .lowmem (NOLOAD) : { + __lowmem_start = .; + *(.lowmem) + __lowmem_end = .; + } + __lowmem_len = ABSOLUTE(__lowmem_end) - ABSOLUTE(__lowmem_start); + __lowmem_dwords = (__lowmem_len + 3) >> 2; + + __high_clear_end = .; + + __high_clear_len = ABSOLUTE(__high_clear_end) - ABSOLUTE(__high_clear_start); + __high_clear_dwords = (__high_clear_len + 3) >> 2; + + /* Start of the lowmem heap */ + . = ALIGN(16); + __lowmem_heap = .; + + /* + * 32-bit code. This is a hack for the moment due to the + * real-mode segments also allocated. + */ + + . = 0x100000; + + __pm_code_start = .; + + __text_vma = .; + __text_lma = __pm_code_lma; + .text : AT(__text_lma) { + FILL(0x90909090) + __text_start = .; + *(.text) + *(.text.*) + __text_end = .; + } + + . = ALIGN(16); + + __rodata_vma = .; + __rodata_lma = __rodata_vma + __text_lma - __text_vma; + .rodata : AT(__rodata_lma) { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + __rodata_end = .; + } + + . = ALIGN(4); + + __ctors_vma = .; + __ctors_lma = __ctors_vma + __text_lma - __text_vma; + .ctors : AT(__ctors_lma) { + __ctors_start = .; + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __ctors_end = .; + } + + __dtors_vma = .; + __dtors_lma = __dtors_vma + __text_lma - __text_vma; + .dtors : AT(__dtors_lma) { + __dtors_start = .; + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __dtors_end = .; + } + + . = ALIGN(4); + + __dynsym_vma = .; + __dynsym_lma = __dynsym_vma + __text_lma - __text_vma; + .dynsym : AT(__dynsym_lma) { + __dynsym_start = .; + *(.dynsym) + __dynsym_end = .; + } + __dynsym_len = __dynsym_end - __dynsym_start; + + . = ALIGN(4); + + __dynstr_vma = .; + __dynstr_lma = __dynstr_vma + __text_lma - __text_vma; + .dynstr : AT(__dynstr_lma) { + __dynstr_start = .; + *(.dynstr) + __dynstr_end = .; + } + __dynstr_len = __dynstr_end - __dynstr_start; + + . = ALIGN(4); + + __gnu_hash_vma = .; + __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma; + .gnu.hash : AT(__gnu_hash_lma) { + __gnu_hash_start = .; + *(.gnu.hash) + __gnu_hash_end = .; + } + + + . = ALIGN(4); + + __dynlink_vma = .; + __dynlink_lma = __dynlink_vma + __text_lma - __text_vma; + .dynlink : AT(__dynlink_lma) { + __dynlink_start = .; + *(.dynlink) + __dynlink_end = .; + } + + . = ALIGN(4); + + __got_vma = .; + __got_lma = __got_vma + __text_lma - __text_vma; + .got : AT(__got_lma) { + __got_start = .; + KEEP (*(.got.plt)) + KEEP (*(.got)) + __got_end = .; + } + + . = ALIGN(4); + + __dynamic_vma = .; + __dynamic_lma = __dynamic_vma + __text_lma - __text_vma; + .dynamic : AT(__dynamic_lma) { + __dynamic_start = .; + *(.dynamic) + __dynamic_end = .; + } + + . = ALIGN(16); + + __data_vma = .; + __data_lma = __data_vma + __text_lma - __text_vma; + .data : AT(__data_lma) { + __data_start = .; + *(.data) + *(.data.*) + __data_end = .; + } + + __pm_code_end = .; + __pm_code_len = ABSOLUTE(__pm_code_end) - ABSOLUTE(__pm_code_start); + __pm_code_dwords = (__pm_code_len + 3) >> 2; + + . = ALIGN(128); + + __bss_vma = .; + __bss_lma = .; /* Dummy */ + .bss (NOLOAD) : AT (__bss_lma) { + __bss_start = .; + *(.bss) + *(.bss.*) + *(COMMON) + __bss_end = .; + } + __bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start); + __bss_dwords = (__bss_len + 3) >> 2; + + /* Very large objects which don't need to be zeroed */ + + __hugebss_vma = .; + __hugebss_lma = .; /* Dummy */ + .hugebss (NOLOAD) : AT (__hugebss_lma) { + __hugebss_start = .; + *(.hugebss) + *(.hugebss.*) + __hugebss_end = .; + } + __hugebss_len = ABSOLUTE(__hugebss_end) - ABSOLUTE(__hugebss_start); + __hugebss_dwords = (__hugebss_len + 3) >> 2; + + + /* XXX: This stack should be unified with the COM32 stack */ + __stack_vma = .; + __stack_lma = .; /* Dummy */ + .stack (NOLOAD) : AT(__stack_lma) { + __stack_start = .; + *(.stack) + __stack_end = .; + } + __stack_len = ABSOLUTE(__stack_end) - ABSOLUTE(__stack_start); + __stack_dwords = (__stack_len + 3) >> 2; + + _end = .; + + /* COM32R and kernels are loaded after our own PM code */ + . = ALIGN(65536); + free_high_memory = .; + + /* Stuff we don't need... */ + /DISCARD/ : { + *(.eh_frame) + } +} diff --git a/efi/i386/syslinux.ld b/efi/i386/syslinux.ld new file mode 100644 index 00000000..e0270537 --- /dev/null +++ b/efi/i386/syslinux.ld @@ -0,0 +1,176 @@ +/* ----------------------------------------------------------------------- + * + * Copyright 2008-2009 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston MA 02110-1301, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * Linker script for the SYSLINUX core + */ + +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_start) + +SECTIONS +{ + . = 0; + ImageBase = .; /* For gnu-efi's crt0 */ + __module_start = .; + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + .text : { + FILL(0x90909090) + __text_start = .; + *(.text) + *(.text.*) + __text_end = .; + } + + . = ALIGN(16); + + .rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + __rodata_end = .; + } + + . = ALIGN(4); + + .ctors : { + __ctors_start = .; + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __ctors_end = .; + } + + .dtors : { + __dtors_start = .; + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __dtors_end = .; + } + + . = ALIGN(4096); + .rel : { + *(.rel.got) + *(.rel.data) + *(.rel.data.*) + *(.rel.ctors) + } + + . = ALIGN(4); + + .gnu.hash : { + __gnu_hash_start = .; + *(.gnu.hash) + __gnu_hash_end = .; + } + + + .dynsym : { + __dynsym_start = .; + *(.dynsym) + __dynsym_end = .; + } + + . = ALIGN(4); + + .dynstr : { + __dynstr_start = .; + *(.dynstr) + __dynstr_end = .; + } + + . = ALIGN(4); + + .dynlink : { + __dynlink_start = .; + *(.dynlink) + __dynlink_end = .; + } + + . = ALIGN(4); + + .got : { + __got_start = .; + KEEP (*(.got.plt)) + KEEP (*(.got)) + __got_end = .; + } + + . = ALIGN(4); + + .dynamic : { + __dynamic_start = .; + *(.dynamic) + __dynamic_end = .; + } + + . = ALIGN(16); + + .data : { + __data_start = .; + *(.data) + *(.data.*) + *(.lowmem) + __data_end = .; + } + + .reloc : { + *(.reloc) + } + + .comment : { + *(.commet) + } + + .symtab : { + *(.symtab) + } + + .strtab : { + *(.strtab) + } + + .bss : { + /* the EFI loader doesn't seem to like a .bss section, + so we stick it all into .data: */ + __bss_start = .; + *(.bss) + *(.bss.*) + *(.bss16) + *(.hugebss) + *(COMMON) + __bss_end = .; + *(.sbss) + *(.scommon) + } + __bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start); + __bss_dwords = (__bss_len + 3) >> 2; + + . = ALIGN(128); + + /* Very large objects which don't need to be zeroed */ + + .hugebss : { + __hugebss_start = .; + *(.hugebss) + *(.hugebss.*) + __hugebss_end = .; + } + + _end = .; + + /* Stuff we don't need... */ + /DISCARD/ : { + *(.eh_frame) + } +} diff --git a/efi/x86_64/syslinux.ld b/efi/x86_64/syslinux.ld new file mode 100644 index 00000000..3c8c7c34 --- /dev/null +++ b/efi/x86_64/syslinux.ld @@ -0,0 +1,176 @@ +/* ----------------------------------------------------------------------- + * + * Copyright 2008-2009 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston MA 02110-1301, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * Linker script for the SYSLINUX core + */ + +OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") +OUTPUT_ARCH(i386:x86-64) +ENTRY(_start) + +SECTIONS +{ + . = 0; + ImageBase = .; /* For gnu-efi's crt0 */ + __module_start = .; + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + .text : { + FILL(0x90909090) + __text_start = .; + *(.text) + *(.text.*) + __text_end = .; + } + + . = ALIGN(16); + + .rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + __rodata_end = .; + } + + . = ALIGN(4); + + .ctors : { + __ctors_start = .; + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __ctors_end = .; + } + + .dtors : { + __dtors_start = .; + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __dtors_end = .; + } + + . = ALIGN(4096); + .rel : { + *(.rel.got) + *(.rel.data) + *(.rel.data.*) + *(.rel.ctors) + } + + . = ALIGN(4); + + .gnu.hash : { + __gnu_hash_start = .; + *(.gnu.hash) + __gnu_hash_end = .; + } + + + .dynsym : { + __dynsym_start = .; + *(.dynsym) + __dynsym_end = .; + } + + . = ALIGN(4); + + .dynstr : { + __dynstr_start = .; + *(.dynstr) + __dynstr_end = .; + } + + . = ALIGN(4); + + .dynlink : { + __dynlink_start = .; + *(.dynlink) + __dynlink_end = .; + } + + . = ALIGN(4); + + .got : { + __got_start = .; + KEEP (*(.got.plt)) + KEEP (*(.got)) + __got_end = .; + } + + . = ALIGN(4); + + .dynamic : { + __dynamic_start = .; + *(.dynamic) + __dynamic_end = .; + } + + . = ALIGN(16); + + .data : { + __data_start = .; + *(.data) + *(.data.*) + *(.lowmem) + __data_end = .; + } + + .reloc : { + *(.reloc) + } + + .comment : { + *(.commet) + } + + .symtab : { + *(.symtab) + } + + .strtab : { + *(.strtab) + } + + .bss : { + /* the EFI loader doesn't seem to like a .bss section, + so we stick it all into .data: */ + __bss_start = .; + *(.bss) + *(.bss.*) + *(.bss16) + *(.hugebss) + *(COMMON) + __bss_end = .; + *(.sbss) + *(.scommon) + } + __bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start); + __bss_dwords = (__bss_len + 3) >> 2; + + . = ALIGN(128); + + /* Very large objects which don't need to be zeroed */ + + .hugebss : { + __hugebss_start = .; + *(.hugebss) + *(.hugebss.*) + __hugebss_end = .; + } + + _end = .; + + /* Stuff we don't need... */ + /DISCARD/ : { + *(.eh_frame) + } +} diff --git a/mbr/i386/mbr.ld b/mbr/i386/mbr.ld new file mode 100644 index 00000000..d14ba802 --- /dev/null +++ b/mbr/i386/mbr.ld @@ -0,0 +1,73 @@ +/* + * Linker script for MBR + */ + +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf32-i386", "elf32-i386", + "elf32-i386") +OUTPUT_ARCH(i386) +EXTERN(_start) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x600; + .text : + { + *(.text*) + *(.rodata*) + } =0x90909090 + + . = ALIGN(4); + .data : + { + *(.data*) + } + + . = ALIGN(128); + .bss : + { + *(.bss*) + } + + . = 0x7c00; + .bootsec : + { + *(.bootsec) + } + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /DISCARD/ : { *(.note.GNU-stack) } +} diff --git a/mbr/x86_64/mbr.ld b/mbr/x86_64/mbr.ld new file mode 100644 index 00000000..ae27d49a --- /dev/null +++ b/mbr/x86_64/mbr.ld @@ -0,0 +1,72 @@ +/* + * Linker script for MBR + */ + +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") +OUTPUT_ARCH(i386:x86-64) +EXTERN(_start) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x600; + .text : + { + *(.text*) + *(.rodata*) + } =0x90909090 + + . = ALIGN(4); + .data : + { + *(.data*) + } + + . = ALIGN(128); + .bss : + { + *(.bss*) + } + + . = 0x7c00; + .bootsec : + { + *(.bootsec) + } + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /DISCARD/ : { *(.note.GNU-stack) } +} diff --git a/memdisk/i386/memdisk.ld b/memdisk/i386/memdisk.ld new file mode 100644 index 00000000..51c3e35c --- /dev/null +++ b/memdisk/i386/memdisk.ld @@ -0,0 +1,140 @@ +/* ----------------------------------------------------------------------- + * + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston MA 02110-1301, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * Linker script for MEMDISK + */ + +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") +OUTPUT_ARCH(i386) +EXTERN(_start) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x100000; + PROVIDE (__executable_start = .); + + .init : + { + KEEP (*(.init)) + } =0x90909090 + .text : + { + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0x90909090 + .fini : + { + KEEP (*(.fini)) + } =0x90909090 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + + /* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(4); + PROVIDE (__preinit_array_start = .); + .preinit_array : { *(.preinit_array) } + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { *(.init_array) } + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { *(.fini_array) } + PROVIDE (__fini_array_end = .); + PROVIDE (__ctors_start = .); + .ctors : + { + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + PROVIDE (__ctors_end = .); + PROVIDE (__dtors_start = .); + .dtors : + { + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + PROVIDE (__dtors_end = .); + + /* Adjust the address for the data segment. Avoid mixing code and + data within same 128-byte chunk. */ + . = ALIGN(128); + + .data : + { + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; + PROVIDE (edata = .); + . = ALIGN(16); + .bss : + { + __bss_start = .; + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(4); + __bss_end = .; + } + _end = .; + PROVIDE (end = .); + + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /DISCARD/ : { *(.note.GNU-stack) } +} diff --git a/memdisk/x86_64/memdisk.ld b/memdisk/x86_64/memdisk.ld new file mode 100644 index 00000000..76abb0c0 --- /dev/null +++ b/memdisk/x86_64/memdisk.ld @@ -0,0 +1,140 @@ +/* ----------------------------------------------------------------------- + * + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston MA 02110-1301, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * Linker script for MEMDISK + */ + +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") +OUTPUT_ARCH(i386:x86-64) +EXTERN(_start) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x100000; + PROVIDE (__executable_start = .); + + .init : + { + KEEP (*(.init)) + } =0x90909090 + .text : + { + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0x90909090 + .fini : + { + KEEP (*(.fini)) + } =0x90909090 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + + /* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(4); + PROVIDE (__preinit_array_start = .); + .preinit_array : { *(.preinit_array) } + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { *(.init_array) } + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { *(.fini_array) } + PROVIDE (__fini_array_end = .); + PROVIDE (__ctors_start = .); + .ctors : + { + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + PROVIDE (__ctors_end = .); + PROVIDE (__dtors_start = .); + .dtors : + { + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + PROVIDE (__dtors_end = .); + + /* Adjust the address for the data segment. Avoid mixing code and + data within same 128-byte chunk. */ + . = ALIGN(128); + + .data : + { + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; + PROVIDE (edata = .); + . = ALIGN(16); + .bss : + { + __bss_start = .; + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(4); + __bss_end = .; + } + _end = .; + PROVIDE (end = .); + + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /DISCARD/ : { *(.note.GNU-stack) } +} |