diff options
Diffstat (limited to 'ld/scripttempl')
57 files changed, 6590 insertions, 87 deletions
diff --git a/ld/scripttempl/a29k.sc b/ld/scripttempl/a29k.sc new file mode 100644 index 000000000000..2825b1e83ea5 --- /dev/null +++ b/ld/scripttempl/a29k.sc @@ -0,0 +1,37 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +SECTIONS +{ + .text : { + *(.text) + ${RELOCATING+ __etext = .}; + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + *(.lit) + *(.shdata) + } + .shbss SIZEOF(.text) + ADDR(.text) : { + *(.shbss) + } + .data : { + *(.data) + ${RELOCATING+ __edata = .}; + } + .bss SIZEOF(.data) + ADDR(.data) : + { + *(.bss) + *(COMMON) + ${RELOCATING+ __end = ALIGN(0x8)}; + } +} +EOF diff --git a/ld/scripttempl/aix.sc b/ld/scripttempl/aix.sc new file mode 100644 index 000000000000..cdd3eac8139f --- /dev/null +++ b/ld/scripttempl/aix.sc @@ -0,0 +1,62 @@ +# AIX linker script. +# AIX always uses shared libraries. The section VMA appears to be +# unimportant. The native linker aligns the sections on boundaries +# specified by the -H option. + +cat <<EOF +OUTPUT_ARCH(${ARCH}) +${RELOCATING+${LIB_SEARCH_DIRS}} +ENTRY(__start) +SECTIONS +{ + .pad 0 : { *(.pad) } + + . = 0x10000000; + .text ${RELOCATING-0} : { + ${RELOCATING+PROVIDE (_text = .);} + *(.text) + *(.pr) + *(.ro) + *(.db) + *(.gl) + *(.xo) + *(.ti) + *(.tb) + ${RELOCATING+PROVIDE (_etext = .);} + } + . = ALIGN (0x10000000); + .data . : { + ${RELOCATING+PROVIDE (_data = .);} + *(.data) + *(.rw) + *(.sv) + *(.sv64) + *(.sv3264) + *(.ua) + . = ALIGN(4); + ${CONSTRUCTING+CONSTRUCTORS} + *(.ds) + *(.tc0) + *(.tc) + *(.td) + ${RELOCATING+PROVIDE (_edata = .);} + } + .bss : { + *(.tocbss) + *(.bss) + *(.bs) + *(.uc) + *(COMMON) + ${RELOCATING+PROVIDE (_end = .);} + ${RELOCATING+PROVIDE (end = .);} + } + + .loader : { + *(.loader) + } + + .debug : { + *(.debug) + } +} +EOF diff --git a/ld/scripttempl/avr.sc b/ld/scripttempl/avr.sc new file mode 100644 index 000000000000..74f7ae4009dd --- /dev/null +++ b/ld/scripttempl/avr.sc @@ -0,0 +1,189 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + text (rx) : ORIGIN = 0, LENGTH = $TEXT_LENGTH + data (rw!x) : ORIGIN = 0x800060, LENGTH = $DATA_LENGTH + eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t*)} + } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d*)} + } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Internal text space or external memory */ + .text : + { + *(.vectors) + + ${CONSTRUCTING+ __ctors_start = . ; } + ${CONSTRUCTING+ *(.ctors) } + ${CONSTRUCTING+ __ctors_end = . ; } + ${CONSTRUCTING+ __dtors_start = . ; } + ${CONSTRUCTING+ *(.dtors) } + ${CONSTRUCTING+ __dtors_end = . ; } + + *(.progmem.gcc*) + *(.progmem*) + ${RELOCATING+. = ALIGN(2);} + *(.init0) /* Start here after reset. */ + *(.init1) + *(.init2) /* Clear __zero_reg__, set up stack pointer. */ + *(.init3) + *(.init4) /* Initialize data and BSS. */ + *(.init5) + *(.init6) /* C++ constructors. */ + *(.init7) + *(.init8) + *(.init9) /* Call main(). */ + *(.text) + ${RELOCATING+. = ALIGN(2);} + *(.text.*) + ${RELOCATING+. = ALIGN(2);} + *(.fini9) /* _exit() starts here. */ + *(.fini8) + *(.fini7) + *(.fini6) /* C++ destructors. */ + *(.fini5) + *(.fini4) + *(.fini3) + *(.fini2) + *(.fini1) + *(.fini0) /* Infinite loop after program termination. */ + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > text} + + .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))} + { + ${RELOCATING+ PROVIDE (__data_start = .) ; } + *(.data) + *(.gnu.linkonce.d*) + ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+ _edata = . ; } + ${RELOCATING+ PROVIDE (__data_end = .) ; } + } ${RELOCATING+ > data} + + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + ${RELOCATING+ PROVIDE (__bss_start = .) ; } + *(.bss) + *(COMMON) + ${RELOCATING+ PROVIDE (__bss_end = .) ; } + } ${RELOCATING+ > data} + + ${RELOCATING+ __data_load_start = LOADADDR(.data); } + ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); } + + /* Global data not cleared after reset. */ + .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} : + { + ${RELOCATING+ PROVIDE (__noinit_start = .) ; } + *(.noinit*) + ${RELOCATING+ PROVIDE (__noinit_end = .) ; } + ${RELOCATING+ _end = . ; } + ${RELOCATING+ PROVIDE (__heap_start = .) ; } + } ${RELOCATING+ > data} + + .eeprom ${RELOCATING-0}: + ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text) + SIZEOF (.data))} + { + *(.eeprom*) + ${RELOCATING+ __eeprom_end = . ; } + } ${RELOCATING+ > eeprom} + + /* 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) } +} +EOF + diff --git a/ld/scripttempl/crisaout.sc b/ld/scripttempl/crisaout.sc new file mode 100644 index 000000000000..acdca7a91229 --- /dev/null +++ b/ld/scripttempl/crisaout.sc @@ -0,0 +1,131 @@ +cat <<EOF +OUTPUT_FORMAT("a.out-cris") +OUTPUT_ARCH(cris) +ENTRY(__start) +SECTIONS +{ + .text ${RELOCATING+ ${TEXT_START_ADDR}}: + { + CREATE_OBJECT_SYMBOLS; + ${CONSTRUCTING+ __Stext = .;} + ${RELOCATING+*(.startup)} + *(.text) + ${CONSTRUCTING+__start = DEFINED(__start) ? __start : + DEFINED(_start) ? _start : + DEFINED(start) ? start : + DEFINED(.startup) ? .startup + 2 : 2;} + ${RELOCATING+*(.text.*)} + ${RELOCATING+*(.gnu.linkonce.t*)} + ${RELOCATING+*(.rodata)} + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + + /* Do not "provide" init-start and fini-start symbols; they might be + referred to weakly, so the linker would not override the zero + default. + FIXME: It's somewhat unexpected to have code emitted by the linker + script. Some other mechanism could probably do better. */ + ${CONSTRUCTING+ . = ALIGN (2);} + ${CONSTRUCTING+ ___init__start = .;} + ${CONSTRUCTING+ PROVIDE (___do_global_ctors = .);} + ${CONSTRUCTING+ SHORT (0xe1fc); /* push srp */} + ${CONSTRUCTING+ SHORT (0xbe7e);} + ${CONSTRUCTING+ *(.init)} + ${CONSTRUCTING+ SHORT (0x0d3e); /* jump [sp+] */} + ${CONSTRUCTING+ PROVIDE (__init__end = .);} + ${CONSTRUCTING+ PROVIDE (___init__end = .);} + + ${CONSTRUCTING+ . = ALIGN (2);} + ${CONSTRUCTING+ ___fini__start = .;} + ${CONSTRUCTING+ PROVIDE (___do_global_dtors = .);} + ${CONSTRUCTING+ SHORT (0xe1fc); /* push srp */} + ${CONSTRUCTING+ SHORT (0xbe7e);} + ${CONSTRUCTING+ *(.fini)} + ${CONSTRUCTING+ SHORT (0x0d3e); /* jump [sp+] */} + ${CONSTRUCTING+ PROVIDE (__fini__end = .);} + ${CONSTRUCTING+ ___fini__end = .;} + + /* Cater to linking from ELF. */ + ${CONSTRUCTING+ PROVIDE(___ctors = .);} + ${CONSTRUCTING+ ___elf_ctors_dtors_begin = .;} + ${CONSTRUCTING+ KEEP (*crtbegin*.o(.ctors))} + ${CONSTRUCTING+ KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors))} + ${CONSTRUCTING+ KEEP (*(SORT(.ctors.*)))} + ${CONSTRUCTING+ KEEP (*(.ctors))} + ${CONSTRUCTING+ PROVIDE(___ctors_end = .);} + + ${CONSTRUCTING+ PROVIDE(___dtors = .);} + ${CONSTRUCTING+ KEEP (*crtbegin*.o(.dtors))} + ${CONSTRUCTING+ KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))} + ${CONSTRUCTING+ KEEP (*(SORT(.dtors.*)))} + ${CONSTRUCTING+ KEEP (*(.dtors))} + ${CONSTRUCTING+ PROVIDE(___dtors_end = .);} + ${CONSTRUCTING+ ___elf_ctors_dtors_end = .;} + + /* We include objects that force alignment of the data segment. + Unfortunately that sometimes causes a gap between .text and .data, + which is not detectable since .data does not have a start address + of itself in the a.out header. This should only matter for + testing; for production use, .data is at a "known" location. + We assume .data does not get an alignment larger than 32 bytes. */ + ${CONSTRUCTING+. = ALIGN (32);} + + ${CONSTRUCTING+ __Etext = .;} + + /* Deprecated, use __Etext. */ + ${CONSTRUCTING+ PROVIDE(_etext = .);} + } + + /* Any dot-relative start-expression (such as "ALIGN(2)", also including + the "default" .data alignment expression) will use the initial, raw + size of .text and will be incorrect if the alignment used is less + than the alignment for .text (which might depend on input and obj + format). FIXME: Seems like a bug in ld. Seems hard to fix. Seems + unimportant. */ + .data : + { + ${CONSTRUCTING+ __Sdata = .;} + *(.data); + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d*)} + ${RELOCATING+*(.eh_frame) /* FIXME: Make .text */} + ${RELOCATING+*(.gcc_except_table)} + + /* See comment at ALIGN before __Etext. */ + ${CONSTRUCTING+. = ALIGN (32);} + + ${CONSTRUCTING+ __Edata = .;} + + /* Deprecated, use __Edata. */ + ${CONSTRUCTING+ PROVIDE(_edata = .);} + } + + .bss : + { + /* Deprecated, use __Sbss. */ + ${CONSTRUCTING+ PROVIDE(_bss_start = .);} + + ${CONSTRUCTING+ __Sbss = .;} + *(.bss) + ${RELOCATING+*(.bss.*)} + *(COMMON) + ${CONSTRUCTING+ __Ebss = .;} + + /* Deprecated, use __Ebss or __Eall as appropriate. */ + ${CONSTRUCTING+ PROVIDE(_end = .);} + ${CONSTRUCTING+ PROVIDE(__end = .);} + } + ${CONSTRUCTING+ __Eall = .;} + + /* Unfortunately, stabs are not mappable from ELF to a.out. + It can probably be fixed with some amount of work. */ + /DISCARD/ : + { *(.stab) *(.stab*) *(.debug) *(.debug*) *(.comment) *(.gnu.warning.*) } + + /* For the rsim and xsim simulators. */ + ${CONSTRUCTING+ PROVIDE(__Endmem = 0x10000000);} + + /* For elinux. */ + ${CONSTRUCTING+ PROVIDE(__Stacksize = 0);} +} +EOF diff --git a/ld/scripttempl/delta68.sc b/ld/scripttempl/delta68.sc new file mode 100644 index 000000000000..d9963054e76d --- /dev/null +++ b/ld/scripttempl/delta68.sc @@ -0,0 +1,49 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +ENTRY(_start) +${RELOCATING+${LIB_SEARCH_DIRS}} + +SECTIONS +{ + .text ${RELOCATING+ 0x2000 + SIZEOF_HEADERS} : + { + ${RELOCATING+ __.text.start = .}; + *(.text) + ${RELOCATING+ etext = .;} + ${RELOCATING+ _etext = .;} + ${RELOCATING+ __.text.end = .}; + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + } + .data ${RELOCATING+ SIZEOF(.text) + ADDR(.text) + 0x400000} : + { + ${RELOCATING+ __.data.start = .}; + *(.data) + ${RELOCATING+ edata = .}; + ${RELOCATING+ _edata = .}; + ${RELOCATING+ __.data.end = .}; + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + ${RELOCATING+ __.bss.start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+ __.bss.end = .}; + ${RELOCATING+ end = ALIGN(0x8)}; + ${RELOCATING+ _end = ALIGN(0x8)}; + } + .comment ${RELOCATING+ 0} : + { + *(.comment) + } +} +EOF diff --git a/ld/scripttempl/dlx.sc b/ld/scripttempl/dlx.sc new file mode 100644 index 000000000000..b222b3356003 --- /dev/null +++ b/ld/scripttempl/dlx.sc @@ -0,0 +1,30 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : + { + CREATE_OBJECT_SYMBOLS + *(.text) + ${RELOCATING+etext = ${DATA_ALIGNMENT};} + } + ${RELOCATING+. = ${DATA_ALIGNMENT};} + .data : + { + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+edata = .;} + } + .bss : + { + *(.bss) + *(COMMON) + ${RELOCATING+end = . }; + } +} +EOF diff --git a/ld/scripttempl/ebmon29k.sc b/ld/scripttempl/ebmon29k.sc new file mode 100644 index 000000000000..62050ee21701 --- /dev/null +++ b/ld/scripttempl/ebmon29k.sc @@ -0,0 +1,27 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +ENTRY(start) + +SECTIONS { + .text ${RELOCATING+${TEXT_START_ADDR}} : + { + *(.text); + ${RELOCATING+_etext = .}; + } + data ${RELOCATING+0x80002000} : + { + *(.data); + *(.mstack); + *(.shbss); + *(.rstack); + *(.mstack); + ${CONSTRUCTING+CONSTRUCTORS} + } + .bss . : + { + *(COMMON) + *(.bss); + ${RELOCATING+_end = .}; + } +} +EOF diff --git a/ld/scripttempl/elf32msp430.sc b/ld/scripttempl/elf32msp430.sc new file mode 100644 index 000000000000..5754d662dcf6 --- /dev/null +++ b/ld/scripttempl/elf32msp430.sc @@ -0,0 +1,246 @@ +#!/bin/sh + +HEAP_SECTION_MSP430=" " +HEAP_MEMORY_MSP430=" " + +if test ${GOT_HEAP_MSP-0} -ne 0 +then +HEAP_SECTION_MSP430=".heap ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__heap_data_start = .) ; } + *(.heap*) + ${RELOCATING+ PROVIDE (_heap_data_end = .) ; } + ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+ PROVIDE (__heap_bottom = .) ; } + ${RELOCATING+ PROVIDE (__heap_top = ${HEAP_START} + ${HEAP_LENGTH}) ; } + } ${RELOCATING+ > heap}" +HEAP_MEMORY_MSP430="heap(rwx) : ORIGIN = $HEAP_START, LENGTH = $HEAP_LENGTH" +fi + + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + text (rx) : ORIGIN = $ROM_START, LENGTH = $ROM_SIZE + data (rwx) : ORIGIN = $RAM_START, LENGTH = $RAM_SIZE + vectors (rw) : ORIGIN = 0xffe0, LENGTH = 0x20 + bootloader(rx) : ORIGIN = 0x0c00, LENGTH = 1K + infomem(rx) : ORIGIN = 0x1000, LENGTH = 256 + infomemnobits(rx) : ORIGIN = 0x1000, LENGTH = 256 + ${HEAP_MEMORY_MSP430} +} + +SECTIONS +{ + /* Read-only sections, merged into text segment. */ + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t*)} + } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d*)} + } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Internal text space. */ + .text : + { + ${RELOCATING+. = ALIGN(2);} + *(.init) + *(.init0) /* Start here after reset. */ + *(.init1) + *(.init2) /* Copy data loop */ + *(.init3) + *(.init4) /* Clear bss */ + *(.init5) + *(.init6) /* C++ constructors. */ + *(.init7) + *(.init8) + *(.init9) /* Call main(). */ + + ${CONSTRUCTING+ __ctors_start = . ; } + ${CONSTRUCTING+ *(.ctors) } + ${CONSTRUCTING+ __ctors_end = . ; } + ${CONSTRUCTING+ __dtors_start = . ; } + ${CONSTRUCTING+ *(.dtors) } + ${CONSTRUCTING+ __dtors_end = . ; } + + ${RELOCATING+. = ALIGN(2);} + *(.text) + ${RELOCATING+. = ALIGN(2);} + *(.text.*) + + ${RELOCATING+. = ALIGN(2);} + *(.fini9) /* */ + *(.fini8) + *(.fini7) + *(.fini6) /* C++ destructors. */ + *(.fini5) + *(.fini4) + *(.fini3) + *(.fini2) + *(.fini1) + *(.fini0) /* Infinite loop after program termination. */ + *(.fini) + + _etext = .; + } ${RELOCATING+ > text} + + .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))} + { + ${RELOCATING+ PROVIDE (__data_start = .) ; } + ${RELOCATING+. = ALIGN(2);} + *(.data) + ${RELOCATING+. = ALIGN(2);} + *(.gnu.linkonce.d*) + ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > data} + + /* Bootloader. */ + .bootloader ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__boot_start = .) ; } + *(.bootloader) + ${RELOCATING+. = ALIGN(2);} + *(.bootloader.*) + } ${RELOCATING+ > bootloader} + + /* Information memory. */ + .infomem ${RELOCATING-0} : + { + *(.infomem) + ${RELOCATING+. = ALIGN(2);} + *(.infomem.*) + } ${RELOCATING+ > infomem} + + /* Information memory (not loaded into MPU). */ + .infomemnobits ${RELOCATING-0} : + { + *(.infomemnobits) + ${RELOCATING+. = ALIGN(2);} + *(.infomemnobits.*) + } ${RELOCATING+ > infomemnobits} + + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + ${RELOCATING+ PROVIDE (__bss_start = .) ; } + *(.bss) + *(COMMON) + ${RELOCATING+ PROVIDE (__bss_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > data} + + .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} : + { + ${RELOCATING+ PROVIDE (__noinit_start = .) ; } + *(.noinit) + *(COMMON) + ${RELOCATING+ PROVIDE (__noinit_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > data} + + .vectors ${RELOCATING-0}: + { + ${RELOCATING+ PROVIDE (__vectors_start = .) ; } + *(.vectors*) + ${RELOCATING+ _vectors_end = . ; } + } ${RELOCATING+ > vectors} + + ${HEAP_SECTION_MSP430} + + /* 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) } + + PROVIDE (__stack = ${STACK}) ; + PROVIDE (__data_start_rom = _etext) ; + PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ; + PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ; + PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ; + PROVIDE (__subdevice_has_heap = ${GOT_HEAP_MSP-0}) ; +} +EOF diff --git a/ld/scripttempl/elf32msp430_3.sc b/ld/scripttempl/elf32msp430_3.sc new file mode 100644 index 000000000000..15eb51723068 --- /dev/null +++ b/ld/scripttempl/elf32msp430_3.sc @@ -0,0 +1,192 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + text (rx) : ORIGIN = $ROM_START, LENGTH = $ROM_SIZE + data (rwx) : ORIGIN = $RAM_START, LENGTH = $RAM_SIZE + vectors (rw) : ORIGIN = 0xffe0, LENGTH = 0x20 +} + +SECTIONS +{ + /* Read-only sections, merged into text segment. */ + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t*)} + } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d*)} + } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Internal text space. */ + .text : + { + ${RELOCATING+. = ALIGN(2);} + *(.init) + *(.init0) /* Start here after reset. */ + *(.init1) + *(.init2) + *(.init3) + *(.init4) + *(.init5) + *(.init6) /* C++ constructors. */ + *(.init7) + *(.init8) + *(.init9) /* Call main(). */ + + ${CONSTRUCTING+ __ctors_start = . ; } + ${CONSTRUCTING+ *(.ctors) } + ${CONSTRUCTING+ __ctors_end = . ; } + ${CONSTRUCTING+ __dtors_start = . ; } + ${CONSTRUCTING+ *(.dtors) } + ${CONSTRUCTING+ __dtors_end = . ; } + + ${RELOCATING+. = ALIGN(2);} + *(.text) + ${RELOCATING+. = ALIGN(2);} + *(.text.*) + + ${RELOCATING+. = ALIGN(2);} + *(.fini9) + *(.fini8) + *(.fini7) + *(.fini6) /* C++ destructors. */ + *(.fini5) + *(.fini4) + *(.fini3) + *(.fini2) + *(.fini1) + *(.fini0) /* Infinite loop after program termination. */ + *(.fini) + + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > text} + + .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))} + { + ${RELOCATING+ PROVIDE (__data_start = .) ; } + *(.data) + *(.gnu.linkonce.d*) + ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > data} + + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + ${RELOCATING+ PROVIDE (__bss_start = .) ; } + *(.bss) + *(COMMON) + ${RELOCATING+ PROVIDE (__bss_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > data} + + .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} : + { + ${RELOCATING+ PROVIDE (__noinit_start = .) ; } + *(.noinit) + *(COMMON) + ${RELOCATING+ PROVIDE (__noinit_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > data} + + .vectors ${RELOCATING-0}: + { + ${RELOCATING+ PROVIDE (__vectors_start = .) ; } + *(.vectors*) + ${RELOCATING+ _vectors_end = . ; } + } ${RELOCATING+ > vectors} + + /* 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) } + + PROVIDE (__stack = ${STACK}) ; + PROVIDE (__data_start_rom = _etext) ; + PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ; + PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ; + PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ; +} +EOF diff --git a/ld/scripttempl/elf_chaos.sc b/ld/scripttempl/elf_chaos.sc new file mode 100644 index 000000000000..35812898e1d3 --- /dev/null +++ b/ld/scripttempl/elf_chaos.sc @@ -0,0 +1,354 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not +# empty. +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# INITIAL_READONLY_SECTIONS - at start of text segment +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_TEXT_SECTIONS - these get put in .text when relocating +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_BSS_SECTIONS - other than .bss .sbss ... +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# BSS_PLT - .plt should be in bss segment +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# STACK_ADDR - start of a .stack section. +# OTHER_END_SYMBOLS - symbols to place right at the end of the script. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# .debug_info .gnu.linkonce.wi.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__sbss_start = .);} + ${RELOCATING+PROVIDE (___sbss_start = .);} + *(.dynsbss) + *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) + *(.scommon) + ${RELOCATING+PROVIDE (__sbss_end = .);} + ${RELOCATING+PROVIDE (___sbss_end = .);} + }" + SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" + SDATA="/* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) + }" + SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }" + REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" + REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" + REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } + .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" + REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } + .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" +fi +CTOR=" + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} +" +DTOR=" + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} +" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+_stack = .;} + *(.stack) + }" + +test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}} + ${CREATE_SHLIB-${INTERP}} + ${INITIAL_READONLY_SECTIONS} + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } + +EOF +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT=cat +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + ${REL_SDATA} + ${REL_SBSS} + ${REL_SDATA2} + ${REL_SBSS2} + .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } +EOF +if [ -n "$COMBRELOC" ]; then +cat <<EOF + .rel.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC +cat <<EOF + } + .rela.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC +cat <<EOF + } +EOF +fi +cat <<EOF + . = ALIGN(0x1000); + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} + ${DATA_PLT-${BSS_PLT-${PLT}}} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + . = ALIGN(0x1000); + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${OTHER_READONLY_SECTIONS} + .eh_frame_hdr : { *(.eh_frame_hdr) } + + . = ALIGN(0x1000); + .data ${RELOCATING-0} : + { + *(.rodata .rodata.*) + *(.rodata1) + *(.gnu.linkonce.r.*) + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + KEEP (*(.eh_frame)) + *(.gcc_except_table) + ${CTOR} + ${DTOR} + KEEP (*(.jcr)) + } + .data1 ${RELOCATING-0} : { *(.data1) } + . = ALIGN(0x1000); + .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) } + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${DATA_PLT+${PLT}} + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + ${OTHER_GOT_SECTIONS} + ${CREATE_SHLIB+${SDATA2}} + ${CREATE_SHLIB+${SBSS2}} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${SBSS} + ${BSS_PLT+${PLT}} + . = ALIGN(0x1000); + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss${RELOCATING+ .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. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } + ${OTHER_BSS_SECTIONS} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+_end = .;} + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+PROVIDE (end = .);} + + /* Stabs debugging sections. */ + . = ALIGN(0x1000); + .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) } + + . = ALIGN(0x1000); + .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) } + + ${STACK_ADDR+${STACK}} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_END_SYMBOLS}} +} +EOF diff --git a/ld/scripttempl/elfd10v.sc b/ld/scripttempl/elfd10v.sc new file mode 100644 index 000000000000..834efe26f7e6 --- /dev/null +++ b/ld/scripttempl/elfd10v.sc @@ -0,0 +1,196 @@ +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" + + +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + + KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" + +STACK=" .stack : { _stack = .; *(.stack) } >STACK " + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR}" +fi + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} + +MEMORY +{ + /* These are the values for the D10V-TS3 board. + There are other memory regions available on + the TS3 (eg ROM, FLASH, etc) but these are not + used by this script. */ + + INSN : org = 0x01000000, len = 256K + DATA : org = 0x02000000, len = 48K + + /* This is a fake memory region at the top of the + on-chip RAM, used as the start of the + (descending) stack. */ + + STACK : org = 0x0200BFFC, len = 4 +} + +SECTIONS +{ + .text ${RELOCATING+${TEXT_START_ADDR}} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + KEEP (*(.init)) + KEEP (*(.init.*)) + KEEP (*(.fini)) + KEEP (*(.fini.*)) + *(.text) + *(.text.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + } ${RELOCATING+ >INSN} =${NOP-0} + + .rodata ${RELOCATING+${READONLY_START_ADDR}} : { + *(.rodata) + *(.gnu.linkonce.r*) + *(.rodata.*) + } ${RELOCATING+ >DATA} + + .rodata1 ${RELOCATING-0} : { + *(.rodata1) + *(.rodata1.*) + } ${RELOCATING+ >DATA} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + ${CONSTRUCTING+CONSTRUCTORS} + } ${RELOCATING+ >DATA} + + .data1 ${RELOCATING-0} : { + *(.data1) + *(.data1.*) + } ${RELOCATING+ >DATA} + + ${RELOCATING+${CTOR} >DATA} + ${RELOCATING+${DTOR} >DATA} + + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : { + *(.sdata) + *(.sdata.*) + } ${RELOCATING+ >DATA} + + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } ${RELOCATING+ >DATA} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.dynbss.*) + *(.bss) + *(.bss.*) + *(COMMON) + } ${RELOCATING+ >DATA} + + ${RELOCATING+_end = . ;} + ${RELOCATING+PROVIDE (end = .);} + + ${RELOCATING+$STACK} + + /* 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) } +} +EOF diff --git a/ld/scripttempl/elfd30v.sc b/ld/scripttempl/elfd30v.sc new file mode 100644 index 000000000000..12d764f285e0 --- /dev/null +++ b/ld/scripttempl/elfd30v.sc @@ -0,0 +1,223 @@ + +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ __CTOR_LIST__ = .; } + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + + KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+ __CTOR_END__ = .; } + } ${RELOCATING+ > ${DATA_MEMORY}}" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ __DTOR_LIST__ = .; } + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+ __DTOR_END__ = .; } + } ${RELOCATING+ > ${DATA_MEMORY}}" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + text ${TEXT_DEF_SECTION} : ORIGIN = ${TEXT_START_ADDR}, LENGTH = ${TEXT_SIZE} + data ${DATA_DEF_SECTION} : ORIGIN = ${DATA_START_ADDR}, LENGTH = ${DATA_SIZE} + emem ${EMEM_DEF_SECTION} : ORIGIN = ${EMEM_START_ADDR}, LENGTH = ${EMEM_SIZE} + eit : ORIGIN = ${EIT_START_ADDR}, LENGTH = ${EIT_SIZE} +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.text ${RELOCATING-0} : { *(.rel.text) *(.rel.gnu.linkonce.t*) } + .rela.text ${RELOCATING-0} : { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rel.data ${RELOCATING-0} : { *(.rel.data) *(.rel.gnu.linkonce.d*) } + .rela.data ${RELOCATING-0} : { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rel.stext ${RELOCATING-0} : { *(.rel.stest) } + .rela.stext ${RELOCATING-0} : { *(.rela.stest) } + .rel.etext ${RELOCATING-0} : { *(.rel.etest) } + .rela.etext ${RELOCATING-0} : { *(.rela.etest) } + .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } + .rel.edata ${RELOCATING-0} : { *(.rel.edata) } + .rela.edata ${RELOCATING-0} : { *(.rela.edata) } + .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) } + .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) } + .rel.sbss ${RELOCATING-0} : { *(.rel.sbss) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) } + .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) } + .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) } + .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) } + .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) } + .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) } + .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + .init ${RELOCATING-0} : { *(.init) } =${NOP-0} + ${DATA_PLT-${PLT}} + + /* Internal text space */ + .stext ${RELOCATING-0} : { *(.stext) } ${RELOCATING+ > text} + + /* Internal text space or external memory */ + .text : + { + *(.text) + *(.gnu.linkonce.t*) + *(.init) + *(.fini) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Internal data space */ + .srodata ${RELOCATING-0} : { *(.srodata) } ${RELOCATING+ > data} + .sdata ${RELOCATING-0} : { *(.sdata) } ${RELOCATING+ > data} + + /* Internal data space or external memory */ + .rodata ${RELOCATING-0} : { *(.rodata) } ${RELOCATING+ > ${DATA_MEMORY}} + + /* C++ exception support. */ + .eh_frame ${RELOCATING-0} : { KEEP (*(.eh_frame)) } ${RELOCATING+ > ${DATA_MEMORY}} + .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) } ${RELOCATING+ > ${DATA_MEMORY}} + + /* Java class registration support. */ + .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } ${RELOCATING+ >${DATA_MEMORY}} + + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + + .data ${RELOCATING-0} : + { + *(.data) + *(.gnu.linkonce.d*) + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ${DATA_MEMORY}} + + /* External memory */ + .etext ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__etext_start = .) ; } + *(.etext) + ${RELOCATING+ PROVIDE (__etext_end = .) ; } + } ${RELOCATING+ > emem} + + .erodata ${RELOCATING-0} : { *(.erodata) } ${RELOCATING+ > emem} + .edata ${RELOCATING-0} : { *(.edata) } ${RELOCATING+ > emem} + + .sbss ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__sbss_start = .) ; } + *(.sbss) + ${RELOCATING+ PROVIDE (__sbss_end = .) ; } + } ${RELOCATING+ > data} + + .ebss ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__ebss_start = .) ; } + *(.ebss) + ${RELOCATING+ PROVIDE (__ebss_end = .) ; } + } ${RELOCATING+ > data} + + .bss ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__bss_start = .) ; } + *(.bss) + *(COMMON) + ${RELOCATING+ PROVIDE (__bss_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > ${DATA_MEMORY}} + + .eit_v ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__eit_start = .) ; } + *(.eit_v) + ${RELOCATING+ PROVIDE (__eit_end = .) ; } + } ${RELOCATING+ > eit} + + /* 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) } + + PROVIDE (__stack = ${STACK_START_ADDR}); +} +EOF + + + + diff --git a/ld/scripttempl/elfppc.sc b/ld/scripttempl/elfi370.sc index ddab8f80f814..6b390fe95cf6 100644 --- a/ld/scripttempl/elfppc.sc +++ b/ld/scripttempl/elfi370.sc @@ -1,6 +1,8 @@ # +# This is just a raw copy of elfppc.sc and has not been otherwise modified +# # Unusual variables checked by this code: -# NOP - two byte opcode for no-op (defaults to 0) +# NOP - four byte opcode for no-op (defaults to 0) # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start # OTHER_READONLY_SECTIONS - other than .text .init .rodata ... # (e.g., .PARISC.milli) @@ -27,42 +29,6 @@ SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) }" SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) }" INTERP=".interp ${RELOCATING-0} : { *(.interp) }" PLT=".plt ${RELOCATING-0} : { *(.plt) }" -CTOR=".ctors ${CONSTRUCTING-0} : - { - ${CONSTRUCTING+${CTOR_START}} - /* gcc uses crtbegin.o to find the start of - the constructors, so we make sure it is - first. Because this is a wildcard, it - doesn't matter if the user does not - actually link against crtbegin.o; the - linker won't look for a file to match a - wildcard. The wildcard also means that it - doesn't matter which directory crtbegin.o - is in. */ - - KEEP (*crtbegin.o(.ctors)) - - /* We don't want to include the .ctor section from - from the crtend.o file until after the sorted ctors. - The .ctor section from the crtend file contains the - end of ctors marker and it must be last */ - - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - ${CONSTRUCTING+${CTOR_END}} - }" - -DTOR=" .dtors ${CONSTRUCTING-0} : - { - ${CONSTRUCTING+${DTOR_START}} - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - ${CONSTRUCTING+${DTOR_END}} - }" - cat <<EOF OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}") @@ -79,7 +45,6 @@ ${RELOCATING- /* For some reason, the Solaris linker makes bad executables bug. But for now assigning the zero vmas works. */} ${RELOCATING+PROVIDE (__stack = 0);} -${RELOCATING+PROVIDE (___stack = 0);} SECTIONS { /* Read-only sections, merged into text segment: */ @@ -93,23 +58,11 @@ SECTIONS .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } .rela.text ${RELOCATING-0} : - { - *(.rela.text) - ${RELOCATING+*(.rela.text.*)} - ${RELOCATING+*(.rela.gnu.linkonce.t*)} - } + { *(.rela.text) *(.rela.gnu.linkonce.t*) } .rela.data ${RELOCATING-0} : - { - *(.rela.data) - ${RELOCATING+*(.rela.data.*)} - ${RELOCATING+*(.rela.gnu.linkonce.d*)} - } + { *(.rela.data) *(.rela.gnu.linkonce.d*) } .rela.rodata ${RELOCATING-0} : - { - *(.rela.rodata) - ${RELOCATING+*(.rela.rodata.*)} - ${RELOCATING+*(.rela.gnu.linkonce.r*)} - } + { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } .rela.got ${RELOCATING-0} : { *(.rela.got) } .rela.got1 ${RELOCATING-0} : { *(.rela.got1) } .rela.got2 ${RELOCATING-0} : { *(.rela.got2) } @@ -127,26 +80,19 @@ SECTIONS { ${RELOCATING+${TEXT_START_SYMBOLS}} *(.text) - ${RELOCATING+*(.text.*)} /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) - ${RELOCATING+*(.gnu.linkonce.t*)} + *(.gnu.linkonce.t*) } =${NOP-0} - .init ${RELOCATING-0} : { KEEP (*(.init)) } =${NOP-0} - .fini ${RELOCATING-0} : { KEEP (*(.fini)) } =${NOP-0} - .rodata ${RELOCATING-0} : - { - *(.rodata) - ${RELOCATING+*(.rodata.*)} - ${RELOCATING+*(.gnu.linkonce.r*)} - } + .init ${RELOCATING-0} : { *(.init) } =${NOP-0} + .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} + .rodata ${RELOCATING-0} : { *(.rodata) *(.gnu.linkonce.r*) } .rodata1 ${RELOCATING-0} : { *(.rodata1) } ${RELOCATING+_etext = .;} ${RELOCATING+PROVIDE (etext = .);} - ${RELOCATING+PROVIDE (__etext = .);} ${CREATE_SHLIB-${SDATA2}} ${CREATE_SHLIB-${SBSS2}} - ${RELOCATING+${OTHER_READONLY_SECTIONS}} + ${OTHER_READONLY_SECTIONS} /* Adjust the address for the data segment. We want to adjust up to the same address within the page on the next page up. It would @@ -168,12 +114,11 @@ SECTIONS { ${RELOCATING+${DATA_START_SYMBOLS}} *(.data) - ${RELOCATING+*(.data.*)} - ${RELOCATING+*(.gnu.linkonce.d*)} + *(.gnu.linkonce.d*) ${CONSTRUCTING+CONSTRUCTORS} } .data1 ${RELOCATING-0} : { *(.data1) } - ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + ${OTHER_READWRITE_SECTIONS} .got1 ${RELOCATING-0} : { *(.got1) } .dynamic ${RELOCATING-0} : { *(.dynamic) } @@ -183,37 +128,27 @@ SECTIONS The current compiler no longer needs this, but keep it around for 2.7.2 */ ${RELOCATING+PROVIDE (_GOT2_START_ = .);} - ${RELOCATING+PROVIDE (__GOT2_START_ = .);} .got2 ${RELOCATING-0} : { *(.got2) } ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);} - ${RELOCATING+PROVIDE (___CTOR_LIST__ = .);} - ${RELOCATING+${CTOR}} + .ctors ${RELOCATING-0} : { *(.ctors) } ${RELOCATING+PROVIDE (__CTOR_END__ = .);} - ${RELOCATING+PROVIDE (___CTOR_END__ = .);} ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);} - ${RELOCATING+PROVIDE (___DTOR_LIST__ = .);} - ${RELOCATING+${DTOR}} + .dtors ${RELOCATING-0} : { *(.dtors) } ${RELOCATING+PROVIDE (__DTOR_END__ = .);} - ${RELOCATING+PROVIDE (___DTOR_END__ = .);} ${RELOCATING+PROVIDE (_FIXUP_START_ = .);} - ${RELOCATING+PROVIDE (__FIXUP_START_ = .);} .fixup ${RELOCATING-0} : { *(.fixup) } ${RELOCATING+PROVIDE (_FIXUP_END_ = .);} - ${RELOCATING+PROVIDE (__FIXUP_END_ = .);} ${RELOCATING+PROVIDE (_GOT2_END_ = .);} - ${RELOCATING+PROVIDE (__GOT2_END_ = .);} ${RELOCATING+PROVIDE (_GOT_START_ = .);} - ${RELOCATING+PROVIDE (__GOT_START_ = .);} .got ${RELOCATING-0} : { *(.got) } .got.plt ${RELOCATING-0} : { *(.got.plt) } ${CREATE_SHLIB+${SDATA2}} ${CREATE_SHLIB+${SBSS2}} ${RELOCATING+PROVIDE (_GOT_END_ = .);} - ${RELOCATING+PROVIDE (__GOT_END_ = .);} /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so @@ -221,30 +156,25 @@ SECTIONS .sdata ${RELOCATING-0} : { *(.sdata) } ${RELOCATING+_edata = .;} ${RELOCATING+PROVIDE (edata = .);} - ${RELOCATING+PROVIDE (__edata = .);} .sbss ${RELOCATING-0} : { ${RELOCATING+PROVIDE (__sbss_start = .);} - ${RELOCATING+PROVIDE (___sbss_start = .);} *(.sbss) *(.scommon) *(.dynsbss) ${RELOCATING+PROVIDE (__sbss_end = .);} - ${RELOCATING+PROVIDE (___sbss_end = .);} } ${PLT} .bss ${RELOCATING-0} : { ${RELOCATING+${OTHER_BSS_SYMBOLS}} ${RELOCATING+PROVIDE (__bss_start = .);} - ${RELOCATING+PROVIDE (___bss_start = .);} *(.dynbss) *(.bss) *(COMMON) } ${RELOCATING+_end = . ;} ${RELOCATING+PROVIDE (end = .);} - ${RELOCATING+PROVIDE (__end = .);} /* These are needed for ELF backends which have not yet been converted to the new style linker. */ @@ -268,7 +198,7 @@ SECTIONS .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) } + .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } @@ -282,7 +212,6 @@ SECTIONS .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } - /* These must appear regardless of ${RELOCATING}. */ ${OTHER_SECTIONS} } EOF diff --git a/ld/scripttempl/elfm68hc11.sc b/ld/scripttempl/elfm68hc11.sc new file mode 100644 index 000000000000..f4977f67ac40 --- /dev/null +++ b/ld/scripttempl/elfm68hc11.sc @@ -0,0 +1,460 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# EMBEDDED - whether this is for an embedded system. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test "$LD_FLAG" = "N" && DATA_ADDR=. + +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); } + ${CONSTRUCTING+${CTOR_START}} + KEEP (*(.ctors)) + + ${CONSTRUCTING+${CTOR_END}} + ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); } + } ${RELOCATING+ > ${TEXT_MEMORY}}" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); } + KEEP (*(.dtors)) + ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); } + } ${RELOCATING+ > ${TEXT_MEMORY}}" + + +VECTORS=" + /* If the 'vectors_addr' symbol is defined, it indicates the start address + of interrupt vectors. This depends on the 68HC11 operating mode: + + Addr + Single chip 0xffc0 + Extended mode 0xffc0 + Bootstrap 0x00c0 + Test 0xbfc0 + + In general, the vectors address is 0xffc0. This can be overriden + with the '-defsym vectors_addr=0xbfc0' ld option. + + Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but + they are redirected to 0x00c0 by the internal PROM. Application's vectors + must also consist of jump instructions (see Motorola's manual). */ + + PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0); + .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 : + { + KEEP (*(.vectors)) + }" + +# +# We provide two emulations: a fixed on that defines some memory banks +# and a configurable one that includes a user provided memory definition. +# +case $GENERIC_BOARD in + yes|1|YES) + MEMORY_DEF=" +/* Get memory banks definition from some user configuration file. + This file must be located in some linker directory (search path + with -L<dir>). See fixed memory banks emulation script. */ +INCLUDE memory.x; +" + ;; + *) +MEMORY_DEF=" +/* Fixed definition of the available memory banks. + See generic emulation script for a user defined configuration. */ +MEMORY +{ + page0 (rwx) : ORIGIN = 0x0, LENGTH = 256 + text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE} + data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE} + eeprom : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE} +} + +/* Setup the stack on the top of the data memory bank. */ +PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1); +" + ;; +esac + +STARTUP_CODE=" + /* Startup code. */ + KEEP (*(.install0)) /* Section should setup the stack pointer. */ + KEEP (*(.install1)) /* Place holder for applications. */ + KEEP (*(.install2)) /* Optional installation of data sections in RAM. */ + KEEP (*(.install3)) /* Place holder for applications. */ + KEEP (*(.install4)) /* Section that calls the main. */ +" + +FINISH_CODE=" + /* Finish code. */ + KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */ + KEEP (*(.fini1)) /* Place holder for applications. */ + KEEP (*(.fini2)) /* C++ destructors. */ + KEEP (*(.fini3)) /* Place holder for applications. */ + KEEP (*(.fini4)) /* Runtime exit. */ +" + +PRE_COMPUTE_DATA_SIZE=" +/* SCz: this does not work yet... This is supposed to force the loading + of _map_data.o (from libgcc.a) when the .data section is not empty. + By doing so, this should bring the code that copies the .data section + from ROM to RAM at init time. + + ___pre_comp_data_size = SIZEOF(.data); + __install_data_sections = ___pre_comp_data_size > 0 ? + __map_data_sections : 0; +*/ +" + +INSTALL_RELOC=" + .install0 0 : { *(.install0) } + .install1 0 : { *(.install1) } + .install2 0 : { *(.install2) } + .install3 0 : { *(.install3) } + .install4 0 : { *(.install4) } +" + +FINISH_RELOC=" + .fini0 0 : { *(.fini0) } + .fini1 0 : { *(.fini1) } + .fini2 0 : { *(.fini2) } + .fini3 0 : { *(.fini3) } + .fini4 0 : { *(.fini4) } +" + +BSS_DATA_RELOC=" + .data1 0 : { *(.data1) } + + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata 0 : { *(.sdata) } + .sbss 0 : { *(.sbss) } + .scommon 0 : { *(.scommon) } +" + +SOFT_REGS_RELOC=" + .softregs 0 : { *(.softregs) } +" + +cat <<EOF +${RELOCATING+/* Linker script for 68HC11 executable (PROM). */} +${RELOCATING-/* Linker script for 68HC11 object file (ld -r). */} + +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${MEMORY_DEF}} + +SECTIONS +{ + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t.*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t.*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d.*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d.*)} + } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r.*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r.*)} + } + .rel.sdata ${RELOCATING-0} : + { + *(.rel.sdata) + ${RELOCATING+*(.rel.sdata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.s.*)} + } + .rela.sdata ${RELOCATING-0} : + { + *(.rela.sdata) + ${RELOCATING+*(.rela.sdata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.s.*)} + } + .rel.sbss ${RELOCATING-0} : + { + *(.rel.sbss) + ${RELOCATING+*(.rel.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rela.sbss ${RELOCATING-0} : + { + *(.rela.sbss) + ${RELOCATING+*(.rela.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rel.bss ${RELOCATING-0} : + { + *(.rel.bss) + ${RELOCATING+*(.rel.bss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.b.*)} + } + .rela.bss ${RELOCATING-0} : + { + *(.rela.bss) + ${RELOCATING+*(.rela.bss.*)} + ${RELOCATING+*(.rela.gnu.linkonce.b.*)} + } + .rel.stext ${RELOCATING-0} : { *(.rel.stest) } + .rela.stext ${RELOCATING-0} : { *(.rela.stest) } + .rel.etext ${RELOCATING-0} : { *(.rel.etest) } + .rela.etext ${RELOCATING-0} : { *(.rela.etest) } + .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } + .rel.edata ${RELOCATING-0} : { *(.rel.edata) } + .rela.edata ${RELOCATING-0} : { *(.rela.edata) } + .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) } + .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) } + .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) } + .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) } + .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) } + .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) } + .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) } + .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Concatenate .page0 sections. Put them in the page0 memory bank + unless we are creating a relocatable file. */ + .page0 : + { + *(.page0) + ${RELOCATING+*(.softregs)} + } ${RELOCATING+ > page0} + + /* Start of text section. */ + .stext ${RELOCATING-0} : + { + *(.stext) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .init ${RELOCATING-0} : + { + *(.init) + } ${RELOCATING+=${NOP-0}} + + ${RELOCATING-${INSTALL_RELOC}} + ${RELOCATING-${FINISH_RELOC}} + + .text ${RELOCATING-0}: + { + /* Put startup code at beginning so that _start keeps same address. */ + ${RELOCATING+${STARTUP_CODE}} + + ${RELOCATING+*(.init)} + *(.text) + ${RELOCATING+*(.text.*)} + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.gnu.linkonce.t.*)} + ${RELOCATING+*(.tramp)} + ${RELOCATING+*(.tramp.*)} + + ${RELOCATING+${FINISH_CODE}} + + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .eh_frame ${RELOCATING-0} : + { + KEEP (*(.eh_frame)) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .gcc_except_table ${RELOCATING-0} : + { + *(.gcc_except_table) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .rodata ${RELOCATING-0} : + { + *(.rodata) + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .rodata1 ${RELOCATING-0} : + { + *(.rodata1) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Constructor and destructor tables are in ROM. */ + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + + .jcr ${RELOCATING-0} : + { + KEEP (*(.jcr)) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Start of the data section image in ROM. */ + ${RELOCATING+__data_image = .;} + ${RELOCATING+PROVIDE (__data_image = .);} + + /* All read-only sections that normally go in PROM must be above. + We construct the DATA image section in PROM at end of all these + read-only sections. The data image must be copied at init time. + Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */ + .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)} + { + ${RELOCATING+__data_section_start = .;} + ${RELOCATING+PROVIDE (__data_section_start = .);} + + ${RELOCATING+${DATA_START_SYMBOLS}} + ${RELOCATING+*(.sdata)} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.data1)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+CONSTRUCTORS} + + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + } ${RELOCATING+ > ${DATA_MEMORY}} + + ${RELOCATING+__data_section_size = SIZEOF(.data);} + ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));} + ${RELOCATING+__data_image_end = __data_image + __data_section_size;} + + ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}} + + /* .install ${RELOCATING-0}: + { + . = _data_image_end; + } ${RELOCATING+ > ${TEXT_MEMORY}} */ + + /* Relocation for some bss and data sections. */ + ${RELOCATING-${BSS_DATA_RELOC}} + ${RELOCATING-${SOFT_REGS_RELOC}} + + .bss ${RELOCATING-0} : + { + ${RELOCATING+__bss_start = .;} + ${RELOCATING+*(.sbss)} + ${RELOCATING+*(.scommon)} + + *(.dynbss) + *(.bss) + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.gnu.linkonce.b.*)} + *(COMMON) + ${RELOCATING+PROVIDE (_end = .);} + } ${RELOCATING+ > ${DATA_MEMORY}} + ${RELOCATING+__bss_size = SIZEOF(.bss);} + ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));} + + .eeprom ${RELOCATING-0} : + { + *(.eeprom) + *(.eeprom.*) + } ${RELOCATING+ > ${EEPROM_MEMORY}} + + ${RELOCATING+${VECTORS}} + + /* 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. + Treatment of DWARF debug section must be at end of the linker + script to avoid problems when there are undefined symbols. It's necessary + to avoid that the DWARF section is relocated before such undefined + symbols are found. */ + + /* 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) } +} +EOF diff --git a/ld/scripttempl/elfm68hc12.sc b/ld/scripttempl/elfm68hc12.sc new file mode 100644 index 000000000000..2fa7186c26fc --- /dev/null +++ b/ld/scripttempl/elfm68hc12.sc @@ -0,0 +1,460 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# EMBEDDED - whether this is for an embedded system. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test "$LD_FLAG" = "N" && DATA_ADDR=. + +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); } + ${CONSTRUCTING+${CTOR_START}} + KEEP (*(.ctors)) + + ${CONSTRUCTING+${CTOR_END}} + ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); } + } ${RELOCATING+ > ${TEXT_MEMORY}}" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); } + KEEP (*(.dtors)) + ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); } + } ${RELOCATING+ > ${TEXT_MEMORY}}" + + +VECTORS=" + /* If the 'vectors_addr' symbol is defined, it indicates the start address + of interrupt vectors. This depends on the 68HC11 operating mode: + + Addr + Single chip 0xffc0 + Extended mode 0xffc0 + Bootstrap 0x00c0 + Test 0xbfc0 + + In general, the vectors address is 0xffc0. This can be overriden + with the '-defsym vectors_addr=0xbfc0' ld option. + + Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but + they are redirected to 0x00c0 by the internal PROM. Application's vectors + must also consist of jump instructions (see Motorola's manual). */ + + PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0); + .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 : + { + KEEP (*(.vectors)) + }" + +# +# We provide two emulations: a fixed on that defines some memory banks +# and a configurable one that includes a user provided memory definition. +# +case $GENERIC_BOARD in + yes|1|YES) + MEMORY_DEF=" +/* Get memory banks definition from some user configuration file. + This file must be located in some linker directory (search path + with -L<dir>). See fixed memory banks emulation script. */ +INCLUDE memory.x; +" + ;; + *) +MEMORY_DEF=" +/* Fixed definition of the available memory banks. + See generic emulation script for a user defined configuration. */ +MEMORY +{ + page0 (rwx) : ORIGIN = 0x0, LENGTH = 256 + text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE} + data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE} + eeprom : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE} +} + +/* Setup the stack on the top of the data memory bank. */ +PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1); +" + ;; +esac + +STARTUP_CODE=" + /* Startup code. */ + KEEP (*(.install0)) /* Section should setup the stack pointer. */ + KEEP (*(.install1)) /* Place holder for applications. */ + KEEP (*(.install2)) /* Optional installation of data sections in RAM. */ + KEEP (*(.install3)) /* Place holder for applications. */ + KEEP (*(.install4)) /* Section that calls the main. */ +" + +FINISH_CODE=" + /* Finish code. */ + KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */ + KEEP (*(.fini1)) /* Place holder for applications. */ + KEEP (*(.fini2)) /* C++ destructors. */ + KEEP (*(.fini3)) /* Place holder for applications. */ + KEEP (*(.fini4)) /* Runtime exit. */ +" + +PRE_COMPUTE_DATA_SIZE=" +/* SCz: this does not work yet... This is supposed to force the loading + of _map_data.o (from libgcc.a) when the .data section is not empty. + By doing so, this should bring the code that copies the .data section + from ROM to RAM at init time. + + ___pre_comp_data_size = SIZEOF(.data); + __install_data_sections = ___pre_comp_data_size > 0 ? + __map_data_sections : 0; +*/ +" + +INSTALL_RELOC=" + .install0 0 : { *(.install0) } + .install1 0 : { *(.install1) } + .install2 0 : { *(.install2) } + .install3 0 : { *(.install3) } + .install4 0 : { *(.install4) } +" + +FINISH_RELOC=" + .fini0 0 : { *(.fini0) } + .fini1 0 : { *(.fini1) } + .fini2 0 : { *(.fini2) } + .fini3 0 : { *(.fini3) } + .fini4 0 : { *(.fini4) } +" + +BSS_DATA_RELOC=" + .data1 0 : { *(.data1) } + + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata 0 : { *(.sdata) } + .sbss 0 : { *(.sbss) } + .scommon 0 : { *(.scommon) } +" + +SOFT_REGS_RELOC=" + .softregs 0 : { *(.softregs) } +" + +cat <<EOF +${RELOCATING+/* Linker script for 68HC12 executable (PROM). */} +${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */} + +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${MEMORY_DEF}} + +SECTIONS +{ + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t.*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t.*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d.*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d.*)} + } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r.*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r.*)} + } + .rel.sdata ${RELOCATING-0} : + { + *(.rel.sdata) + ${RELOCATING+*(.rel.sdata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.s.*)} + } + .rela.sdata ${RELOCATING-0} : + { + *(.rela.sdata) + ${RELOCATING+*(.rela.sdata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.s.*)} + } + .rel.sbss ${RELOCATING-0} : + { + *(.rel.sbss) + ${RELOCATING+*(.rel.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rela.sbss ${RELOCATING-0} : + { + *(.rela.sbss) + ${RELOCATING+*(.rela.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rel.bss ${RELOCATING-0} : + { + *(.rel.bss) + ${RELOCATING+*(.rel.bss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.b.*)} + } + .rela.bss ${RELOCATING-0} : + { + *(.rela.bss) + ${RELOCATING+*(.rela.bss.*)} + ${RELOCATING+*(.rela.gnu.linkonce.b.*)} + } + .rel.stext ${RELOCATING-0} : { *(.rel.stest) } + .rela.stext ${RELOCATING-0} : { *(.rela.stest) } + .rel.etext ${RELOCATING-0} : { *(.rel.etest) } + .rela.etext ${RELOCATING-0} : { *(.rela.etest) } + .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } + .rel.edata ${RELOCATING-0} : { *(.rel.edata) } + .rela.edata ${RELOCATING-0} : { *(.rela.edata) } + .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) } + .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) } + .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) } + .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) } + .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) } + .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) } + .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) } + .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Concatenate .page0 sections. Put them in the page0 memory bank + unless we are creating a relocatable file. */ + .page0 : + { + *(.page0) + } ${RELOCATING+ > page0} + + /* Start of text section. */ + .stext ${RELOCATING-0} : + { + *(.stext) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .init ${RELOCATING-0} : + { + *(.init) + } ${RELOCATING+=${NOP-0}} + + ${RELOCATING-${INSTALL_RELOC}} + ${RELOCATING-${FINISH_RELOC}} + + .text ${RELOCATING-0}: + { + /* Put startup code at beginning so that _start keeps same address. */ + ${RELOCATING+${STARTUP_CODE}} + + ${RELOCATING+*(.init)} + *(.text) + ${RELOCATING+*(.text.*)} + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.gnu.linkonce.t.*)} + ${RELOCATING+*(.tramp)} + ${RELOCATING+*(.tramp.*)} + + ${RELOCATING+${FINISH_CODE}} + + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .eh_frame ${RELOCATING-0} : + { + KEEP (*(.eh_frame)) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .gcc_except_table ${RELOCATING-0} : + { + *(.gcc_except_table) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .rodata ${RELOCATING-0} : + { + *(.rodata) + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .rodata1 ${RELOCATING-0} : + { + *(.rodata1) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Constructor and destructor tables are in ROM. */ + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + + .jcr ${RELOCATING-0} : + { + KEEP (*(.jcr)) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Start of the data section image in ROM. */ + ${RELOCATING+__data_image = .;} + ${RELOCATING+PROVIDE (__data_image = .);} + + /* All read-only sections that normally go in PROM must be above. + We construct the DATA image section in PROM at end of all these + read-only sections. The data image must be copied at init time. + Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */ + .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)} + { + ${RELOCATING+__data_section_start = .;} + ${RELOCATING+PROVIDE (__data_section_start = .);} + + ${RELOCATING+${DATA_START_SYMBOLS}} + ${RELOCATING+*(.sdata)} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.data1)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+CONSTRUCTORS} + + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + } ${RELOCATING+ > ${DATA_MEMORY}} + + ${RELOCATING+__data_section_size = SIZEOF(.data);} + ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));} + ${RELOCATING+__data_image_end = __data_image + __data_section_size;} + + ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}} + + /* .install ${RELOCATING-0}: + { + . = _data_image_end; + } ${RELOCATING+ > ${TEXT_MEMORY}} */ + + /* Relocation for some bss and data sections. */ + ${RELOCATING-${BSS_DATA_RELOC}} + ${RELOCATING-${SOFT_REGS_RELOC}} + + .bss ${RELOCATING-0} : + { + ${RELOCATING+__bss_start = .;} + ${RELOCATING+*(.softregs)} + ${RELOCATING+*(.sbss)} + ${RELOCATING+*(.scommon)} + + *(.dynbss) + *(.bss) + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.gnu.linkonce.b.*)} + *(COMMON) + ${RELOCATING+PROVIDE (_end = .);} + } ${RELOCATING+ > ${DATA_MEMORY}} + ${RELOCATING+__bss_size = SIZEOF(.bss);} + ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));} + + .eeprom ${RELOCATING-0} : + { + *(.eeprom) + *(.eeprom.*) + } ${RELOCATING+ > ${EEPROM_MEMORY}} + + ${RELOCATING+${VECTORS}} + + /* 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. + Treatment of DWARF debug section must be at end of the linker + script to avoid problems when there are undefined symbols. It's necessary + to avoid that the DWARF section is relocated before such undefined + symbols are found. */ + + /* 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) } +} +EOF diff --git a/ld/scripttempl/elfxtensa.sc b/ld/scripttempl/elfxtensa.sc new file mode 100644 index 000000000000..f99d2ce0c433 --- /dev/null +++ b/ld/scripttempl/elfxtensa.sc @@ -0,0 +1,397 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not +# empty. +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# INITIAL_READONLY_SECTIONS - at start of text segment +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_TEXT_SECTIONS - these get put in .text when relocating +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_BSS_SECTIONS - other than .bss .sbss ... +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# STACK_ADDR - start of a .stack section. +# OTHER_END_SYMBOLS - symbols to place right at the end of the script. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# .debug_info .gnu.linkonce.wi.foo +# .tdata .gnu.linkonce.td.foo +# .tbss .gnu.linkonce.tb.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +test "$LD_FLAG" = "N" && DATA_ADDR=. +test -n "$CREATE_SHLIB" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" +test -z "$CREATE_SHLIB" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" +DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" +DATA_SEGMENT_END="" +if test -n "${COMMONPAGESIZE}"; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" +fi +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +INIT_LIT=".init.literal 0 : { *(.init.literal) }" +INIT=".init 0 : { *(.init) }" +FINI_LIT=".fini.literal 0 : { *(.fini.literal) }" +FINI=".fini 0 : { *(.fini) }" +if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__sbss_start = .);} + ${RELOCATING+PROVIDE (___sbss_start = .);} + *(.dynsbss) + *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) + *(.scommon) + ${RELOCATING+PROVIDE (__sbss_end = .);} + ${RELOCATING+PROVIDE (___sbss_end = .);} + }" + SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" + SDATA="/* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) + }" + SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }" + REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" + REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" + REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } + .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" + REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } + .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" +fi +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" +DTOR=".dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+_stack = .;} + *(.stack) + }" + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" +fi + +cat <<EOF +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + ${INITIAL_READONLY_SECTIONS} + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } + +EOF +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT=cat +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } + .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } + .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } + .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + ${REL_SDATA} + ${REL_SBSS} + ${REL_SDATA2} + ${REL_SBSS2} + .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } +EOF +if [ -n "$COMBRELOC" ]; then +cat <<EOF + .rel.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC +cat <<EOF + } + .rela.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC +cat <<EOF + } +EOF +fi +cat <<EOF + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} + + ${RELOCATING-$INIT_LIT} + ${RELOCATING-$INIT} + + .text ${RELOCATING-0} : + { + *(.got.plt* .plt*) + + ${RELOCATING+${INIT_START}} + ${RELOCATING+KEEP (*(.init.literal))} + ${RELOCATING+KEEP (*(.init))} + ${RELOCATING+${INIT_END}} + + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.literal .text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + + ${RELOCATING+${FINI_START}} + ${RELOCATING+KEEP (*(.fini.literal))} + ${RELOCATING+KEEP (*(.fini))} + ${RELOCATING+${FINI_END}} + } =${NOP-0} + + ${RELOCATING-$FINI_LIT} + ${RELOCATING-$FINI} + + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + ${WRITABLE_RODATA-${RODATA}} + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${OTHER_READONLY_SECTIONS} + .eh_frame_hdr : { *(.eh_frame_hdr) } + + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + + /* 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. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}} + .preinit_array ${RELOCATING-0} : { *(.preinit_array) } + ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}} + + ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}} + .init_array ${RELOCATING-0} : { *(.init_array) } + ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}} + + ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}} + .fini_array ${RELOCATING-0} : { *(.fini_array) } + ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } + .data1 ${RELOCATING-0} : { *(.data1) } + .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } + .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } + .eh_frame ${RELOCATING-0} : { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) } + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + .got ${RELOCATING-0} : { *(.got) } + ${OTHER_GOT_SECTIONS} + ${CREATE_SHLIB+${SDATA2}} + ${CREATE_SHLIB+${SBSS2}} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${SBSS} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss${RELOCATING+ .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. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } + ${OTHER_BSS_SECTIONS} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+_end = .;} + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+PROVIDE (end = .);} + ${RELOCATING+${DATA_SEGMENT_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) } + + ${STACK_ADDR+${STACK}} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_END_SYMBOLS}} +} +EOF diff --git a/ld/scripttempl/epocpe.sc b/ld/scripttempl/epocpe.sc new file mode 100644 index 000000000000..eda6696b59ab --- /dev/null +++ b/ld/scripttempl/epocpe.sc @@ -0,0 +1,151 @@ +# Linker script for PE. + +if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then + RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +fi + +# We can't easily and portably get an unquoted $ in a shell +# substitution, so we do this instead. +# Sorting of the .foo$* sections is required by the definition of +# grouped sections in PE. +# Sorting of the file names in R_IDATA is required by the +# current implementation of dlltool (this could probably be changed to +# use grouped sections instead). +if test "${RELOCATING}"; then + R_TEXT='*(SORT(.text$*))' + R_DATA='*(SORT(.data$*))' + R_RDATA='*(SORT(.rdata$*))' + R_IDATA=' + SORT(*)(.idata$2) + SORT(*)(.idata$3) + /* These zeroes mark the end of the import list. */ + LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); + SORT(*)(.idata$4) + SORT(*)(.idata$5) + SORT(*)(.idata$6) + SORT(*)(.idata$7)' + R_CRT='*(SORT(.CRT$*))' + R_RSRC='*(SORT(.rsrc$*))' +else + R_TEXT= + R_DATA= + R_RDATA= + R_IDATA= + R_CRT= + R_RSRC= +fi + +cat <<EOF +${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} +${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} + +${LIB_SEARCH_DIRS} + +ENTRY(_mainCRTStartup) + +SECTIONS +{ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ *(.init)} + *(.text) + ${R_TEXT} + *(.glue_7t) + *(.glue_7) + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); *(.ctors); *(.ctor); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); LONG (0); } + ${RELOCATING+ *(.fini)} + /* ??? Why is .gcc_exc here? */ + ${RELOCATING+ *(.gcc_exc)} + ${RELOCATING+ etext = .;} + *(.gcc_except_table) + + /* For EPOC the read only data is located at the end of the .text + section */ + *(.rdata) + ${R_RDATA} + *(.eh_frame) + } + + /* The Cygwin32 library uses a section to avoid copying certain data + on fork. This used to be named ".data$nocopy". The linker used + to include this between __data_start__ and __data_end__, but that + breaks building the cygwin32 dll. Instead, we name the section + ".data_cygwin_nocopy" and explictly include it after __data_end__. */ + + .data ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__data_start__ = . ;} + *(.data) + *(.data2) + ${R_DATA} + ${RELOCATING+__data_end__ = . ;} + ${RELOCATING+*(.data_cygwin_nocopy)} + } + + .bss ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__bss_start__ = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+__bss_end__ = . ;} + } + + .edata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.edata) + } + + /DISCARD/ : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${R_IDATA} + } + + .CRT ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${R_CRT} + } + + .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* end is deprecated, don't use it */ + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} + ${RELOCATING+ __end__ = .;} + } + + .reloc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.reloc) + } + + .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rsrc) + ${R_RSRC} + } + + .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + + .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } + +} +EOF diff --git a/ld/scripttempl/h8300.sc b/ld/scripttempl/h8300.sc new file mode 100644 index 000000000000..1fdf30c8fd55 --- /dev/null +++ b/ld/scripttempl/h8300.sc @@ -0,0 +1,94 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +ENTRY("_start") + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + ram : o = 0x0100, l = 0xfdfc + /* The stack starts at the top of main ram. */ + topram : o = 0xfefc, l = 0x4 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + SHORT (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.init : + { + *(.init) + } ${RELOCATING+ > ram} + +.text : + { + *(.rodata) + *(.text) + *(.text.*) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + *(.data.*) + *(.tiny) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8300h.sc b/ld/scripttempl/h8300h.sc new file mode 100644 index 000000000000..c2bc2e14baa2 --- /dev/null +++ b/ld/scripttempl/h8300h.sc @@ -0,0 +1,97 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300h) +ENTRY("_start") + +/* The memory size is 256KB to coincide with the simulator. + Don't change either without considering the other. */ + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + /* We still only use 256k as the main ram size. */ + ram : o = 0x0100, l = 0x3fefc + /* The stack starts at the top of main ram. */ + topram : o = 0x3fffc, l = 0x4 + /* This holds variables in the "tiny" sections. */ + tiny : o = 0xff8000, l = 0x7f00 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xffff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + LONG (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.tiny : + { + *(.tiny) + } ${RELOCATING+ > tiny} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8300hn.sc b/ld/scripttempl/h8300hn.sc new file mode 100644 index 000000000000..e2c295447858 --- /dev/null +++ b/ld/scripttempl/h8300hn.sc @@ -0,0 +1,87 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300hn) +ENTRY("_start") + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + ram : o = 0x0100, l = 0xfdfc + /* The stack starts at the top of main ram. */ + topram : o = 0xfefc, l = 0x4 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + SHORT (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + *(.tiny) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8300s.sc b/ld/scripttempl/h8300s.sc new file mode 100644 index 000000000000..53c9dec11c2c --- /dev/null +++ b/ld/scripttempl/h8300s.sc @@ -0,0 +1,97 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300s) +ENTRY("_start") + +/* The memory size is 256KB to coincide with the simulator. + Don't change either without considering the other. */ + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + /* We still only use 256k as the main ram size. */ + ram : o = 0x0100, l = 0x3fefc + /* The stack starts at the top of main ram. */ + topram : o = 0x3fffc, l = 0x4 + /* This holds variables in the "tiny" sections. */ + tiny : o = 0xff8000, l = 0x7f00 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xffff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + LONG (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.tiny : + { + *(.tiny) + } ${RELOCATING+ > tiny} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8300sn.sc b/ld/scripttempl/h8300sn.sc new file mode 100644 index 000000000000..b2647ca4058c --- /dev/null +++ b/ld/scripttempl/h8300sn.sc @@ -0,0 +1,87 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300sn) +ENTRY("_start") + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + ram : o = 0x0100, l = 0xfdfc + /* The stack starts at the top of main ram. */ + topram : o = 0xfefc, l = 0x4 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + SHORT (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + *(.tiny) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8300sx.sc b/ld/scripttempl/h8300sx.sc new file mode 100644 index 000000000000..d3807c0d0cd1 --- /dev/null +++ b/ld/scripttempl/h8300sx.sc @@ -0,0 +1,97 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300sx) +ENTRY("_start") + +/* The memory size is 256KB to coincide with the simulator. + Don't change either without considering the other. */ + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + /* We still only use 256k as the main ram size. */ + ram : o = 0x0100, l = 0x3fefc + /* The stack starts at the top of main ram. */ + topram : o = 0x3fffc, l = 0x4 + /* This holds variables in the "tiny" sections. */ + tiny : o = 0xff8000, l = 0x7f00 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xffff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + LONG (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.tiny : + { + *(.tiny) + } ${RELOCATING+ > tiny} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8300sxn.sc b/ld/scripttempl/h8300sxn.sc new file mode 100644 index 000000000000..0b1bcf1196f8 --- /dev/null +++ b/ld/scripttempl/h8300sxn.sc @@ -0,0 +1,87 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300sxn) +ENTRY("_start") + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + ram : o = 0x0100, l = 0xfdfc + /* The stack starts at the top of main ram. */ + topram : o = 0xfefc, l = 0x4 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + SHORT (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + *(.tiny) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8500.sc b/ld/scripttempl/h8500.sc new file mode 100644 index 000000000000..6b889ddcc774 --- /dev/null +++ b/ld/scripttempl/h8500.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Code and data 64k total */ + +SECTIONS +{ +.text ${RELOCATING+ 0x0000} : + { + *(.text) + ${RELOCATING+ _etext = . ; } + } + +.data ${RELOCATING+ . } : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } + +.rdata ${RELOCATING+ . } : + { + *(.rdata); + *(.strings) + + ${CONSTRUCTING+${TORS}} + } + +.bss ${RELOCATING+ . } : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } + +.stack ${RELOCATING+ 0xfff0} : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8500b.sc b/ld/scripttempl/h8500b.sc new file mode 100644 index 000000000000..fb6c0e86b6a3 --- /dev/null +++ b/ld/scripttempl/h8500b.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Code and data, both larger than 64k */ + +SECTIONS +{ +.text ${RELOCATING+ 0x10000} : + { + *(.text) + ${RELOCATING+ _etext = . ; } + } + +.data ${RELOCATING+ 0x20000} : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } + +.rdata ${RELOCATING+ 0x30000} : + { + *(.rdata); + *(.strings) + + ${CONSTRUCTING+${TORS}} + } + +.bss ${RELOCATING+ 0x40000} : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } + +.stack ${RELOCATING+ 0x50000} : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8500c.sc b/ld/scripttempl/h8500c.sc new file mode 100644 index 000000000000..145ffc5c3295 --- /dev/null +++ b/ld/scripttempl/h8500c.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Compact model - code < 64k, data > 64k */ + +SECTIONS +{ +.text 0x10000 : + { + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +.data 0x20000 : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.rdata 0x30000 : + { + *(.rdata); + + ${CONSTRUCTING+${TORS}} + } ${RELOCATING+ > ram} + +.bss 0x40000 : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack 0x5fff0 : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8500m.sc b/ld/scripttempl/h8500m.sc new file mode 100644 index 000000000000..3314066ed63b --- /dev/null +++ b/ld/scripttempl/h8500m.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Code and data, both larger than 64k */ + +SECTIONS +{ +.text ${RELOCATING+ 0x10000} : + { + *(.text) + ${RELOCATING+ _etext = . ; } + } + +.data ${RELOCATING+ 0x20000} : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } + +.rdata ${RELOCATING+ . } : + { + *(.rdata); + *(.strings) + + ${CONSTRUCTING+${TORS}} + } + +.bss ${RELOCATING+ . } : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } + +.stack ${RELOCATING+ 0x2fff0} : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/h8500s.sc b/ld/scripttempl/h8500s.sc new file mode 100644 index 000000000000..da4d2101b18c --- /dev/null +++ b/ld/scripttempl/h8500s.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Code and data, both 64k */ + +SECTIONS +{ +.text ${RELOCATING+ 0x10000} : + { + *(.text) + ${RELOCATING+ _etext = . ; } + } + +.rdata ${RELOCATING+ 0x20000} : + { + *(.rdata); + *(.strings) + + ${CONSTRUCTING+${TORS}} + } + +.data ${RELOCATING+ . } : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } + +.bss ${RELOCATING+ .} : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } + +.stack ${RELOCATING+ 0x2fff0} : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/hppaelf.sc b/ld/scripttempl/hppaelf.sc new file mode 100644 index 000000000000..941ce08998c6 --- /dev/null +++ b/ld/scripttempl/hppaelf.sc @@ -0,0 +1,38 @@ +DATA_ADDR=0x40000000 +test "$LD_FLAG" = "N" && DATA_ADDR=. +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +ENTRY("\$START\$") +${RELOCATING+${LIB_SEARCH_DIRS}} +SECTIONS +{ + .text 0x1000 ${RELOCATING++${TEXT_START_ADDR}}: + { + ${RELOCATING+__text_start = .}; + CREATE_OBJECT_SYMBOLS + *(.PARISC.stubs) + *(.text) + ${RELOCATING+etext = .}; + ${RELOCATING+_etext = .}; + } + ${RELOCATING+. = ${DATA_ADDR};} + .data : + { + ${RELOCATING+ . = . + 0x1000 }; + ${RELOCATING+__data_start = .}; + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+edata = .}; + ${RELOCATING+_edata = .}; + } + ${RELOCATING+. = ${DATA_ADDR} + SIZEOF(.data);} + .bss : + { + *(.bss) + *(COMMON) + ${RELOCATING+end = . }; + ${RELOCATING+_end = . }; + } +} +EOF diff --git a/ld/scripttempl/i386beos.sc b/ld/scripttempl/i386beos.sc new file mode 100644 index 000000000000..21a01e56cdc1 --- /dev/null +++ b/ld/scripttempl/i386beos.sc @@ -0,0 +1,194 @@ +# Linker script for PE. + +if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then + RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +fi + +# We can't easily and portably get an unquoted $ in a shell +# substitution, so we do this instead. +if test "${RELOCATING}"; then + R_TEXT='*(.text$*)' + R_DATA='*(.data$*)' + R_RDATA='*(.rdata$*)' + R_IDATA=' + *(.idata$2) + *(.idata$3) + /* These zeroes mark the end of the import list. */ + LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); + *(.idata$4) + *(.idata$5) + *(.idata$6) + *(.idata$7)' + R_CRT='*(.CRT$*)' + R_RSRC='*(.rsrc$*)' + R_EXC='*(.exc$*)' +else + R_TEXT= + R_DATA= + R_RDATA= + R_IDATA= + R_CRT= + R_RSRC= + R_EXC= +fi + +cat <<EOF +${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} +${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} + +${LIB_SEARCH_DIRS} + +ENTRY(__start) +${RELOCATING+header = .;} +${RELOCATING+__fltused = .; /* set up floating pt for MS .obj\'s */} +${RELOCATING+__ldused = .;} +SECTIONS +{ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ __text_start__ = . ;} + ${RELOCATING+ *(.init)} + *(.text) + ${R_TEXT} + *(.glue_7t) + *(.glue_7) + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); *(.ctors); *(.ctor); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); LONG (0); } + ${RELOCATING+ *(.fini)} + /* ??? Why is .gcc_exc here? */ + ${RELOCATING+ *(.gcc_exc)} + ${RELOCATING+ etext = .;} + ${RELOCATING+ __text_end__ = .;} + *(.gcc_except_table) + } + + /* The Cygwin32 library uses a section to avoid copying certain data + on fork. This used to be named ".data$nocopy". The linker used + to include this between __data_start__ and __data_end__, but that + breaks building the cygwin32 dll. Instead, we name the section + ".data_cygwin_nocopy" and explictly include it after __data_end__. */ + + .data ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__data_start__ = . ;} + *(.data) + *(.data2) + ${R_DATA} + ${RELOCATING+__data_end__ = . ;} + ${RELOCATING+*(.data_cygwin_nocopy)} + } + + .bss ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__bss_start__ = . ;} + *(.bss) + *(COMMON) + /* link.exe apparently pulls in .obj's because of UNDEF common + symbols, which is not the coff way, but that's MS for you. */ + *(.CRT\$XCA) + *(.CRT\$XCZ) + *(.CRT\$XIA) + *(.CRT\$XIZ) + ${RELOCATING+__bss_end__ = . ;} + } + + .rdata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rdata) + ${R_RDATA} + *(.eh_frame) + } + + .edata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.edata) + } + + /DISCARD/ : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + *(.debug*) + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${R_IDATA} + } + .CRT ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${R_CRT} + } + + .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* end is deprecated, don't use it */ + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} + ${RELOCATING+ __end__ = .;} + } + + .reloc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.reloc) + } + + .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rsrc) + ${R_RSRC} + } + + .exc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.exc) + ${R_EXC} + } + + .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + + .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } + /* 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 ${RELOCATING+(NOLOAD)} : { *(.debug) } + .line 0 ${RELOCATING+(NOLOAD)} : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 ${RELOCATING+(NOLOAD)} : { *(.debug_srcinfo) } + .debug_sfnames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 ${RELOCATING+(NOLOAD)} : { *(.debug_aranges) } + .debug_pubnames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 ${RELOCATING+(NOLOAD)} : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_abbrev 0 ${RELOCATING+(NOLOAD)} : { *(.debug_abbrev) } + .debug_line 0 ${RELOCATING+(NOLOAD)} : { *(.debug_line) } + .debug_frame 0 ${RELOCATING+(NOLOAD)} : { *(.debug_frame) } + .debug_str 0 ${RELOCATING+(NOLOAD)} : { *(.debug_str) } + .debug_loc 0 ${RELOCATING+(NOLOAD)} : { *(.debug_loc) } + .debug_macinfo 0 ${RELOCATING+(NOLOAD)} : { *(.debug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_weaknames) } + .debug_funcnames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_funcnames) } + .debug_typenames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_typenames) } + .debug_varnames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_varnames) } +} +EOF diff --git a/ld/scripttempl/i386go32.sc b/ld/scripttempl/i386go32.sc new file mode 100644 index 000000000000..54908fe110df --- /dev/null +++ b/ld/scripttempl/i386go32.sc @@ -0,0 +1,79 @@ +# Linker script for i386 go32 (DJGPP) + +test -z "$ENTRY" && ENTRY=start +EXE=${CONSTRUCTING+${RELOCATING+-exe}} + +# These are substituted in as variables in order to get '}' in a shell +# conditional expansion. +CTOR='.ctor : { + *(SORT(.ctors.*)) + *(.ctor) + }' +DTOR='.dtor : { + *(SORT(.dtors.*)) + *(.dtor) + }' + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}${EXE}") + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ ${TARGET_PAGE_SIZE}+SIZEOF_HEADERS} : { + *(.text) + ${RELOCATING+*(.text.*)} + ${RELOCATING+*(.gnu.linkonce.t*)} + *(.const*) + *(.ro*) + ${RELOCATING+*(.gnu.linkonce.r*)} + ${RELOCATING+etext = . ; PROVIDE(_etext = .) ;} + ${RELOCATING+. = ALIGN(${SEGMENT_SIZE});} + } + .data ${RELOCATING+ ${DATA_ALIGNMENT}} : { + ${RELOCATING+djgpp_first_ctor = . ; + *(SORT(.ctors.*)) + *(.ctor) + djgpp_last_ctor = . ;} + ${RELOCATING+djgpp_first_dtor = . ; + *(SORT(.dtors.*)) + *(.dtor) + djgpp_last_dtor = . ;} + *(.data) + ${RELOCATING+*(.data.*)} + + ${RELOCATING+*(.gcc_exc*)} + ${RELOCATING+___EH_FRAME_BEGIN__ = . ;} + ${RELOCATING+*(.eh_fram*)} + ${RELOCATING+___EH_FRAME_END__ = . ;} + ${RELOCATING+LONG(0);} + + ${RELOCATING+*(.gnu.linkonce.d*)} + ${RELOCATING+edata = . ; PROVIDE(_edata = .) ;} + ${RELOCATING+. = ALIGN(${SEGMENT_SIZE});} + } + ${CONSTRUCTING+${RELOCATING-$CTOR}} + ${CONSTRUCTING+${RELOCATING-$DTOR}} + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + *(COMMON) + ${RELOCATING+ end = . ; PROVIDE(_end = .) ;} + ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});} + } + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .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) } +} +EOF diff --git a/ld/scripttempl/i386lynx.sc b/ld/scripttempl/i386lynx.sc new file mode 100644 index 000000000000..16b72a43c75b --- /dev/null +++ b/ld/scripttempl/i386lynx.sc @@ -0,0 +1,46 @@ +test -z "$ENTRY" && ENTRY=_start +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ SIZEOF_HEADERS} : { + *(.init) + *(.text) + ${RELOCATING+ etext = .;} + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + *(.fini) + ${RELOCATING+ etext = .}; + } + .data ${RELOCATING+ 0x400000 + (. & 0xffc00fff)} : { + *(.data) + ${RELOCATING+ edata = .}; + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss) + *(COMMON) + ${RELOCATING+ end = .}; + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/i386msdos.sc b/ld/scripttempl/i386msdos.sc new file mode 100644 index 000000000000..4d312e7ff925 --- /dev/null +++ b/ld/scripttempl/i386msdos.sc @@ -0,0 +1,38 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${STACKZERO+${RELOCATING+${STACKZERO}}} +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : + { + CREATE_OBJECT_SYMBOLS + *(.text) + ${RELOCATING+etext = .;} + ${RELOCATING+_etext = .;} + ${RELOCATING+__etext = .;} + } + .data : + { + *(.rodata) + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+edata = .;} + ${RELOCATING+_edata = .;} + ${RELOCATING+__edata = .;} + } + .bss : + { + ${RELOCATING+ _bss_start = .}; + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+end = ALIGN(4) }; + ${RELOCATING+_end = ALIGN(4) }; + ${RELOCATING+__end = ALIGN(4) }; + } +} +EOF diff --git a/ld/scripttempl/i860coff.sc b/ld/scripttempl/i860coff.sc new file mode 100644 index 000000000000..f268c6f9060d --- /dev/null +++ b/ld/scripttempl/i860coff.sc @@ -0,0 +1,42 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} +PROVIDE (__stack = 0); +SECTIONS +{ + .text ${RELOCATING+ 0x1000000} : { + *(.text) + ${CONSTRUCTING+ . = ALIGN(4);} + ${RELOCATING+ etext = .;} + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + } + .data : { + *(.data) + ${RELOCATING+ edata = .}; + } + .bss : { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+ end = ALIGN(0x8)}; + ${RELOCATING+ _end = ALIGN(0x8)}; + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/i960.sc b/ld/scripttempl/i960.sc new file mode 100644 index 000000000000..dc335555d7d7 --- /dev/null +++ b/ld/scripttempl/i960.sc @@ -0,0 +1,25 @@ +cat <<EOF +SECTIONS +{ + .text : + { + ${GLD_STYLE+ CREATE_OBJECT_SYMBOLS} + *(.text) + ${RELOCATING+ _etext = .}; + ${CONSTRUCTING+${COFF_CTORS}} + } + .data : + { + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+ _edata = .}; + } + .bss : + { + ${RELOCATING+ _bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+ _end = .}; + } +} +EOF diff --git a/ld/scripttempl/ip2k.sc b/ld/scripttempl/ip2k.sc new file mode 100644 index 000000000000..d7826cafcaac --- /dev/null +++ b/ld/scripttempl/ip2k.sc @@ -0,0 +1,150 @@ +cat << EOF +OUTPUT_FORMAT("elf32-ip2k", "elf32-ip2k", "elf32-ip2k") +OUTPUT_ARCH(ip2k) +ENTRY(_start) +SEARCH_DIR(.); + +/* IP2022 default linker script. */ + +MEMORY +{ + D_GPR : org = 0x01000080, len = 128 + D_RAM : org = 0x01000100, len = 4K - 256 + P_RAM : org = 0x02000000, len = 16K + P_ROM : org = 0x02010000, len = 64K - 32 + P_RESET : org = 0x0201FFE0, len = 32 + P_CONFIG : org = 0x02020000, len = 128 +} + +SECTIONS +{ + /* Allocated memory end markers + (initialized to start of appropiate memory address). */ + __data_end = 0x01000100; + __pram_end = 0x02000000; + __flash_end = 0x02010000; + + /* Global general purpose registers in direct addressing range. */ + .gpr 0x01000080 : + { + *(.gpr) + } >D_GPR + + /* Pre-allocated, pre-initialized data memory. */ + __data_run_begin = __data_end; + __data_load_begin = (__flash_end + 1) & 0xFFFFFFFE; + .data __data_run_begin : AT (__data_load_begin) + { + * (.data); + * (.rodata) + } >D_RAM + __data_run_end = __data_run_begin + SIZEOF(.data); + __data_load_end = __data_load_begin + SIZEOF(.data); + __data_end = __data_run_end; + __flash_end = __data_load_end; + + /* Pre-allocated, uninitialized data memory. */ + __bss_begin = __data_end; + .bss __bss_begin : + { + * (.bss) + } >D_RAM + __bss_end = __bss_begin + SIZEOF(.bss); + __data_end = __bss_end; + + /* Pre-allocated PRAM data memory. */ + __pram_data_begin = (__pram_end + 1) & 0xFFFFFFFE; + .pram_data __pram_data_begin : + { + * (.pram_data) + } >P_RAM + __pram_data_end = __pram_data_begin + SIZEOF(.pram_data); + __pram_end = __pram_data_end; + + /* PRAM code. */ + __pram_run_begin = (__pram_end + 1) & 0xFFFFFFFE; + __pram_load_begin = (__flash_end + 1) & 0xFFFFFFFE; + .pram __pram_run_begin : AT (__pram_load_begin) + { + * (.pram) + } >P_RAM + __pram_run_end = __pram_run_begin + SIZEOF(.pram); + __pram_load_end = __pram_load_begin + SIZEOF(.pram); + + __pram_load_shift = ((__pram_run_begin - __pram_load_begin) & 0x1FFFF) | 0x02000000; + __pram_end = __pram_run_end; + __flash_end = __pram_load_end; + + /* PRAM overlay code. */ + __pram_overlay_run_start = (__pram_end + 1) & 0xFFFFFFFE; + __pram_overlay_load_start = (__flash_end + 1) & 0xFFFFFFFE; + OVERLAY __pram_overlay_run_start : AT (__pram_overlay_load_start) + { + .pram1 { */overlay1/* (.pram); * (.pram1) } + .pram2 { */overlay2/* (.pram); * (.pram2) } + } >P_RAM + __pram_overlay_run_end = .; + __pram_overlay_load_end = __pram_overlay_load_start + SIZEOF(.pram1) + SIZEOF(.pram2); + __pram_end = __pram_overlay_run_end; + __flash_end = __pram_overlay_load_end; + + /* Flash code. */ + __text_begin = (__flash_end + 1) & 0xFFFFFFFE; + .text __text_begin : + { + * (.text); + * (.text.libgcc) + } >P_ROM = 0xffff + __text_end = __text_begin + SIZEOF(.text); + __flash_end = __text_end; + + /* Strings. */ + __strings_begin = (__flash_end + 1) & 0xFFFFFFFE; + .strings __strings_begin : + { + * (strings); + * (.progmem.data) + } >P_ROM = 0xffff + __strings_end = __strings_begin + SIZEOF (.strings); + __flash_end = __strings_end; + + .ctors : { * (.ctors) } > P_ROM + .dtors : { * (.dtors) } > P_ROM + + /* Reset code. */ + .reset : { * (.reset) } >P_RESET = 0xffff + + /* Configuration block. */ + .config : { * (.config) } >P_CONFIG = 0xffff + + /* Stack. */ + PROVIDE (__stack = 0x01000FFF); + + /* 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 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) } +} +EOF diff --git a/ld/scripttempl/iq2000.sc b/ld/scripttempl/iq2000.sc new file mode 100644 index 000000000000..db3a597ddbb4 --- /dev/null +++ b/ld/scripttempl/iq2000.sc @@ -0,0 +1,443 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# INITIAL_READONLY_SECTIONS - at start of data segment +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_TEXT_SECTIONS - these get put in .text when relocating +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_BSS_SECTIONS - other than .bss .sbss ... +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# BSS_PLT - .plt should be in bss segment +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }" +SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} }" +SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} }" +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" +fi + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +SECTIONS +{ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + ${TEXT_DYNAMIC+${DYNAMIC}} + +EOF +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT=cat +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t.*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t.*)} + } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r.*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r.*)} + } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d.*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d.*)} + } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + .rel.sdata ${RELOCATING-0} : + { + *(.rel.sdata) + ${RELOCATING+*(.rel.sdata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.s.*)} + } + .rela.sdata ${RELOCATING-0} : + { + *(.rela.sdata) + ${RELOCATING+*(.rela.sdata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.s.*)} + } + .rel.sbss ${RELOCATING-0} : + { + *(.rel.sbss) + ${RELOCATING+*(.rel.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rela.sbss ${RELOCATING-0} : + { + *(.rela.sbss) + ${RELOCATING+*(.rela.sbss.*)} + ${RELOCATING+*(.rela.gnu.linkonce.sb.*)} + } + .rel.sdata2 ${RELOCATING-0} : + { + *(.rel.sdata2) + ${RELOCATING+*(.rel.sdata2.*)} + ${RELOCATING+*(.rel.gnu.linkonce.s2.*)} + } + .rela.sdata2 ${RELOCATING-0} : + { + *(.rela.sdata2) + ${RELOCATING+*(.rela.sdata2.*)} + ${RELOCATING+*(.rela.gnu.linkonce.s2.*)} + } + .rel.sbss2 ${RELOCATING-0} : + { + *(.rel.sbss2) + ${RELOCATING+*(.rel.sbss2.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb2.*)} + } + .rela.sbss2 ${RELOCATING-0} : + { + *(.rela.sbss2) + ${RELOCATING+*(.rela.sbss2.*)} + ${RELOCATING+*(.rela.gnu.linkonce.sb2.*)} + } + .rel.bss ${RELOCATING-0} : + { + *(.rel.bss) + ${RELOCATING+*(.rel.bss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.b.*)} + } + .rela.bss ${RELOCATING-0} : + { + *(.rela.bss) + ${RELOCATING+*(.rela.bss.*)} + ${RELOCATING+*(.rela.gnu.linkonce.b.*)} + } +EOF +if [ -n "$COMBRELOC" ]; then +cat <<EOF + .rel.dyn : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC +cat <<EOF + } + .rela.dyn : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC +cat <<EOF + } +EOF +fi +cat <<EOF + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} + + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } =${NOP-0} + + ${DATA_PLT-${BSS_PLT-${PLT}}} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text) + ${RELOCATING+*(.text.*)} + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.gnu.linkonce.t.*)} + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } + .data1 ${RELOCATING-0} : { *(.data1) } + .eh_frame ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__eh_frame_begin = .);} + *(.eh_frame) + LONG (0); + ${RELOCATING+PROVIDE (__eh_frame_end = .);} + } ${RELOCATING+} + .gcc_except_table : { *(.gcc_except_table) } + ${INITIAL_READONLY_SECTIONS} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + ${RODATA} + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${RELOCATING+${OTHER_READONLY_SECTIONS}} + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + .jcr : { KEEP (*(.jcr)) } + ${DATA_PLT+${PLT}} + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + ${RELOCATING+${OTHER_GOT_SECTIONS}} + ${CREATE_SHLIB+${SDATA2}} + ${CREATE_SHLIB+${SBSS2}} + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + *(.sdata) + ${RELOCATING+*(.sdata.*)} + ${RELOCATING+*(.gnu.linkonce.s.*)} + } + ${RELOCATING+${OTHER_SDATA_SECTIONS}} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .sbss ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__sbss_start = .);} + ${RELOCATING+PROVIDE (___sbss_start = .);} + *(.dynsbss) + *(.sbss) + ${RELOCATING+*(.sbss.*)} + ${RELOCATING+*(.gnu.linkonce.sb.*)} + *(.scommon) + ${RELOCATING+PROVIDE (__sbss_end = .);} + ${RELOCATING+PROVIDE (___sbss_end = .);} + } + ${BSS_PLT+${PLT}} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.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. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } + ${RELOCATING+${OTHER_BSS_SECTIONS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+_end = .;} + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+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) } + + ${RELOCATING+${OTHER_RELOCATING_SECTIONS}} + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF diff --git a/ld/scripttempl/m68kaux.sc b/ld/scripttempl/m68kaux.sc new file mode 100644 index 000000000000..404280e1272c --- /dev/null +++ b/ld/scripttempl/m68kaux.sc @@ -0,0 +1,46 @@ +# Linker script for A/UX. +test -z "$ENTRY" && ENTRY=_start +INIT='.init : { *(.init) }' +FINI='.fini : { *(.fini) }' +CTORS='.ctors : { *(.ctors) }' +DTORS='.dtors : { *(.dtors) }' + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ $TEXT_START_ADDR} : { + ${RELOCATING+ *(.init)} + ${RELOCATING+ *(.fini)} + *(.text) + ${RELOCATING+ . = ALIGN(4);} + ${RELOCATING+ *(.ctors)} + ${RELOCATING+ *(.dtors)} + ${RELOCATING+ etext = .;} + ${RELOCATING+ _etext = .;} + } =0x4E714E71 + .data ${RELOCATING+ $DATA_ALIGNMENT} : { + *(.data) + ${RELOCATING+ edata = .;} + ${RELOCATING+ _edata = .;} + } + .bss : { + *(.bss) + *(COMMON) + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} + } + ${RELOCATING- ${INIT}} + ${RELOCATING- ${FINI}} + ${RELOCATING- ${CTORS}} + ${RELOCATING- ${DTORS}} + + .comment 0 ${RELOCATING+(NOLOAD)} : { [ .comment ] [ .ident ] } + .stab 0 ${RELOCATING+(NOLOAD)} : { [ .stab ] } + .stabstr 0 ${RELOCATING+(NOLOAD)} : { [ .stabstr ] } +} +EOF diff --git a/ld/scripttempl/m68kcoff.sc b/ld/scripttempl/m68kcoff.sc new file mode 100644 index 000000000000..f268c6f9060d --- /dev/null +++ b/ld/scripttempl/m68kcoff.sc @@ -0,0 +1,42 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} +PROVIDE (__stack = 0); +SECTIONS +{ + .text ${RELOCATING+ 0x1000000} : { + *(.text) + ${CONSTRUCTING+ . = ALIGN(4);} + ${RELOCATING+ etext = .;} + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + } + .data : { + *(.data) + ${RELOCATING+ edata = .}; + } + .bss : { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+ end = ALIGN(0x8)}; + ${RELOCATING+ _end = ALIGN(0x8)}; + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/m68klynx.sc b/ld/scripttempl/m68klynx.sc new file mode 100644 index 000000000000..81d2245885ac --- /dev/null +++ b/ld/scripttempl/m68klynx.sc @@ -0,0 +1,46 @@ +test -z "$ENTRY" && ENTRY=_start +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ SIZEOF_HEADERS} : { + *(.init) + *(.text) + ${RELOCATING+ etext = .;} + ${CONSTRUCTING+ ___CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___CTOR_END__ - ___CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ ___CTOR_END__ = .;} + ${CONSTRUCTING+ ___DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___DTOR_END__ - ___DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ ___DTOR_END__ = .;} + *(.fini) + ${RELOCATING+ etext = .}; + } + .data ${RELOCATING+ 0x400000 + (. & 0xffc00fff)} : { + *(.data .data2) + ${RELOCATING+ edata = .}; + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss) + *(COMMON) + ${RELOCATING+ end = .}; + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/m88kbcs.sc b/ld/scripttempl/m88kbcs.sc new file mode 100644 index 000000000000..f52b14dc0ce3 --- /dev/null +++ b/ld/scripttempl/m88kbcs.sc @@ -0,0 +1,49 @@ +# These are substituted in as variables in order to get '}' in a shell +# conditional expansion. +INIT='.init : { *(.init) }' +FINI='.fini : { *(.fini) }' +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +ENTRY(__start) +${RELOCATING+${LIB_SEARCH_DIRS}} + +SECTIONS +{ + .text ${RELOCATING+ (0x20007 + SIZEOF_HEADERS) &~ 7} : + { + ${RELOCATING+ __.text.start = .}; + ${RELOCATING+ __.init.start = .}; + ${RELOCATING+ *(.init)} + ${RELOCATING+ __.init.end = .}; + *(.text) + ${RELOCATING+ __.tdesc_start = .}; + ${RELOCATING+ *(.tdesc)} + ${RELOCATING+ __.text_end = .} ; + ${RELOCATING+ __.initp.start = .}; + ${RELOCATING+ __.initp.end = .}; + ${RELOCATING+ __.fini_start = .}; + ${RELOCATING+ *(.fini) } + ${RELOCATING+ __.fini_end = .}; + ${RELOCATING+_etext = .}; + } + .data ${RELOCATING+ NEXT (0x400000) + ((SIZEOF(.text) + ADDR(.text)) % 0x2000)} : + { + *(.data) + ${RELOCATING+_edata = .}; + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss) + *(COMMON) + ${RELOCATING+ _end = .}; + ${RELOCATING+ __end = .}; + } + ${RELOCATING- ${INIT}} + ${RELOCATING- ${FINI}} + .comment 0 ${RELOCATING+(NOLOAD)} : + { + *(.comment) + } +} +EOF diff --git a/ld/scripttempl/mcorepe.sc b/ld/scripttempl/mcorepe.sc new file mode 100644 index 000000000000..6f928aadd2d5 --- /dev/null +++ b/ld/scripttempl/mcorepe.sc @@ -0,0 +1,162 @@ +# Linker script for MCore PE. + +if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then + RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +fi + +# We can't easily and portably get an unquoted $ in a shell +# substitution, so we do this instead. +# Sorting of the .foo$* sections is required by the definition of +# grouped sections in PE. +# Sorting of the file names in R_IDATA is required by the +# current implementation of dlltool (this could probably be changed to +# use grouped sections instead). +if test "${RELOCATING}"; then + R_TEXT='*(SORT(.text$*))' + R_DATA='*(SORT(.data$*))' + R_RDATA='*(SORT(.rdata$*))' + R_IDATA=' + SORT(*)(.idata$2) + SORT(*)(.idata$3) + /* These zeroes mark the end of the import list. */ + LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); + SORT(*)(.idata$4) + SORT(*)(.idata$5) + SORT(*)(.idata$6) + SORT(*)(.idata$7)' + R_CRT='*(SORT(.CRT$*))' + R_RSRC='*(SORT(.rsrc$*))' +else + R_TEXT= + R_DATA= + R_RDATA= + R_IDATA= + R_CRT= + R_RSRC= +fi + +if test "$RELOCATING"; then + # Can't use ${RELOCATING+blah "blah" blah} for this, + # because bash 2.x will lose the doublequotes. + cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +EOF +fi + +cat <<EOF +${LIB_SEARCH_DIRS} + +ENTRY(_mainCRTStartup) + +SECTIONS +{ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ *(.init)} + *(.text) + ${R_TEXT} + *(.glue_7t) + *(.glue_7) + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); *(.ctors); *(.ctor); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); LONG (0); } + ${RELOCATING+ *(.fini)} + /* ??? Why is .gcc_exc here? */ + ${RELOCATING+ *(.gcc_exc)} + ${RELOCATING+ etext = .;} + *(.gcc_except_table) + } + + /* The Cygwin32 library uses a section to avoid copying certain data + on fork. This used to be named ".data$nocopy". The linker used + to include this between __data_start__ and __data_end__, but that + breaks building the cygwin32 dll. Instead, we name the section + ".data_cygwin_nocopy" and explictly include it after __data_end__. */ + + .data ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__data_start__ = . ;} + *(.data) + *(.data2) + ${R_DATA} + ${RELOCATING+__data_end__ = . ;} + ${RELOCATING+*(.data_cygwin_nocopy)} + } + + .bss ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__bss_start__ = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+__bss_end__ = . ;} + } + + .rdata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rdata) + ${R_RDATA} + *(.eh_frame) + } + + .edata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.edata) + } + + /DISCARD/ : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${R_IDATA} + } + .CRT ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${R_CRT} + } + + .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* end is deprecated, don't use it */ + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} + ${RELOCATING+ __end__ = .;} + } + + .reloc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.reloc) + } + + .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rsrc) + ${R_RSRC} + } + + .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + + .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } + + .stack 0x80000 : + { + _stack = .; + *(.stack) + } +} +EOF diff --git a/ld/scripttempl/mmo.sc b/ld/scripttempl/mmo.sc new file mode 100644 index 000000000000..643b349539e3 --- /dev/null +++ b/ld/scripttempl/mmo.sc @@ -0,0 +1,131 @@ +cat <<EOF +OUTPUT_FORMAT("mmo") +OUTPUT_ARCH(mmix) +ENTRY(Main) +SECTIONS +{ + .text ${RELOCATING+ ${TEXT_START_ADDR}}: + { + *(.text) + ${RELOCATING+*(.text.*)} + ${RELOCATING+*(.gnu.linkonce.t*)} + ${RELOCATING+*(.rodata)} + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + + /* FIXME: Move .init, .fini, .ctors and .dtors to their own sections. */ + ${RELOCATING+ PROVIDE (_init_start = .);} + ${RELOCATING+ PROVIDE (_init = .);} + ${RELOCATING+ KEEP (*(.init))} + ${RELOCATING+ PROVIDE (_init_end = .);} + + ${RELOCATING+ PROVIDE (_fini_start = .);} + ${RELOCATING+ PROVIDE (_fini = .);} + ${RELOCATING+ KEEP (*(.fini))} + ${RELOCATING+ PROVIDE (_fini_end = .);} + + /* FIXME: Align ctors, dtors, ehframe. */ + ${RELOCATING+ PROVIDE (_ctors_start = .);} + ${RELOCATING+ PROVIDE (__ctors_start = .);} + ${RELOCATING+ PROVIDE (_ctors = .);} + ${RELOCATING+ PROVIDE (__ctors = .);} + ${RELOCATING+ KEEP (*crtbegin*.o(.ctors))} + ${RELOCATING+ KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors))} + ${RELOCATING+ KEEP (*(SORT(.ctors.*)))} + ${RELOCATING+ KEEP (*(.ctors))} + ${RELOCATING+ PROVIDE (_ctors_end = .);} + ${RELOCATING+ PROVIDE (__ctors_end = .);} + + ${RELOCATING+ PROVIDE (_dtors_start = .);} + ${RELOCATING+ PROVIDE (__dtors_start = .);} + ${RELOCATING+ PROVIDE (_dtors = .);} + ${RELOCATING+ PROVIDE (__dtors = .);} + ${RELOCATING+ KEEP (*crtbegin*.o(.dtors))} + ${RELOCATING+ KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))} + ${RELOCATING+ KEEP (*(SORT(.dtors.*)))} + ${RELOCATING+ KEEP (*(.dtors))} + ${RELOCATING+ PROVIDE (_dtors_end = .);} + ${RELOCATING+ PROVIDE (__dtors_end = .);} + + ${RELOCATING+KEEP (*(.jcr))} + ${RELOCATING+KEEP (*(.eh_frame))} + ${RELOCATING+*(.gcc_except_table)} + + ${RELOCATING+ PROVIDE(etext = .);} + ${RELOCATING+ PROVIDE(_etext = .);} + ${RELOCATING+ PROVIDE(__etext = .);} + } + ${RELOCATING+Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : ADDR (.text));} + + .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) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .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) } + .debug_ranges 0 : { *(.debug_ranges) } + + .data ${RELOCATING+ ${DATA_ADDR}}: + { + ${RELOCATING+ PROVIDE(__Sdata = .);} + + *(.data); + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d*)} + + ${RELOCATING+ PROVIDE(__Edata = .);} + + /* Deprecated, use __Edata. */ + ${RELOCATING+ PROVIDE(edata = .);} + ${RELOCATING+ PROVIDE(_edata = .);} + ${RELOCATING+ PROVIDE(__edata = .);} + } + + /* At the moment, although perhaps we should, we can't map sections + without contents to sections *with* contents due to FIXME: a BFD bug. + Anyway, the mmo back-end ignores sections without contents when + writing out sections, so this works fine. */ + .bss : + { + ${RELOCATING+ PROVIDE(__Sbss = .);} + ${RELOCATING+ PROVIDE(__bss_start = .);} + ${RELOCATING+ *(.sbss);} + ${RELOCATING+ *(.bss);} + ${RELOCATING+*(.bss.*)} + ${RELOCATING+ *(COMMON);} + ${RELOCATING+ PROVIDE(__Ebss = .);} + } + + /* Deprecated, use __Ebss or __Eall as appropriate. */ + ${RELOCATING+ PROVIDE(end = .);} + ${RELOCATING+ PROVIDE(_end = .);} + ${RELOCATING+ PROVIDE(__end = .);} + ${RELOCATING+ PROVIDE(__Eall = .);} + + .MMIX.reg_contents : + { + /* Note that this section always has a fixed VMA - that of its + first register * 8. */ + *(.MMIX.reg_contents.linker_allocated); + *(.MMIX.reg_contents); + } + + /* By default, put the high end of the stack where the register stack + begins. They grow in opposite directions. */ + PROVIDE (__Stack_start = 0x6000000000000000); + + /* Unfortunately, stabs are not mappable from ELF to MMO. + It can probably be fixed with some amount of work. */ + /DISCARD/ : + { *(.gnu.warning.*); } +} +EOF diff --git a/ld/scripttempl/or32.sc b/ld/scripttempl/or32.sc new file mode 100644 index 000000000000..2825b1e83ea5 --- /dev/null +++ b/ld/scripttempl/or32.sc @@ -0,0 +1,37 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +SECTIONS +{ + .text : { + *(.text) + ${RELOCATING+ __etext = .}; + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + *(.lit) + *(.shdata) + } + .shbss SIZEOF(.text) + ADDR(.text) : { + *(.shbss) + } + .data : { + *(.data) + ${RELOCATING+ __edata = .}; + } + .bss SIZEOF(.data) + ADDR(.data) : + { + *(.bss) + *(COMMON) + ${RELOCATING+ __end = ALIGN(0x8)}; + } +} +EOF diff --git a/ld/scripttempl/pj.sc b/ld/scripttempl/pj.sc new file mode 100644 index 000000000000..93981a59b968 --- /dev/null +++ b/ld/scripttempl/pj.sc @@ -0,0 +1,55 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + ram : o = 0x1000, l = 512M +} + +SECTIONS +{ + .text : + { + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + ${CONSTRUCTING+${TORS}} + .data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + .bss : + { + ${RELOCATING+ _bss_start = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > ram} + .stack ${RELOCATING+ 0x30000 } : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > ram} + .stab 0 ${RELOCATING+(NOLOAD)} : + { + *(.stab) + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + *(.stabstr) + } +} +EOF diff --git a/ld/scripttempl/psos.sc b/ld/scripttempl/psos.sc new file mode 100644 index 000000000000..ab8c6c7e3c8e --- /dev/null +++ b/ld/scripttempl/psos.sc @@ -0,0 +1,61 @@ +cat <<EOF +OUTPUT_FORMAT(${OUTPUT_FORMAT}) +OUTPUT_ARCH(${ARCH}) +${RELOCATING+${LIB_SEARCH_DIRS}} + +SECTIONS +{ + .text ${RELOCATING:-0} ${RELOCATING+${TEXT_START_ADDR}} : { + ${RELOCATING+ start = DEFINED(_START) ? _START : DEFINED(_start) ? _start : .;} + ${RELOCATING+ PROVIDE(__text = .);} + *(.text); + *(code); + *(const); + *(strings); + *(pSOS); + *(pROBE); + *(pNA); + *(pHILE); + *(pREPC); + *(pRPC); + ${CONSTRUCTING+ ___CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___CTOR_END__ - ___CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0);} + ${CONSTRUCTING+ ___CTOR_END__ = .;} + ${CONSTRUCTING+ ___DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___DTOR_END__ - ___DTOR_LIST__) / 4 - 2);} + ${CONSTRUCTING+ *(.dtors);} + ${CONSTRUCTING+ LONG(0);} + ${CONSTRUCTING+ ___DTOR_END__ = .;} + ${RELOCATING+ PROVIDE(__etext = .);} + ${RELOCATING+ PROVIDE(_etext = .);} + } + .data ${RELOCATING:-0} : ${RELOCATING+ AT(ADDR(.text) + SIZEOF(.text))} { + ${RELOCATING+ PROVIDE(__data = .);} + *(.data); + *(vars); + ${RELOCATING+ PROVIDE(__edata = .);} + ${RELOCATING+ PROVIDE(_edata = .);} + } + .bss ${RELOCATING:-0} : + { + ${RELOCATING+ PROVIDE(__bss = .);} + *(.bss); + *(zerovars); + *(COMMON); + ${RELOCATING+ PROVIDE(__ebss = .);} + ${RELOCATING+ PROVIDE(__end = .);} + ${RELOCATING+ PROVIDE(_end = .);} + ${RELOCATING+ PROVIDE(_FreeMemStart = .);} + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + *(.stab); + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + *(.stabstr); + } +} +EOF diff --git a/ld/scripttempl/riscix.sc b/ld/scripttempl/riscix.sc new file mode 100644 index 000000000000..c801a0c4a990 --- /dev/null +++ b/ld/scripttempl/riscix.sc @@ -0,0 +1,35 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+__DYNAMIC = 0;} +${STACKZERO+${RELOCATING+${STACKZERO}}} +${SHLIB_PATH+${RELOCATING+${SHLIB_PATH}}} +SECTIONS +{ + .text ${RELOCATING+${TEXT_START_ADDR}}: + { + CREATE_OBJECT_SYMBOLS + *(.text) + ${PAD_TEXT+${RELOCATING+. = ${DATA_ALIGNMENT};}} + ${RELOCATING+_etext = ${DATA_ALIGNMENT};} + ${RELOCATING+__etext = ${DATA_ALIGNMENT};} + } + .data ${RELOCATING+${DATA_ALIGNMENT}} : + { + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+_edata = .;} + ${RELOCATING+__edata = .;} + } + .bss ${RELOCATING+SIZEOF(.data) + ADDR(.data)} : + { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+_end = ALIGN(4) }; + ${RELOCATING+__end = ALIGN(4) }; + } +} +EOF diff --git a/ld/scripttempl/sa29200.sc b/ld/scripttempl/sa29200.sc new file mode 100644 index 000000000000..a2f267e649d5 --- /dev/null +++ b/ld/scripttempl/sa29200.sc @@ -0,0 +1,44 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +ENTRY(start) + +SECTIONS { + .text ${RELOCATING+${TEXT_START_ADDR}} : + { + *(.text); + *(.text1); + *(.text2); + ${RELOCATING+_etext = .}; + } + .lit ALIGN(4) : + { + *(.lit); + ${RELOCATING+_elit = .}; + } + .data ALIGN(4) : + { + *(.data); + *(.data1); + *(.data2); + ${RELOCATING+_edata = .}; + ${CONSTRUCTING+CONSTRUCTORS} + ${CONSTRUCTING+ ___CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___CTOR_END__ - ___CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ ___CTOR_END__ = .;} + ${CONSTRUCTING+ ___DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___DTOR_END__ - ___DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ ___DTOR_END__ = .;} + } + + .bss ALIGN(4) : + { + *(COMMON) + *(.bss) + ${RELOCATING+_end = .}; + } +} +EOF diff --git a/ld/scripttempl/sparclynx.sc b/ld/scripttempl/sparclynx.sc new file mode 100644 index 000000000000..c2b1e1d327de --- /dev/null +++ b/ld/scripttempl/sparclynx.sc @@ -0,0 +1,47 @@ +# Linker script for Sparc LynxOS. +test -z "$ENTRY" && ENTRY=_start +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ SIZEOF_HEADERS} : { + *(.init) + *(.text) + ${RELOCATING+ etext = .;} + ${CONSTRUCTING+ ___CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___CTOR_END__ - ___CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ ___CTOR_END__ = .;} + ${CONSTRUCTING+ ___DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___DTOR_END__ - ___DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ ___DTOR_END__ = .;} + *(.fini) + ${RELOCATING+ etext = .}; + } + .data ${RELOCATING+ 0x400000 + (. & 0xffc00fff)} : { + *(.data) + ${RELOCATING+ edata = .}; + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss) + *(COMMON) + ${RELOCATING+ end = .}; + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/st2000.sc b/ld/scripttempl/st2000.sc new file mode 100644 index 000000000000..7ee132a8b263 --- /dev/null +++ b/ld/scripttempl/st2000.sc @@ -0,0 +1,26 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + + +SECTIONS +{ +.text : + { + *(.text) + *(.strings) + _etext = .; + *(.data) + _edata = .; + *(.bss) + *(COMMON) + _end = .; + +} + +} +EOF + + + + diff --git a/ld/scripttempl/tic4xcoff.sc b/ld/scripttempl/tic4xcoff.sc new file mode 100644 index 000000000000..121f3ed4c1f6 --- /dev/null +++ b/ld/scripttempl/tic4xcoff.sc @@ -0,0 +1,151 @@ +# In microcomputer (MC) mode, the vectors are mapped into the on-chip ROM, +# otherwise in microprocessor (MP) mode the vectors are mapped to address 0 +# on the external bus. In MC mode, the on-chip ROM contains a bootloader program +# that loads the internal RAM from the serial port or external ROM. +# +# Common configurations: +# 1. MC mode, no external memory (serial boot). +# 2. MC mode, external RAM (serial boot). +# 3. MC mode, external ROM. +# 4. MC mode, external ROM, external RAM. +# 5. MP mode, external ROM. +# 6. MP mode, external ROM, external RAM. +# 7. MP mode, external RAM (dual-port with hosting CPU or external debugger). +# +# Config TEXT DATA/BSS +# 1. INT_RAM INT_RAM (mcmode,onchip) +# 2. EXT_RAM EXT_RAM (mcmode,extram) +# 3. INT_RAM INT_RAM (mcmode,onchip) +# 4. EXT_RAM EXT_RAM (mcmode,extram) +# 5. EXT_ROM INT_RAM (mpmode,onchip,extrom) +# 6. EXT_ROM EXT_RAM (mpmode,extram,extrom) +# 7. EXT_RAM EXT_RAM (mpmode,extram) +# +# In MC mode, TEXT and DATA are copied into RAM by the bootloader. +# +# In MP mode with external ROM, DATA needs to be copied into RAM at boot time. +# +# If there is external RAM it is better to use that and reserve the internal RAM +# for data buffers. However, the address of the external RAM needs to be specified. +# +# This emulation assumes config 7. + +case $OUTPUT_ARCH in + tic3x) OUTPUT_ARCHNAME="TMS320C3x" ;; + tic4x) OUTPUT_ARCHNAME="TMS320C4x" ;; +esac + +case $ONCHIP in + yes) RAM=RAM; + STACK_SIZE_DEFAULT=128; + HEAP_SIZE_DEFAULT=0; + ;; + *) RAM=EXT0; + STACK_SIZE_DEFAULT=0x1000; + HEAP_SIZE_DEFAULT=0x4000; + ;; +esac + +TEXT_MEMORY=$RAM; +DATA_MEMORY=$RAM; + + +MEMORY_DEF=" +/* C30 memory space. */ +MEMORY +{ + EXT0 : org = 0x0000000, len = 0x800000 /* External address bus. */ + XBUS : org = 0x0800000, len = 0x002000 /* Expansion bus. */ + IOBUS : org = 0x0804000, len = 0x002000 /* I/O BUS. */ + RAM0 : org = 0x0809800, len = 0x000400 /* Internal RAM block 0. */ + RAM1 : org = 0x0809a00, len = 0x000400 /* Internal RAM block 1. */ + RAM : org = 0x0809800, len = 0x000800 /* Internal RAM. */ + EXT1 : org = 0x080a000, len = 0x7f6000 /* External address bus. */ +} +" + +test -z "$ENTRY" && ENTRY=_start + +cat <<EOF +${RELOCATING+/* Linker script for $OUTPUT_ARCHNAME executable. */} +${RELOCATING-/* Linker script for $OUTPUT_ARCHNAME object file (ld -r). */} + +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH("${OUTPUT_ARCH}") +${LIB_SEARCH_DIRS} +ENTRY(${ENTRY}) + +${RELOCATING+ __HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : ${HEAP_SIZE_DEFAULT};} +${RELOCATING+ __STACK_SIZE = DEFINED(__STACK_SIZE) ? __STACK_SIZE : ${STACK_SIZE_DEFAULT};} + +${RELOCATING+${MEMORY_DEF}} + +/* In the small memory model the .data and .bss sections must be contiguous + when loaded and fit within the same page. The DP register is loaded + with the page address. */ + +SECTIONS +{ + /* Reset, interrupt, and trap vectors. */ + .vectors ${RELOCATING+ 0} : { + *(.vectors) + } ${RELOCATING+ > ${TEXT_MEMORY}} + /* Constants. */ + .const : { + *(.const) + } ${RELOCATING+ > ${TEXT_MEMORY}} + /* Program code. */ + .text : { + ${RELOCATING+ __text = .;} + ${RELOCATING+ *(.init)} + *(.text) + ${CONSTRUCTING+ ___CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG(___CTOR_END__ - ___CTOR_LIST__ - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0);} + ${CONSTRUCTING+ ___CTOR_END__ = .;} + ${CONSTRUCTING+ ___DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG(___DTOR_END__ - ___DTOR_LIST__ - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ ___DTOR_END__ = .;} + ${RELOCATING+ *(.fini)} + ${RELOCATING+ __etext = .;} + } ${RELOCATING+ > ${TEXT_MEMORY}} + /* Global initialised variables. */ + .data : + { + ${RELOCATING+ __data = .;} + *(.data) + ${RELOCATING+ __edata = .;} + } ${RELOCATING+ > ${DATA_MEMORY}} + /* Global uninitialised variables. */ + .bss : { + ${RELOCATING+ __bss = .;} + *(.bss) + *(COMMON) + ${RELOCATING+ __end = .;} + } ${RELOCATING+ > ${DATA_MEMORY}} + /* Heap. */ + .heap : + { + ${RELOCATING+ __heap = .;} + ${RELOCATING+ . += __HEAP_SIZE}; + } ${RELOCATING+ > ${DATA_MEMORY}} + /* Stack (grows upward). */ + .stack : + { + ${RELOCATING+ __stack = .;} + *(.stack) + ${RELOCATING+ . = . + __STACK_SIZE}; + } ${RELOCATING+ > ${DATA_MEMORY}} + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/tic54xcoff.sc b/ld/scripttempl/tic54xcoff.sc new file mode 100644 index 000000000000..8d8a81166b56 --- /dev/null +++ b/ld/scripttempl/tic54xcoff.sc @@ -0,0 +1,52 @@ +# default linker script for c54x, TI COFF(1). +# patterned after description in TI Assembler Tools PDF, SPRU102C, 7-53 +test -z "$ENTRY" && ENTRY=_c_int00 + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH("${OUTPUT_ARCH}") + +MEMORY +{ + /*PAGE 0 : */ prog (RXI) : ORIGIN = 0x00000080, LENGTH = 0xFF00 + /*PAGE 1 : */ data (W) : ORIGIN = 0x01000080, LENGTH = 0xFF80 +} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text : + { + ___text__ = .; + *(.text) + etext = .; + ___etext__ = .; + } > prog + .data : + { + ___data__ = .; + __data = .; + *(.data) + __edata = .; + edata = .; + ___edata__ = .; + } > prog + /* all other initialized sections should be allocated here */ + .cinit : + { + *(.cinit) + } > prog + .bss : + { + ___bss__ = .; + __bss = .; + *(.bss) + *(COMMON) + __ebss = .; + end = .; + ___end__ = .; + } > data + /* all other uninitialized sections should be allocated here */ +} +EOF diff --git a/ld/scripttempl/tic80coff.sc b/ld/scripttempl/tic80coff.sc new file mode 100644 index 000000000000..2b6f6534aaba --- /dev/null +++ b/ld/scripttempl/tic80coff.sc @@ -0,0 +1,74 @@ +# Linker script for TI TMS320C80 (tic80) COFF. +# +# Besides the shell variables set by the emulparams script, and the LD_FLAG +# variable, the genscripts.sh script will set the following variables for each +# time this script is run to generate one of the linker scripts for ldscripts: +# +# RELOCATING: Set to a non-empty string when the linker is going to be doing +# a final relocation. +# +# CONSTRUCTING: Set to a non-empty string when the linker is going to be +# building global constructor and destructor tables. +# +# DATA_ALIGNMENT: Set to an ALIGN expression when the output should be page +# aligned, or to "." when generating the -N script. +# +# CREATE_SHLIB: Set to a non-empty string when generating a script for +# the -shared linker arg. + +test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x80000 + SIZEOF_HEADERS" +test -z "$ENTRY" && ENTRY=__start + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ $TEXT_START_ADDR} : { + *(.init) + *(.fini) + *(.text) + } + .const ALIGN(4) : { + *(.const) + } + .ctors ALIGN(4) : { + ${CONSTRUCTING+ . = ALIGN(4);} + ${CONSTRUCTING+ ___CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG(-1)} + *(.ctors) + ${CONSTRUCTING+ ___CTOR_END__ = .;} + ${CONSTRUCTING+ LONG(0)} + } + .dtors ALIGN(4) : { + ${CONSTRUCTING+ ___DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG(-1)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ ___DTOR_END__ = .;} + ${CONSTRUCTING+ LONG(0)} + } + ${RELOCATING+ etext = .;} + .data : { + *(.data) + ${RELOCATING+ __edata = .}; + } + .bss : { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+ _end = ALIGN(0x8)}; + ${RELOCATING+ __end = ALIGN(0x8)}; + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/v850.sc b/ld/scripttempl/v850.sc index 8958321b2b95..18ba03a20b6c 100644 --- a/ld/scripttempl/v850.sc +++ b/ld/scripttempl/v850.sc @@ -4,6 +4,7 @@ OUTPUT_FORMAT("elf32-v850", "elf32-v850", OUTPUT_ARCH(v850) ENTRY(_start) SEARCH_DIR(.); +EXTERN(__ctbp __ep __gp); SECTIONS { /* This saves a little space in the ELF file, since the zda starts diff --git a/ld/scripttempl/w65.sc b/ld/scripttempl/w65.sc new file mode 100644 index 000000000000..f92d99943108 --- /dev/null +++ b/ld/scripttempl/w65.sc @@ -0,0 +1,65 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + ram : o = 0x1000, l = 512k +} + +SECTIONS +{ +.text : + { + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + + ${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack ${RELOCATING+ 0x30000 } : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > ram} + +.stab . (NOLOAD) : + { + [ .stab ] + } + +.stabstr . (NOLOAD) : + { + [ .stabstr ] + } +} +EOF + + + + diff --git a/ld/scripttempl/xstormy16.sc b/ld/scripttempl/xstormy16.sc new file mode 100644 index 000000000000..a74df07575f6 --- /dev/null +++ b/ld/scripttempl/xstormy16.sc @@ -0,0 +1,240 @@ +# +# Unusual variables checked by this code: +# NOP - two byte opcode for no-op (defaults to 0) +# INITIAL_READONLY_SECTIONS - at start of text segment +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_TEXT_SECTIONS - these get put in .text when relocating +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_BSS_SECTIONS - other than .bss .sbss ... +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got and .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# INPUT_FILES - INPUT command of files to always include +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + } > ROM" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + } > ROM" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +/* There are two memory regions we care about, one from 0 through 0x7F00 + that is RAM and one from 0x8000 up which is ROM. */ +MEMORY +{ + RAM (w) : ORIGIN = 0, LENGTH = 0x7F00 + ROM (!w) : ORIGIN = 0x8000, LENGTH = 0xFF8000 +} + +SECTIONS +{ + .data ${RELOCATING-0} : + { + ${RELOCATING+__rdata = .;} + ${RELOCATING+__data = .;} + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } > RAM + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + ${RELOCATING+${OTHER_GOT_SECTIONS}} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.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. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } > RAM + ${RELOCATING+${OTHER_BSS_SECTIONS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+_end = .;} + ${RELOCATING+__stack = .;} + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+PROVIDE (end = .);} + + /* Read-only sections in ROM. */ + .int_vec ${RELOCATING-0} : { *(.int_vec) } > ROM + + .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } > ROM + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + .jcr : { KEEP (*(.jcr)) } > ROM + .eh_frame : { KEEP (*(.eh_frame)) } > ROM + .gcc_except_table : { *(.gcc_except_table) } > ROM + .plt : { *(.plt) } > ROM + + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text) + ${RELOCATING+*(.text.*)} + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.gnu.linkonce.t.*)} + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } > ROM =${NOP-0} + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } > ROM =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } > ROM =${NOP-0} + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + ${RELOCATING+${OTHER_READONLY_SECTIONS}} + + + /* 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) } + + ${RELOCATING+${OTHER_RELOCATING_SECTIONS}} + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF |