diff options
author | Richard Henderson <rth@redhat.com> | 1999-05-03 07:29:11 +0000 |
---|---|---|
committer | Richard Henderson <rth@redhat.com> | 1999-05-03 07:29:11 +0000 |
commit | 252b5132c753830d5fd56823373aed85f2a0db63 (patch) | |
tree | 1af963bfd8d3e55167b81def4207f175eaff3a56 /ld/scripttempl | |
download | gdb-252b5132c753830d5fd56823373aed85f2a0db63.zip gdb-252b5132c753830d5fd56823373aed85f2a0db63.tar.gz gdb-252b5132c753830d5fd56823373aed85f2a0db63.tar.bz2 |
19990502 sourceware importbinu_ss_19990502
Diffstat (limited to 'ld/scripttempl')
53 files changed, 4131 insertions, 0 deletions
diff --git a/ld/scripttempl/README b/ld/scripttempl/README new file mode 100644 index 0000000..26ad2e9 --- /dev/null +++ b/ld/scripttempl/README @@ -0,0 +1,4 @@ +The files in this directory are linker script templates. +genscripts.sh sets some shell variables, then sources +EMULATION.sc, to generate EMULATION.{x,xr,xu,xn,xbn} -- the script +files for default, -r, -Ur, -n, -N. diff --git a/ld/scripttempl/a29k.sc b/ld/scripttempl/a29k.sc new file mode 100644 index 0000000..2825b1e --- /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 0000000..3f4b617 --- /dev/null +++ b/ld/scripttempl/aix.sc @@ -0,0 +1,55 @@ +# 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_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+${LIB_SEARCH_DIRS}} +ENTRY(__start) +SECTIONS +{ + .pad 0 : { *(.pad) } + .text ${RELOCATING-0} : { + ${RELOCATING+PROVIDE (_text = .);} + *(.text) + *(.pr) + *(.ro) + *(.db) + *(.gl) + *(.xo) + *(.ti) + *(.tb) + ${RELOCATING+PROVIDE (_etext = .);} + } + .data 0 : { + ${RELOCATING+PROVIDE (_data = .);} + *(.data) + *(.rw) + *(.sv) + *(.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 0 : { + *(.loader) + } + .debug 0 : { + *(.debug) + } +} +EOF diff --git a/ld/scripttempl/alpha.sc b/ld/scripttempl/alpha.sc new file mode 100644 index 0000000..44a10c4 --- /dev/null +++ b/ld/scripttempl/alpha.sc @@ -0,0 +1,74 @@ +# Linker script for Alpha systems. +# Ian Lance Taylor <ian@cygnus.com>. +# These variables may be overridden by the emulation file. The +# defaults are appropriate for an Alpha running OSF/1. +test -z "$ENTRY" && ENTRY=__start +test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x120000000 + SIZEOF_HEADERS" +if test "x$LD_FLAG" = "xn" -o "x$LD_FLAG" = "xN"; then + DATA_ADDR=. +else + test -z "$DATA_ADDR" && DATA_ADDR=0x140000000 +fi +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : { + ${RELOCATING+ _ftext = . }; + ${RELOCATING+ __istart = . }; + ${RELOCATING+ *(.init) } + ${RELOCATING+ LONG (0x6bfa8001)} + ${RELOCATING+ eprol = .}; + *(.text) + ${RELOCATING+ __fstart = . }; + ${RELOCATING+ *(.fini)} + ${RELOCATING+ LONG (0x6bfa8001)} + ${RELOCATING+ _etext = .}; + } + .rdata : { + *(.rdata) + } + .rconst : { + *(.rconst) + } + .pdata : { + ${RELOCATING+ _fpdata = .;} + *(.pdata) + } + ${RELOCATING+. = ${DATA_ADDR};} + .data : { + ${RELOCATING+ _fdata = .;} + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + } + .xdata : { + *(.xdata) + } + ${RELOCATING+ _gp = ALIGN (16) + 0x8000;} + .lit8 : { + *(.lit8) + } + .lita : { + *(.lita) + } + .sdata : { + *(.sdata) + } + ${RELOCATING+ _EDATA = .;} + ${RELOCATING+ _FBSS = .;} + .sbss : { + *(.sbss) + *(.scommon) + } + .bss : { + *(.bss) + *(COMMON) + } + ${RELOCATING+ _end = .;} +} +EOF diff --git a/ld/scripttempl/aout.sc b/ld/scripttempl/aout.sc new file mode 100644 index 0000000..80dbb37 --- /dev/null +++ b/ld/scripttempl/aout.sc @@ -0,0 +1,57 @@ +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${ALIGNMENT}" && ALIGNMENT="4" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${STACKZERO+${RELOCATING+${STACKZERO}}} +${SHLIB_PATH+${RELOCATING+${SHLIB_PATH}}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+PROVIDE (__stack = 0);} +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : + { + CREATE_OBJECT_SYMBOLS + *(.text) + /* The next six sections are for SunOS dynamic linking. The order + is important. */ + *(.dynrel) + *(.hash) + *(.dynsym) + *(.dynstr) + *(.rules) + *(.need) + ${RELOCATING+_etext = .;} + ${RELOCATING+__etext = .;} + ${PAD_TEXT+${RELOCATING+. = ${DATA_ALIGNMENT};}} + } + ${RELOCATING+. = ${DATA_ALIGNMENT};} + .data : + { + /* The first three sections are for SunOS dynamic linking. */ + *(.dynamic) + *(.got) + *(.plt) + *(.data) + *(.linux-dynamic) /* For Linux dynamic linking. */ + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+_edata = .;} + ${RELOCATING+__edata = .;} + } + .bss : + { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+_end = . }; + ${RELOCATING+__end = . }; + } +} +EOF diff --git a/ld/scripttempl/armaout.sc b/ld/scripttempl/armaout.sc new file mode 100644 index 0000000..e9276a8 --- /dev/null +++ b/ld/scripttempl/armaout.sc @@ -0,0 +1,35 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${STACKZERO+${RELOCATING+${STACKZERO}}} +SECTIONS +{ + .text ${RELOCATING+${TEXT_START_ADDR}} : + { + CREATE_OBJECT_SYMBOLS + ${RELOCATING+__stext_ = .;} + *(.text) + ${PAD_TEXT+${RELOCATING+. = ${DATA_ALIGNMENT};}} + ${RELOCATING+_etext = ${DATA_ALIGNMENT};} + ${RELOCATING+__etext = ${DATA_ALIGNMENT};} + } + .data ${RELOCATING+${DATA_ALIGNMENT}} : + { + ${RELOCATING+__sdata_ = .;} + *(.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/armcoff.sc b/ld/scripttempl/armcoff.sc new file mode 100644 index 0000000..8e07169 --- /dev/null +++ b/ld/scripttempl/armcoff.sc @@ -0,0 +1,62 @@ +# Linker script for ARM COFF. +# Based on i386coff.sc by Ian Taylor <ian@cygnus.com>. +test -z "$ENTRY" && ENTRY=_start +if test -z "${DATA_ADDR}"; then + if test "$LD_FLAG" = "N" || test "$LD_FLAG" = "n"; then + DATA_ADDR=. + fi +fi +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + /* We start at 0x8000 because gdb assumes it (see FRAME_CHAIN). + This is an artifact of the ARM Demon monitor using the bottom 32k + as workspace (shared with the FP instruction emulator if + present): */ + .text ${RELOCATING+ 0x8000} : { + *(.init) + *(.text) + *(.glue_7t) + *(.glue_7) + *(.rdata) + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); *(.ctors); *(.ctor); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); LONG (0); } + *(.fini) + ${RELOCATING+ etext = .;} + } + .data ${RELOCATING+${DATA_ADDR-0x40000 + (. & 0xfffc0fff)}} : { + ${RELOCATING+ __data_start__ = . ;} + *(.data) + ${RELOCATING+ __data_end__ = . ;} + ${RELOCATING+ edata = .;} + ${RELOCATING+ _edata = .;} + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + ${RELOCATING+ __bss_start__ = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ __bss_end__ = . ;} + } + + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} + ${RELOCATING+ __end__ = .;} + + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/delta68.sc b/ld/scripttempl/delta68.sc new file mode 100644 index 0000000..d996305 --- /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/ebmon29k.sc b/ld/scripttempl/ebmon29k.sc new file mode 100644 index 0000000..62050ee --- /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/elf.sc b/ld/scripttempl/elf.sc new file mode 100644 index 0000000..e1fea97 --- /dev/null +++ b/ld/scripttempl/elf.sc @@ -0,0 +1,286 @@ +# +# Unusual variables checked by this code: +# NOP - two 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 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_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. +# DATA_PLT - .plt should be in data segment, not text 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 +# +# 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 -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) }" + +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}} + }" + +# 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 +{ + /* 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) } + .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.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} : { KEEP (*(.init)) } =${NOP-0} + ${DATA_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} + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + .fini ${RELOCATING-0} : { KEEP (*(.fini)) } =${NOP-0} + .rodata ${RELOCATING-0} : + { + *(.rodata) + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + } + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${RELOCATING+${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. */ + ${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 : { *(.eh_frame) } + .gcc_except_table : { *(.gcc_except_table) } + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + ${DATA_PLT+${PLT}} + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + ${TEXT_DYNAMIC-${DYNAMIC}} + /* 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+${OTHER_GOT_SECTIONS}} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + *(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+. = 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) } + .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/elfd10v.sc b/ld/scripttempl/elfd10v.sc new file mode 100644 index 0000000..322eef4 --- /dev/null +++ b/ld/scripttempl/elfd10v.sc @@ -0,0 +1,226 @@ +# +# Unusual variables checked by this code: +# NOP - two 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) +# 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. +# DATA_PLT - .plt should be in data segment, not text segment. +# 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=. +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}} + }" + + +# 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}} +${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+. = ${READONLY_BASE_ADDRESS};}} + ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .rel.text ${RELOCATING-0} : { *(.rel.text) } + .rela.text ${RELOCATING-0} : { *(.rela.text) } + .rel.data ${RELOCATING-0} : { *(.rel.data) } + .rela.data ${RELOCATING-0} : { *(.rela.data) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) } + .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) } + ${DATA_PLT-${PLT}} + .rodata ${RELOCATING-0} : { *(.rodata) *(.gnu.linkonce.r*) } + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${RELOCATING+${OTHER_READONLY_SECTIONS}} + + /* Adjust the address for the data segment. */ + ${RELOCATING+. = ${DATA_ADDR-ALIGN(4);}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + ${CONSTRUCTING+CONSTRUCTORS} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + .dynamic ${RELOCATING-0} : { *(.dynamic) } + ${DATA_PLT+${PLT}} + /* 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) } + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + *(COMMON) + } + ${RELOCATING+_end = . ;} + ${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) } + .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} + + + /* Hmmm, there's got to be a better way. This sets the stack to the + top of the simulator memory (i.e. top of 64K data space). */ + .stack 0x00007FFE : { _stack = .; *(.stack) } + + .text ${RELOCATING+${TEXT_START_ADDR}} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + KEEP (*(.init)) + KEEP (*(.fini)) + *(.text) + *(.text.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =${NOP-0} + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} +} +EOF diff --git a/ld/scripttempl/elfd30v.sc b/ld/scripttempl/elfd30v.sc new file mode 100644 index 0000000..0ff9283 --- /dev/null +++ b/ld/scripttempl/elfd30v.sc @@ -0,0 +1,219 @@ + +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) } + + .rela.text ${RELOCATING-0} : { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rela.data ${RELOCATING-0} : { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rela.stext ${RELOCATING-0} : { *(.rela.stest) } + .rela.etext ${RELOCATING-0} : { *(.rela.etest) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } + .rela.edata ${RELOCATING-0} : { *(.rela.edata) } + .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) } + .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) } + .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) } + .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + .rel.data ${RELOCATING-0} : { *(.rel.data) *(.rel.gnu.linkonce.d*) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } + .rel.stext ${RELOCATING-0} : { *(.rel.stest) } + .rel.etext ${RELOCATING-0} : { *(.rel.etest) } + .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) } + .rel.edata ${RELOCATING-0} : { *(.rel.edata) } + .rel.sbss ${RELOCATING-0} : { *(.rel.sbss) } + .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) } + .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) } + .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) } + .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.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} : { *(.eh_frame) } ${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) } + .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/elfppc.sc new file mode 100644 index 0000000..ddab8f8 --- /dev/null +++ b/ld/scripttempl/elfppc.sc @@ -0,0 +1,288 @@ +# +# Unusual variables checked by this code: +# NOP - two 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) +# 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. +# +# 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} +test "$LD_FLAG" = "N" && DATA_ADDR=. +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}") +OUTPUT_ARCH(${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- /* 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. */} + +${RELOCATING+PROVIDE (__stack = 0);} +${RELOCATING+PROVIDE (___stack = 0);} +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + .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) } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r*)} + } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rela.got1 ${RELOCATING-0} : { *(.rela.got1) } + .rela.got2 ${RELOCATING-0} : { *(.rela.got2) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) } + .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2) } + .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2) } + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text) + ${RELOCATING+*(.text.*)} + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.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*)} + } + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + ${RELOCATING+PROVIDE (__etext = .);} + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${RELOCATING+${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 + be more correct to do this: + ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1))};} + The current expression does not correctly handle the case of a + text segment ending precisely at the end of a page; it causes the + data segment to skip a page. The above expression does not have + this problem, but it will currently (2/95) cause BFD to allocate + a single segment, combining both text and data, for this case. + This will prevent the text segment from being shared among + multiple executions of the program; I think that is more + important than losing a page of the virtual address space (note + that no actual memory is lost; the page which is skipped can not + be referenced). */ + ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d*)} + ${CONSTRUCTING+CONSTRUCTORS} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + + .got1 ${RELOCATING-0} : { *(.got1) } + .dynamic ${RELOCATING-0} : { *(.dynamic) } + + /* Put .ctors and .dtors next to the .got2 section, so that the pointers + get relocated with -mrelocatable. Also put in the .fixup pointers. + 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}} + ${RELOCATING+PROVIDE (__CTOR_END__ = .);} + ${RELOCATING+PROVIDE (___CTOR_END__ = .);} + + ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);} + ${RELOCATING+PROVIDE (___DTOR_LIST__ = .);} + ${RELOCATING+${DTOR}} + ${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 + we can shorten the on-disk segment size. */ + .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. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.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 : { *(.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) } + .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) } + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF diff --git a/ld/scripttempl/go32coff.sc b/ld/scripttempl/go32coff.sc new file mode 100644 index 0000000..40f6076 --- /dev/null +++ b/ld/scripttempl/go32coff.sc @@ -0,0 +1,33 @@ +# Linker script for 386 go32 +# DJ Delorie (dj@ctron.com) + +test -z "$ENTRY" && ENTRY=start +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ 0x1000+SIZEOF_HEADERS} : { + *(.text) + ${RELOCATING+ etext = . ; _etext = .}; + ${RELOCATING+ . = ALIGN(0x200);} + } + .data ${RELOCATING+ ${DATA_ALIGNMENT}} : { + ${RELOCATING+ *(.ctor)} + ${RELOCATING+ *(.dtor)} + *(.data) + ${RELOCATING+ edata = . ; _edata = .}; + ${RELOCATING+ . = ALIGN(0x200);} + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss) + *(COMMON) + ${RELOCATING+ end = . ; _end = .}; + ${RELOCATING+ . = ALIGN(0x200);} + } +} +EOF diff --git a/ld/scripttempl/h8300.sc b/ld/scripttempl/h8300.sc new file mode 100644 index 0000000..f2f876e --- /dev/null +++ b/ld/scripttempl/h8300.sc @@ -0,0 +1,69 @@ +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 to 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} +.tors : { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } ${RELOCATING+ > ram} +.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 0000000..d1cfd86 --- /dev/null +++ b/ld/scripttempl/h8300h.sc @@ -0,0 +1,76 @@ +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} +.tors : { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } ${RELOCATING+ > ram} +.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/h8300s.sc b/ld/scripttempl/h8300s.sc new file mode 100644 index 0000000..45474fc --- /dev/null +++ b/ld/scripttempl/h8300s.sc @@ -0,0 +1,76 @@ +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} +.tors : { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } ${RELOCATING+ > ram} +.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/h8500.sc b/ld/scripttempl/h8500.sc new file mode 100644 index 0000000..d6a39ee --- /dev/null +++ b/ld/scripttempl/h8500.sc @@ -0,0 +1,62 @@ +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) + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; +} + +.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 0000000..ef5fa2c --- /dev/null +++ b/ld/scripttempl/h8500b.sc @@ -0,0 +1,62 @@ +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) + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; +} + +.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 0000000..03880e3 --- /dev/null +++ b/ld/scripttempl/h8500c.sc @@ -0,0 +1,59 @@ +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); + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; +} ${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 0000000..040a4a7 --- /dev/null +++ b/ld/scripttempl/h8500m.sc @@ -0,0 +1,61 @@ +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) + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } + +.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 0000000..11615d8 --- /dev/null +++ b/ld/scripttempl/h8500s.sc @@ -0,0 +1,60 @@ +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) + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } + +.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 0000000..941ce08 --- /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 0000000..83ffde1 --- /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) } + .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/i386coff.sc b/ld/scripttempl/i386coff.sc new file mode 100644 index 0000000..fbb1b79 --- /dev/null +++ b/ld/scripttempl/i386coff.sc @@ -0,0 +1,43 @@ +# Linker script for 386 COFF. This works on SVR3.2 and SCO Unix 3.2.2. +# Ian Taylor <ian@cygnus.com>. +test -z "$ENTRY" && ENTRY=_start +# 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}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ SIZEOF_HEADERS} : { + ${RELOCATING+ *(.init)} + *(.text) + ${RELOCATING+ *(.fini)} + ${RELOCATING+ etext = .}; + } + .data ${RELOCATING+ 0x400000 + (. & 0xffc00fff)} : { + *(.data) + ${RELOCATING+ edata = .}; + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss) + *(COMMON) + ${RELOCATING+ end = .}; + } + ${RELOCATING- ${INIT}} + ${RELOCATING- ${FINI}} + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/ld/scripttempl/i386go32.sc b/ld/scripttempl/i386go32.sc new file mode 100644 index 0000000..6bd3d09 --- /dev/null +++ b/ld/scripttempl/i386go32.sc @@ -0,0 +1,46 @@ +# 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 : { *(.ctor) }' +DTOR='.dtor : { *(.dtor) }' + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}${EXE}") + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ ${TARGET_PAGE_SIZE}+SIZEOF_HEADERS} : { + *(.text) + *(.const*) + *(.ro*) + ${RELOCATING+etext = . ; _etext = .}; + ${RELOCATING+. = ALIGN(${SEGMENT_SIZE});} + } + .data ${RELOCATING+ ${DATA_ALIGNMENT}} : { + ${RELOCATING+djgpp_first_ctor = . ; + *(.ctor) + djgpp_last_ctor = . ;} + ${RELOCATING+djgpp_first_dtor = . ; + *(.dtor) + djgpp_last_dtor = . ;} + *(.data) + ${RELOCATING+ edata = . ; _edata = .}; + ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});} + } + ${CONSTRUCTING+${RELOCATING-$CTOR}} + ${CONSTRUCTING+${RELOCATING-$DTOR}} + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss) + *(COMMON) + ${RELOCATING+ end = . ; _end = .}; + ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});} + } +} +EOF diff --git a/ld/scripttempl/i386lynx.sc b/ld/scripttempl/i386lynx.sc new file mode 100644 index 0000000..16b72a4 --- /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 0000000..4d312e7 --- /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/i960.sc b/ld/scripttempl/i960.sc new file mode 100644 index 0000000..dc33555 --- /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/m68kaux.sc b/ld/scripttempl/m68kaux.sc new file mode 100644 index 0000000..404280e --- /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 0000000..f268c6f --- /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 0000000..81d2245 --- /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 0000000..f52b14d --- /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 0000000..8111bf2 --- /dev/null +++ b/ld/scripttempl/mcorepe.sc @@ -0,0 +1,156 @@ +# 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) + } + + /* 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/mips.sc b/ld/scripttempl/mips.sc new file mode 100644 index 0000000..d60aeed --- /dev/null +++ b/ld/scripttempl/mips.sc @@ -0,0 +1,72 @@ +# Linker script for MIPS systems. +# Ian Lance Taylor <ian@cygnus.com>. +# These variables may be overridden by the emulation file. The +# defaults are appropriate for a DECstation running Ultrix. +test -z "$ENTRY" && ENTRY=__start + +if [ -z "$EMBEDDED" ]; then + test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x400000 + SIZEOF_HEADERS" +else + test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x400000" +fi +if test "x$LD_FLAG" = "xn" -o "x$LD_FLAG" = "xN"; then + DATA_ADDR=. +else + test -z "$DATA_ADDR" && DATA_ADDR=0x10000000 +fi +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : { + ${RELOCATING+ _ftext = . }; + *(.init) + ${RELOCATING+ eprol = .}; + *(.text) + ${RELOCATING+PROVIDE (__runtime_reloc_start = .);} + *(.rel.sdata) + ${RELOCATING+PROVIDE (__runtime_reloc_stop = .);} + *(.fini) + ${RELOCATING+ etext = .}; + ${RELOCATING+ _etext = .}; + } + ${RELOCATING+. = ${DATA_ADDR};} + .rdata : { + *(.rdata) + } + ${RELOCATING+ _fdata = ALIGN(16);} + .data : { + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + } + ${RELOCATING+ _gp = ALIGN(16) + 0x8000;} + .lit8 : { + *(.lit8) + } + .lit4 : { + *(.lit4) + } + .sdata : { + *(.sdata) + } + ${RELOCATING+ edata = .;} + ${RELOCATING+ _edata = .;} + ${RELOCATING+ _fbss = .;} + .sbss : { + *(.sbss) + *(.scommon) + } + .bss : { + *(.bss) + *(COMMON) + } + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} +} +EOF diff --git a/ld/scripttempl/mipsbsd.sc b/ld/scripttempl/mipsbsd.sc new file mode 100644 index 0000000..b222b33 --- /dev/null +++ b/ld/scripttempl/mipsbsd.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/nw.sc b/ld/scripttempl/nw.sc new file mode 100644 index 0000000..725522c --- /dev/null +++ b/ld/scripttempl/nw.sc @@ -0,0 +1,131 @@ +# +# Unusual variables checked by this code: +# NOP - two 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 .ctors .rodata ... +# (e.g., .PARISC.milli) +# OTHER_READWRITE_SECTIONS - other than .data .bss .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. +# DATA_PLT - .plt should be in data segment, not text segment. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${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- /* 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_START_ADDR} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .rel.text ${RELOCATING-0} : { *(.rel.text) } + .rela.text ${RELOCATING-0} : { *(.rela.text) } + .rel.data ${RELOCATING-0} : { *(.rel.data) } + .rela.data ${RELOCATING-0} : { *(.rela.data) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) } + .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.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}} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text) + ${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+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} + .ctors ${RELOCATING-0} : { *(.ctors) } + .dtors ${RELOCATING-0} : { *(.dtors) } + .rodata ${RELOCATING-0} : { *(.rodata) } + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${RELOCATING+${OTHER_READONLY_SECTIONS}} + + /* Read-write section, merged into data segment: */ + ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};} + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + .dynamic ${RELOCATING-0} : { *(.dynamic) } + ${DATA_PLT+${PLT}} + /* 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) } + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + *(COMMON) + } + ${RELOCATING+_end = . ;} + ${RELOCATING+PROVIDE (end = .);} + + /* These are needed for ELF backends which have not yet been + converted to the new style linker. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc new file mode 100644 index 0000000..7926bfe --- /dev/null +++ b/ld/scripttempl/pe.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) + } + + /* 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 ] + } + +} +EOF diff --git a/ld/scripttempl/ppcpe.sc b/ld/scripttempl/ppcpe.sc new file mode 100644 index 0000000..40fbe33 --- /dev/null +++ b/ld/scripttempl/ppcpe.sc @@ -0,0 +1,198 @@ +# A PE linker script for PowerPC. +# Loosely based on Steve Chamberlain's pe.sc. +# All new mistakes should be credited to Kim Knuttila (krk@cygnus.com) +# +# 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}) +${LIB_SEARCH_DIRS} + +/* Much of this layout was determined by delving into .exe files for + the box generated by other compilers/linkers/etc. This means that + if a particular feature did not happen to appear in one of the + subject files, then it may not be yet supported. +*/ + +/* It's "mainCRTStartup", not "_mainCRTStartup", and it's located in + one of the two .lib files (libc.lib and kernel32.lib) that currently + must be present on the link line. This means that you must use + "-u mainCRTStartup" to make sure it gets included in the link. +*/ + +ENTRY(mainCRTStartup) + +SECTIONS +{ + + /* text - the usual meaning */ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ *(.init);} + *(.text) + *(.gcc_except_table) + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); *(.ctors); *(.ctor); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); LONG (0); } + ${RELOCATING+ *(.fini);} + ${RELOCATING+ etext = .}; + } + + /* rdata - Read Only Runtime Data + CTR sections: All of the CRT (read only C runtime data) sections + appear at the start of the .rdata (read only runtime data) + section, in the following order. Don't know if it matters or not. + Not all sections are always present either. + .rdata: compiler generated read only data + .xdata: compiler generated exception handling table. (Most docs + seem to suggest that this section is now deprecated infavor + of the ydata section) + .edata: The exported names table. + */ + .rdata BLOCK(__section_alignment__) : + { + *(.CRT\$XCA); + *(.CRT\$XCC); + *(.CRT\$XCZ); + *(.CRT\$XIA); + *(.CRT\$XIC); + *(.CRT\$XIZ); + *(.CRT\$XLA); + *(.CRT\$XLZ); + *(.CRT\$XPA); + *(.CRT\$XPX); + *(.CRT\$XPZ); + *(.CRT\$XTA); + *(.CRT\$XTZ); + *(.rdata); + *(.xdata); + } + + .edata BLOCK(__section_alignment__) : + { + *(.edata); + } + + /* data - initialized data + .ydata: exception handling information. + .data: the usual meaning. + .data2: more of the same. + .bss: For some reason, bss appears to be included in the data + section, as opposed to being given a section of it's own. + COMMON: + */ + .data BLOCK(__section_alignment__) : + { + __data_start__ = . ; + *(.ydata); + *(.data); + *(.data2); + __bss_start__ = . ; + *(.bss) ; + *(COMMON); + __bss_end__ = . ; + ${RELOCATING+ end = .}; + __data_end__ = . ; + } + + /* The exception handling table. A sequence of 5 word entries. Section + address and extent are placed in the DataDirectory. + */ + .pdata BLOCK(__section_alignment__) : + { + *(.pdata) + ; + } + + /* The idata section is chock full of magic bits. + 1. Boundaries around various idata parts are used to initialize + some of the fields of the DataDirectory. In particular, the + magic for 2, 4 and 5 are known to be used. Some compilers + appear to generate magic section symbols for this purpose. + Where we can, we catch such symbols and use our own. This of + course is something less than a perfect strategy. + 2. The table of contents is placed immediately after idata4. + The ".private.toc" sections are generated by the ppc bfd. The + .toc variable is generated by gas, and resolved here. It is + used to initialized function descriptors (and anyone else who + needs the address of the module's toc). The only thing + interesting about it at all? Most ppc instructions using it + have a 16bit displacement field. The convention for addressing + is to initialize the .toc value to 32K past the start of the + actual toc, and subtract 32K from all references, thus using + the entire 64K range. Naturally, the reloc code must agree + on this number or you get pretty stupid results. + */ + .idata BLOCK(__section_alignment__) : + { + __idata2_magic__ = .; + *(.idata\$2); + __idata3_magic__ = .; + *(.idata\$3); + __idata4_magic__ = .; + *(.idata\$4); + . = ALIGN(4); + .toc = . + 32768; + *(.private.toc); + __idata5_magic__ = .; + *(.idata\$5); + __idata6_magic__ = .; + *(.idata\$6); + __idata7_magic__ = .; + *(.idata\$7); + ; + } + + /* reldata -- data that requires relocation + */ + .reldata BLOCK(__section_alignment__) : + { + *(.reldata) + ; + } + + + /* Resources */ + .rsrc BLOCK(__section_alignment__) : + { + *(.rsrc\$01) + *(.rsrc\$02) + ; + } + + .stab BLOCK(__section_alignment__) ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + + .stabstr BLOCK(__section_alignment__) ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } + + /* The .reloc section is currently generated by the dlltool from Steve + Chamberlain in a second pass of linking. Section address and extent + are placed in the DataDirectory. + */ + .reloc BLOCK(__section_alignment__) : + { + *(.reloc) + ; + } + + /* We don't do anything useful with codeview debugger support or the + directive section (yet). Hopefully, we junk them correctly. + */ + /DISCARD/ BLOCK(__section_alignment__) : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + ; + } +} +EOF diff --git a/ld/scripttempl/psos.sc b/ld/scripttempl/psos.sc new file mode 100644 index 0000000..ab8c6c7 --- /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 0000000..c801a0c --- /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 0000000..a2f267e --- /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/sh.sc b/ld/scripttempl/sh.sc new file mode 100644 index 0000000..036dd21 --- /dev/null +++ b/ld/scripttempl/sh.sc @@ -0,0 +1,59 @@ +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 0 ${RELOCATING+(NOLOAD)} : + { + *(.stab) + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + *(.stabstr) + } +} +EOF + + + + diff --git a/ld/scripttempl/sparccoff.sc b/ld/scripttempl/sparccoff.sc new file mode 100644 index 0000000..6bbb7ad --- /dev/null +++ b/ld/scripttempl/sparccoff.sc @@ -0,0 +1,48 @@ +# Linker script for Sparc COFF. +# Based on i386coff.sc by Ian Taylor <ian@cygnus.com>. +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/sparclynx.sc b/ld/scripttempl/sparclynx.sc new file mode 100644 index 0000000..c2b1e1d --- /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 0000000..7ee132a --- /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/tic30aout.sc b/ld/scripttempl/tic30aout.sc new file mode 100644 index 0000000..28baed3 --- /dev/null +++ b/ld/scripttempl/tic30aout.sc @@ -0,0 +1,34 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${STACKZERO+${RELOCATING+${STACKZERO}}} +${RELOCATING+PROVIDE (__stack = 0);} +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : + { + CREATE_OBJECT_SYMBOLS + *(.text) + ${RELOCATING+_etext = .;} + ${RELOCATING+__etext = .;} + ${PAD_TEXT+${RELOCATING+. = ${DATA_ALIGNMENT};}} + } + ${RELOCATING+. = ${DATA_ALIGNMENT};} + .data : + { + *(.data) + ${RELOCATING+_edata = .;} + ${RELOCATING+__edata = .;} + } + .bss : + { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+_end = ALIGN(4) }; + ${RELOCATING+__end = ALIGN(4) }; + } +} +EOF diff --git a/ld/scripttempl/tic30coff.sc b/ld/scripttempl/tic30coff.sc new file mode 100644 index 0000000..df2d4f7 --- /dev/null +++ b/ld/scripttempl/tic30coff.sc @@ -0,0 +1,58 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH("${OUTPUT_ARCH}") + +MEMORY +{ + rom : ORIGIN = 0x00000300, LENGTH = 16k + ram : ORIGIN = 0x00000300 + 16k, LENGTH = 16k + ramblk0 : ORIGIN = 0x02026000, LENGTH = 0x1000 + ramblk1 : ORIGIN = 0x02027000, LENGTH = 0x1000 +} + +SECTIONS +{ +.vectors 0x00000000 : +{ + *(vectors) +} + +.text : +{ + *(.text) +} > rom + +.const : +{ + *(.const) + __etext = . ; +} > rom + +.mdata : AT( ADDR(.const) + SIZEOF(.const) ) +{ + __data = . ; + *(.data); + __edata = . ; +} > ram + +.bss : +{ + __bss = . ; + *(.bss); + *(COMMON); + __ebss = . ; +} > ram + +.ram0 : +{ + *(ram0) +} > ramblk0 + +.ram1 : +{ + *(ram1) +} > ramblk1 + +} + +EOF diff --git a/ld/scripttempl/tic80coff.sc b/ld/scripttempl/tic80coff.sc new file mode 100644 index 0000000..2b6f653 --- /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 new file mode 100644 index 0000000..6b2f7e5 --- /dev/null +++ b/ld/scripttempl/v850.sc @@ -0,0 +1,204 @@ +cat << EOF +OUTPUT_FORMAT("elf32-v850", "elf32-v850", + "elf32-v850") +OUTPUT_ARCH(v850) +ENTRY(_start) +SEARCH_DIR(.); +/*/critters/slug/grossman/install/sun4/v850-elf/lib*/ +SECTIONS +{ + /* This saves a little space in the ELF file, since the zda starts + at a higher location that the ELF headers take up. */ + + .zdata ${ZDATA_START_ADDR} : { + *(.zdata) + *(.zbss) + *(reszdata) + *(.zcommon) + } + + /* This is the read only part of the zero data area. + Having it as a seperate section prevents its + attributes from being inherited by the zdata + section. Specifically it prevents the zdata + section from being marked READONLY. */ + + .rozdata ${ROZDATA_START_ADDR} : { + *(.rozdata) + *(romzdata) + *(romzbss) + } + + /* Read-only sections, merged into text segment: */ + . = ${TEXT_START_ADDR}; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.text : { *(.rel.text) } + .rela.text : { *(.rela.text) } + .rel.data : { *(.rel.data) } + .rela.data : { *(.rela.data) } + .rel.rodata : { *(.rel.rodata) } + .rela.rodata : { *(.rela.rodata) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { KEEP (*(.init)) } =0 + .plt : { *(.plt) } + + .text : { + *(.text) + ${RELOCATING+*(.text.*)} + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =0 + + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + + /* This is special code area at the end of the normal text section. + It contains a small lookup table at the start followed by the + code pointed to by entries in the lookup table. */ + + .call_table_data ${CALL_TABLE_START_ADDR} : { + ${RELOCATING+PROVIDE(__ctbp = .);} + *(.call_table_data) + } = 0xff /* fill gaps with 0xff */ + .call_table_text : { + *(.call_table_text) + } + + .fini : { KEEP (*(.fini)) } =0 + .rodata : { *(.rodata) ${RELOCATING+*(.rodata.*)} *(.gnu.linkonce.r*) } + .rodata1 : { *(.rodata1) } + + .data : { + *(.data) + ${RELOCATING+*(.data.*)} + *(.gnu.linkonce.d*) + CONSTRUCTORS + } + .data1 : { *(.data1) } + .ctors : { + ${RELOCATING+___ctors = .;} + KEEP (*(.ctors)) + ${RELOCATING+___ctors_end = .;} + } + + .dtors : { + ${RELOCATING+___dtors = .;} + KEEP (*(.dtors)) + ${RELOCATING+___dtors_end = .;} + } + + .got : { *(.got.plt) *(.got) } + .dynamic : { *(.dynamic) } + + .tdata ${TDATA_START_ADDR} : { + ${RELOCATING+PROVIDE (__ep = .);} + *(.tbyte) + *(.tcommon_byte) + *(.tdata) + *(.tbss) + *(.tcommon) + } + + /* 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 ${SDATA_START_ADDR} : { + ${RELOCATING+PROVIDE (__gp = . + 0x8000);} + *(.sdata) + } + + /* See comment about .rozdata. */ + .rosdata ${ROSDATA_START_ADDR} : { + *(.rosdata) + } + + /* We place the .sbss data section AFTER the .rosdata section, so that + it can directly preceed the .bss section. This allows runtime startup + code to initialise all the zero-data sections by simply taking the + value of '_edata' and zeroing until it reaches '_end' */ + .sbss : { + ${RELOCATING+__sbss_start = .;} + *(.sbss) + *(.scommon) + } + + ${RELOCATING+_edata = DEFINED (__sbss_start) ? __sbss_start : . ;} + ${RELOCATING+PROVIDE (edata = _edata);} + + .bss : + { + ${RELOCATING+__bss_start = DEFINED (__sbss_start) ? __sbss_start : . ;} + ${RELOCATING+__real_bss_start = . ;} + *(.dynbss) + *(.bss) + *(COMMON) + } + + ${RELOCATING+_end = . ;} + ${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) } + .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) } + + /* User stack */ + .stack 0x200000 : { + ${RELOCATING+__stack = .;} + *(.stack) + } + /* These must appear regardless of . */ +} +EOF diff --git a/ld/scripttempl/vanilla.sc b/ld/scripttempl/vanilla.sc new file mode 100644 index 0000000..1798480 --- /dev/null +++ b/ld/scripttempl/vanilla.sc @@ -0,0 +1 @@ +# Nothing to do. diff --git a/ld/scripttempl/w65.sc b/ld/scripttempl/w65.sc new file mode 100644 index 0000000..f904495 --- /dev/null +++ b/ld/scripttempl/w65.sc @@ -0,0 +1,58 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY { + ram : o = 0x1000, l = 512k + } + +SECTIONS +{ +.text : + { + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + + +.tors : { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; +} ${RELOCATING+ > ram} + +.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/z8000.sc b/ld/scripttempl/z8000.sc new file mode 100644 index 0000000..2b87930 --- /dev/null +++ b/ld/scripttempl/z8000.sc @@ -0,0 +1,54 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH("${OUTPUT_ARCH}") +ENTRY(_start) + +SECTIONS +{ +.text ${BIG+ ${RELOCATING+ 0x0000000}} : { + *(.text) + *(.strings) + *(.rdata) + } + +.ctors ${BIG+ ${RELOCATING+ 0x2000000}} : + { + ${RELOCATING+ ___ctors = . ; } + *(.ctors); + ${RELOCATING+ ___ctors_end = . ; } + ___dtors = . ; + *(.dtors); + ${RELOCATING+ ___dtors_end = . ; } + } + +.data ${BIG+ ${RELOCATING+ 0x3000000}} : { + *(.data) + } + +.bss ${BIG+ ${RELOCATING+ 0x4000000}} : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss); + *(COMMON); + ${RELOCATING+ __end_bss = . ; } + } + +.heap ${BIG+ ${RELOCATING+ 0x5000000}} : { + ${RELOCATING+ __start_heap = . ; } + ${RELOCATING+ . = . + 20k ; } + ${RELOCATING+ __end_heap = . ; } + } + +.stack ${RELOCATING+ 0xf000 } : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + ${RELOCATING+ __stack_top = . ; } + } + +} +EOF + + + + |