diff options
Diffstat (limited to 'binutils-2.21/ld/scripttempl')
84 files changed, 12020 insertions, 0 deletions
diff --git a/binutils-2.21/ld/scripttempl/README b/binutils-2.21/ld/scripttempl/README new file mode 100644 index 0000000..26ad2e9 --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/aix.sc b/binutils-2.21/ld/scripttempl/aix.sc new file mode 100644 index 0000000..d592dbe --- /dev/null +++ b/binutils-2.21/ld/scripttempl/aix.sc @@ -0,0 +1,62 @@ +# AIX linker script. +# AIX always uses shared libraries. The section VMA appears to be +# unimportant. The native linker aligns the sections on boundaries +# specified by the -H option. + +cat <<EOF +OUTPUT_ARCH(${ARCH}) +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+ENTRY (__start)} +SECTIONS +{ + .pad 0 : { *(.pad) } + + . = 0x10000000; + .text ${RELOCATING-0} : { + ${RELOCATING+PROVIDE (_text = .);} + *(.text) + *(.pr) + *(.ro) + *(.db) + *(.gl) + *(.xo) + *(.ti) + *(.tb) + ${RELOCATING+PROVIDE (_etext = .);} + } + . = ALIGN (0x10000000); + .data . : { + ${RELOCATING+PROVIDE (_data = .);} + *(.data) + *(.rw) + *(.sv) + *(.sv64) + *(.sv3264) + *(.ua) + . = ALIGN(4); + ${CONSTRUCTING+CONSTRUCTORS} + *(.ds) + *(.tc0) + *(.tc) + *(.td) + ${RELOCATING+PROVIDE (_edata = .);} + } + .bss : { + *(.tocbss) + *(.bss) + *(.bs) + *(.uc) + *(COMMON) + ${RELOCATING+PROVIDE (_end = .);} + ${RELOCATING+PROVIDE (end = .);} + } + + .loader : { + *(.loader) + } + + .debug : { + *(.debug) + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/alpha.sc b/binutils-2.21/ld/scripttempl/alpha.sc new file mode 100644 index 0000000..99565b4 --- /dev/null +++ b/binutils-2.21/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} + +${RELOCATING+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/binutils-2.21/ld/scripttempl/alphavms.sc b/binutils-2.21/ld/scripttempl/alphavms.sc new file mode 100644 index 0000000..406a601 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/alphavms.sc @@ -0,0 +1,49 @@ +# Linker script for Alpha VMS systems. +# Tristan Gingold <gingold@adacore.com>. + +PAGESIZE=0x10000 + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +SECTIONS +{ + ${RELOCATING+. = ${PAGESIZE};} + + /* RW initialized data. */ + \$DATA\$ ALIGN (${PAGESIZE}) : { + *(\$DATA\$) + } + /* RW data unmodified (zero-initialized). */ + \$BSS\$ ALIGN (${PAGESIZE}) : { + *(\$BSS\$) + } + /* RO, executable code. */ + \$CODE\$ ALIGN (${PAGESIZE}) : { + *(\$CODE\$) + } + /* RO initialized data. */ + \$LITERAL\$ ALIGN (${PAGESIZE}) : { + *(\$LINK\$) + *(\$LITERAL\$) + *(\$READONLY\$) + *(\$READONLY_ADDR\$) + *(eh_frame) + *(jcr) + *(ctors) + *(dtors) + *(gcc_except_table) + + /* LIB$INITIALIZE stuff. */ + *(LIB\$INITIALIZDZ) /* Start marker. */ + *(LIB\$INITIALIZD_) /* Hi priority. */ + *(LIB\$INITIALIZE) /* User. */ + *(LIB\$INITIALIZE$) /* End marker. */ + } + + \$DST\$ 0 : { + *(\$DST\$) + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/aout.sc b/binutils-2.21/ld/scripttempl/aout.sc new file mode 100644 index 0000000..80dbb37 --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/armaout.sc b/binutils-2.21/ld/scripttempl/armaout.sc new file mode 100644 index 0000000..9bae887 --- /dev/null +++ b/binutils-2.21/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 = ${DATA_ALIGNMENT};} + ${RELOCATING+__edata = ${DATA_ALIGNMENT};} + } + .bss ${RELOCATING+${DATA_ALIGNMENT}} : + { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+_end = ALIGN(4) }; + ${RELOCATING+__end = ALIGN(4) }; + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/armbpabi.sc b/binutils-2.21/ld/scripttempl/armbpabi.sc new file mode 100644 index 0000000..3049f36 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/armbpabi.sc @@ -0,0 +1,430 @@ +# This variant of elf.sc is used for ARM BPABI platforms, like Symbian +# OS, where a separate postlinker will operated on the generated +# executable or shared object. See elf.sc for configuration variables +# that apply; only BPABI-specific variables will be noted here. + +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=. +test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" +test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" +test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT +DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" +DATA_SEGMENT_RELRO_END="" +DATA_SEGMENT_RELRO_GOTPLT_END="" +DATA_SEGMENT_END="" +if test -n "${COMMONPAGESIZE}"; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" + if test -n "${SEPARATE_GOTPLT}"; then + DATA_SEGMENT_RELRO_GOTPLT_END=". = DATA_SEGMENT_RELRO_END (. + ${SEPARATE_GOTPLT});" + else + DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (.);" + fi +fi +INTERP=".interp 0 : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }" +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" +if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__sbss_start = .);} + ${RELOCATING+PROVIDE (___sbss_start = .);} + *(.dynsbss) + *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) + *(.scommon) + ${RELOCATING+PROVIDE (__sbss_end = .);} + ${RELOCATING+PROVIDE (___sbss_end = .);} + }" + SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" + SDATA="/* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) + }" + SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }" + REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" + REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" + REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } + .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" + REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } + .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" +else + NO_SMALL_DATA=" " +fi +test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " +INIT_ARRAY=".init_array ${RELOCATING-0} : + { + /* SymbianOS uses this symbol. */ + ${RELOCATING+PROVIDE (SHT\$\$INIT_ARRAY\$\$Base = .);} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_start = .);}} + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_end = .);}} + /* SymbianOS uses this symbol. */ + ${RELOCATING+PROVIDE (SHT\$\$INIT_ARRAY\$\$Limit = .);} + }" +FINI_ARRAY=".fini_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_start = .);}} + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_end = .);}} + }" +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)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" +DTOR=".dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+_stack = .;} + *(.stack) + }" + +TEXT_START_ADDR="SEGMENT_START(\"text\", ${TEXT_START_ADDR})" +SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text\", ${SHLIB_TEXT_START_ADDR:-0})" +DATA_ADDR="SEGMENT_START(\"data\", ${DATA_ADDR-${DATA_SEGMENT_ALIGN}})" +SHLIB_DATA_ADDR="SEGMENT_START(\"data\", ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}})" + +# 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" + SHLIB_BASE_ADDRESS="${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" + SHLIB_BASE_ADDRESS="${SHLIB_TEXT_START_ADDR}" +fi + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +${RELOCATING+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. */} + +/* ARM's proprietary toolchain generate these symbols to match the start + and end of particular sections of the image. SymbianOS uses these + symbols. We provide them for compatibility with ARM's toolchains. + These symbols should be bound locally; each shared object may define + its own version of these symbols. */ + +VERSION +{ + /* Give these a dummy version to work around linker lameness. + The name used shouldn't matter as these are all local symbols. */ + __GNU { + local: + Image\$\$ER_RO\$\$Base; + Image\$\$ER_RO\$\$Limit; + SHT\$\$INIT_ARRAY\$\$Base; + SHT\$\$INIT_ARRAY\$\$Limit; + .ARM.exidx\$\$Base; + .ARM.exidx\$\$Limit; + }; +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR});}}} + + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+ . = ${TEXT_BASE_ADDRESS};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}} + + /* Define Image\$\$ER_RO\$\$Base. */ + ${RELOCATING+PROVIDE (Image\$\$ER_RO\$\$Base = .);} + + ${INITIAL_READONLY_SECTIONS} + +EOF +cat <<EOF + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } =${NOP-0} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + /* The SymbianOS kernel requires that the PLT go at the end of the + text section. */ + ${DATA_PLT-${BSS_PLT-${PLT}}} + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + + /* Define Image\$\$ER_RO\$\$Limit. */ + ${RELOCATING+PROVIDE (Image\$\$ER_RO\$\$Limit = .);} + + ${WRITABLE_RODATA-${RODATA}} + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + + /* On SymbianOS, put .init_array and friends in the read-only + segment; there is no runtime relocation applied to these + arrays. */ + + .preinit_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_start = .);}} + KEEP (*(.preinit_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_end = .);}} + } + ${RELOCATING+${INIT_ARRAY}} + ${RELOCATING+${FINI_ARRAY}} + + ${OTHER_READONLY_SECTIONS} + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } + + /* 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-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR};}} + + /* Exception handling */ + .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } + + /* Thread Local Storage sections */ + .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } + .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } + + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } + + ${RELOCATING+${DATARELRO}} + ${OTHER_RELRO_SECTIONS} + ${RELOCATING+${DATA_SEGMENT_RELRO_END}} + + ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}} + ${CREATE_SHLIB+${SDATA2}} + ${CREATE_SHLIB+${SBSS2}} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+. = DEFINED(__bss_segment_start) ? __bss_segment_start : .;} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${SBSS} + ${BSS_PLT+${PLT}} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${RELOCATING+_end = .;} + ${RELOCATING+PROVIDE (end = .);} + ${RELOCATING+${DATA_SEGMENT_END}} + + /* These sections are not mapped under the BPABI. */ + .dynamic 0 : { *(.dynamic) } + .hash 0 : { *(.hash) } + .dynsym 0 : { *(.dynsym) } + .dynstr 0 : { *(.dynstr) } + .gnu.version 0 : { *(.gnu.version) } + .gnu.version_d 0: { *(.gnu.version_d) } + .gnu.version_r 0: { *(.gnu.version_r) } + ${CREATE_SHLIB-${INTERP}} + + /* 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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + ${STACK_ADDR+${STACK}} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_SYMBOLS}} + ${RELOCATING+${DISCARDED}} +EOF + +# These relocations sections are part of the read-only segment in SVR4 +# executables, but are not mapped in BPABI executables. +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT=cat +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init 0 : { *(.rel.init) } + .rela.init 0 : { *(.rela.init) } + .rel.text 0 : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text 0 : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini 0 : { *(.rel.fini) } + .rela.fini 0 : { *(.rela.fini) } + .rel.rodata 0 : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } + .rela.rodata 0 : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data.rel.ro 0 : { *(.rel.data.rel.ro${RELOCATING+*}) } + .rela.data.rel.ro 0 : { *(.rel.data.rel.ro${RELOCATING+*}) } + .rel.data 0 : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data 0 : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + .rel.tdata 0 : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } + .rela.tdata 0 : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } + .rel.tbss 0 : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } + .rela.tbss 0 : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } + .rel.ctors 0 : { *(.rel.ctors) } + .rela.ctors 0 : { *(.rela.ctors) } + .rel.dtors 0 : { *(.rel.dtors) } + .rela.dtors 0 : { *(.rela.dtors) } + ${REL_SDATA} + ${REL_SBSS} + ${REL_SDATA2} + ${REL_SBSS2} + .rel.bss 0 : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } + .rela.bss 0 : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } + .rel.init_array 0 : { *(.rel.init_array) } + .rela.init_array 0 : { *(.rela.init_array) } + .rel.fini_array 0 : { *(.rel.fini_array) } + .rela.fini_array 0 : { *(.rela.fini_array) } +EOF +if [ -n "$COMBRELOC" ]; then +cat <<EOF + .rel.dyn 0 : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC +cat <<EOF + } + .rela.dyn 0 : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC +cat <<EOF + } +EOF +fi +cat <<EOF + .rel.plt 0 : { *(.rel.plt) } + .rela.plt 0 : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} + .rel.other 0 : { *(.rel.*) } + .rela.other 0 : { *(.rela.*) } + .reli.other 0 : { *(.reli.*) } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/armcoff.sc b/binutils-2.21/ld/scripttempl/armcoff.sc new file mode 100644 index 0000000..ebc019a --- /dev/null +++ b/binutils-2.21/ld/scripttempl/armcoff.sc @@ -0,0 +1,84 @@ +# 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 + +# These are substituted in as variables in order to get '}' in a shell +# conditional expansion. +CTOR='.ctor : { + *(SORT(.ctors.*)) + *(.ctor) + }' +DTOR='.dtor : { + *(SORT(.dtors.*)) + *(.dtor) + }' + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +${RELOCATING+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 = .;} + ${RELOCATING+ _etext = .;} + } + .data ${RELOCATING+${DATA_ADDR-0x40000 + (ALIGN(0x8) & 0xfffc0fff)}} : { + ${RELOCATING+ __data_start__ = . ;} + *(.data*) + + ${RELOCATING+*(.gcc_exc*)} + ${RELOCATING+___EH_FRAME_BEGIN__ = . ;} + ${RELOCATING+*(.eh_fram*)} + ${RELOCATING+___EH_FRAME_END__ = . ;} + ${RELOCATING+LONG(0);} + + ${RELOCATING+ __data_end__ = . ;} + ${RELOCATING+ edata = .;} + ${RELOCATING+ _edata = .;} + } + ${CONSTRUCTING+${RELOCATING-$CTOR}} + ${CONSTRUCTING+${RELOCATING-$DTOR}} + .bss ${RELOCATING+ ALIGN(0x8)} : + { + ${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/binutils-2.21/ld/scripttempl/avr.sc b/binutils-2.21/ld/scripttempl/avr.sc new file mode 100644 index 0000000..2a0bc6a --- /dev/null +++ b/binutils-2.21/ld/scripttempl/avr.sc @@ -0,0 +1,234 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + text (rx) : ORIGIN = 0, LENGTH = $TEXT_LENGTH + data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = $DATA_LENGTH + eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t*)} + } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d*)} + } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Internal text space or external memory. */ + .text ${RELOCATING-0} : + { + *(.vectors) + KEEP(*(.vectors)) + + /* For data that needs to reside in the lower 64k of progmem. */ + *(.progmem.gcc*) + *(.progmem*) + ${RELOCATING+. = ALIGN(2);} + + ${CONSTRUCTING+ __trampolines_start = . ; } + /* The jump trampolines for the 16-bit limited relocs will reside here. */ + *(.trampolines) + *(.trampolines*) + ${CONSTRUCTING+ __trampolines_end = . ; } + + /* For future tablejump instruction arrays for 3 byte pc devices. + We don't relax jump/call instructions within these sections. */ + *(.jumptables) + *(.jumptables*) + + /* For code that needs to reside in the lower 128k progmem. */ + *(.lowtext) + *(.lowtext*) + + ${CONSTRUCTING+ __ctors_start = . ; } + ${CONSTRUCTING+ *(.ctors) } + ${CONSTRUCTING+ __ctors_end = . ; } + ${CONSTRUCTING+ __dtors_start = . ; } + ${CONSTRUCTING+ *(.dtors) } + ${CONSTRUCTING+ __dtors_end = . ; } + KEEP(SORT(*)(.ctors)) + KEEP(SORT(*)(.dtors)) + + /* From this point on, we don't bother about wether the insns are + below or above the 16 bits boundary. */ + *(.init0) /* Start here after reset. */ + KEEP (*(.init0)) + *(.init1) + KEEP (*(.init1)) + *(.init2) /* Clear __zero_reg__, set up stack pointer. */ + KEEP (*(.init2)) + *(.init3) + KEEP (*(.init3)) + *(.init4) /* Initialize data and BSS. */ + KEEP (*(.init4)) + *(.init5) + KEEP (*(.init5)) + *(.init6) /* C++ constructors. */ + KEEP (*(.init6)) + *(.init7) + KEEP (*(.init7)) + *(.init8) + KEEP (*(.init8)) + *(.init9) /* Call main(). */ + KEEP (*(.init9)) + *(.text) + ${RELOCATING+. = ALIGN(2);} + *(.text.*) + ${RELOCATING+. = ALIGN(2);} + *(.fini9) /* _exit() starts here. */ + KEEP (*(.fini9)) + *(.fini8) + KEEP (*(.fini8)) + *(.fini7) + KEEP (*(.fini7)) + *(.fini6) /* C++ destructors. */ + KEEP (*(.fini6)) + *(.fini5) + KEEP (*(.fini5)) + *(.fini4) + KEEP (*(.fini4)) + *(.fini3) + KEEP (*(.fini3)) + *(.fini2) + KEEP (*(.fini2)) + *(.fini1) + KEEP (*(.fini1)) + *(.fini0) /* Infinite loop after program termination. */ + KEEP (*(.fini0)) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > text} + + .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))} + { + ${RELOCATING+ PROVIDE (__data_start = .) ; } + *(.data) + *(.data*) + *(.rodata) /* We need to include .rodata here if gcc is used */ + *(.rodata*) /* with -fdata-sections. */ + *(.gnu.linkonce.d*) + ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+ _edata = . ; } + ${RELOCATING+ PROVIDE (__data_end = .) ; } + } ${RELOCATING+ > data} + + .bss ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))} + { + ${RELOCATING+ PROVIDE (__bss_start = .) ; } + *(.bss) + *(.bss*) + *(COMMON) + ${RELOCATING+ PROVIDE (__bss_end = .) ; } + } ${RELOCATING+ > data} + + ${RELOCATING+ __data_load_start = LOADADDR(.data); } + ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); } + + /* Global data not cleared after reset. */ + .noinit ${RELOCATING-0}: + { + ${RELOCATING+ PROVIDE (__noinit_start = .) ; } + *(.noinit*) + ${RELOCATING+ PROVIDE (__noinit_end = .) ; } + ${RELOCATING+ _end = . ; } + ${RELOCATING+ PROVIDE (__heap_start = .) ; } + } ${RELOCATING+ > data} + + .eeprom ${RELOCATING-0}: + { + *(.eeprom*) + ${RELOCATING+ __eeprom_end = . ; } + } ${RELOCATING+ > eeprom} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } +} +EOF + diff --git a/binutils-2.21/ld/scripttempl/crisaout.sc b/binutils-2.21/ld/scripttempl/crisaout.sc new file mode 100644 index 0000000..c58f56d --- /dev/null +++ b/binutils-2.21/ld/scripttempl/crisaout.sc @@ -0,0 +1,133 @@ +cat <<EOF +OUTPUT_FORMAT("a.out-cris") +OUTPUT_ARCH(cris) +${RELOCATING+ENTRY (__start)} +SECTIONS +{ + .text ${RELOCATING+ ${TEXT_START_ADDR}}: + { + CREATE_OBJECT_SYMBOLS; + ${CONSTRUCTING+ __Stext = .;} + ${RELOCATING+*(.startup)} + *(.text) + ${CONSTRUCTING+__start = DEFINED(__start) ? __start : + DEFINED(_start) ? _start : + DEFINED(start) ? start : + DEFINED(.startup) ? .startup + 2 : 2;} + ${RELOCATING+*(.text.*)} + ${RELOCATING+*(.gnu.linkonce.t*)} + ${RELOCATING+*(.rodata)} + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + + /* Do not "provide" init-start and fini-start symbols; they might be + referred to weakly, so the linker would not override the zero + default. + FIXME: It's somewhat unexpected to have code emitted by the linker + script. Some other mechanism could probably do better. */ + ${CONSTRUCTING+ . = ALIGN (2);} + ${CONSTRUCTING+ ___init__start = .;} + ${CONSTRUCTING+ PROVIDE (___do_global_ctors = .);} + ${CONSTRUCTING+ SHORT (0xe1fc); /* push srp */} + ${CONSTRUCTING+ SHORT (0xbe7e);} + ${CONSTRUCTING+ *(.init)} + ${CONSTRUCTING+ SHORT (0x0d3e); /* jump [sp+] */} + ${CONSTRUCTING+ PROVIDE (__init__end = .);} + ${CONSTRUCTING+ PROVIDE (___init__end = .);} + + ${CONSTRUCTING+ . = ALIGN (2);} + ${CONSTRUCTING+ ___fini__start = .;} + ${CONSTRUCTING+ PROVIDE (___do_global_dtors = .);} + ${CONSTRUCTING+ SHORT (0xe1fc); /* push srp */} + ${CONSTRUCTING+ SHORT (0xbe7e);} + ${CONSTRUCTING+ *(.fini)} + ${CONSTRUCTING+ SHORT (0x0d3e); /* jump [sp+] */} + ${CONSTRUCTING+ PROVIDE (__fini__end = .);} + ${CONSTRUCTING+ ___fini__end = .;} + + /* Cater to linking from ELF. */ + ${CONSTRUCTING+ PROVIDE(___ctors = .);} + ${CONSTRUCTING+ ___elf_ctors_dtors_begin = .;} + ${CONSTRUCTING+ KEEP (*crtbegin.o(.ctors))} + ${CONSTRUCTING+ KEEP (*crtbegin?.o(.ctors))} + ${CONSTRUCTING+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors))} + ${CONSTRUCTING+ KEEP (*(SORT(.ctors.*)))} + ${CONSTRUCTING+ KEEP (*(.ctors))} + ${CONSTRUCTING+ PROVIDE(___ctors_end = .);} + + ${CONSTRUCTING+ PROVIDE(___dtors = .);} + ${CONSTRUCTING+ KEEP (*crtbegin.o(.dtors))} + ${CONSTRUCTING+ KEEP (*crtbegin?.o(.dtors))} + ${CONSTRUCTING+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors))} + ${CONSTRUCTING+ KEEP (*(SORT(.dtors.*)))} + ${CONSTRUCTING+ KEEP (*(.dtors))} + ${CONSTRUCTING+ PROVIDE(___dtors_end = .);} + ${CONSTRUCTING+ ___elf_ctors_dtors_end = .;} + + /* We include objects that force alignment of the data segment. + Unfortunately that sometimes causes a gap between .text and .data, + which is not detectable since .data does not have a start address + of itself in the a.out header. This should only matter for + testing; for production use, .data is at a "known" location. + We assume .data does not get an alignment larger than 32 bytes. */ + ${CONSTRUCTING+. = ALIGN (32);} + + ${CONSTRUCTING+ __Etext = .;} + + /* Deprecated, use __Etext. */ + ${CONSTRUCTING+ PROVIDE(_etext = .);} + } + + /* Any dot-relative start-expression (such as "ALIGN(2)", also including + the "default" .data alignment expression) will use the initial, raw + size of .text and will be incorrect if the alignment used is less + than the alignment for .text (which might depend on input and obj + format). FIXME: Seems like a bug in ld. Seems hard to fix. Seems + unimportant. */ + .data : + { + ${CONSTRUCTING+ __Sdata = .;} + *(.data); + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d*)} + ${RELOCATING+*(.eh_frame) /* FIXME: Make .text */} + ${RELOCATING+*(.gcc_except_table)} + + /* See comment at ALIGN before __Etext. */ + ${CONSTRUCTING+. = ALIGN (32);} + + ${CONSTRUCTING+ __Edata = .;} + + /* Deprecated, use __Edata. */ + ${CONSTRUCTING+ PROVIDE(_edata = .);} + } + + .bss : + { + /* Deprecated, use __Sbss. */ + ${CONSTRUCTING+ PROVIDE(_bss_start = .);} + + ${CONSTRUCTING+ __Sbss = .;} + *(.bss) + ${RELOCATING+*(.bss.*)} + *(COMMON) + ${CONSTRUCTING+ __Ebss = .;} + + /* Deprecated, use __Ebss or __Eall as appropriate. */ + ${CONSTRUCTING+ PROVIDE(_end = .);} + ${CONSTRUCTING+ PROVIDE(__end = .);} + } + ${CONSTRUCTING+ __Eall = .;} + + /* Unfortunately, stabs are not mappable from ELF to a.out. + It can probably be fixed with some amount of work. */ + /DISCARD/ : + { *(.stab) *(.stab*) *(.debug) *(.debug*) *(.comment) *(.gnu.warning.*) } + + /* For the rsim and xsim simulators. */ + ${CONSTRUCTING+ PROVIDE(__Endmem = 0x10000000);} + + /* For elinux. */ + ${CONSTRUCTING+ PROVIDE(__Stacksize = 0);} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/delta68.sc b/binutils-2.21/ld/scripttempl/delta68.sc new file mode 100644 index 0000000..fb196f3 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/delta68.sc @@ -0,0 +1,49 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+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/binutils-2.21/ld/scripttempl/dlx.sc b/binutils-2.21/ld/scripttempl/dlx.sc new file mode 100644 index 0000000..b222b33 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/dlx.sc @@ -0,0 +1,30 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : + { + CREATE_OBJECT_SYMBOLS + *(.text) + ${RELOCATING+etext = ${DATA_ALIGNMENT};} + } + ${RELOCATING+. = ${DATA_ALIGNMENT};} + .data : + { + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+edata = .;} + } + .bss : + { + *(.bss) + *(COMMON) + ${RELOCATING+end = . }; + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf.sc b/binutils-2.21/ld/scripttempl/elf.sc new file mode 100644 index 0000000..f020a66 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf.sc @@ -0,0 +1,613 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not +# empty. +# SMALL_DATA_CTOR - .ctors contains small data. +# SMALL_DATA_DTOR - .dtors contains small data. +# 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_RELRO_SECTIONS - other than .data.rel.ro ... +# (e.g. PPC32 .fixup, .got[12]) +# OTHER_BSS_SECTIONS - other than .bss .sbss ... +# ATTRS_SECTIONS - at the end +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_ADDR - the first byte of the text segment, after any +# headers. +# TEXT_BASE_ADDRESS - the first byte of the text segment. +# 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. +# DATA_END_SYMBOLS - symbols that appear at the end of the +# writeable data sections. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. +# BSS_PLT - .plt should be in bss segment +# NO_REL_RELOCS - Don't include .rel.* sections in script +# NO_RELA_RELOCS - Don't include .rela.* sections in script +# NON_ALLOC_DYN - Place dynamic sections after data segment. +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# STACK_ADDR - start of a .stack section. +# OTHER_SYMBOLS - symbols to place right at the end of the script. +# ETEXT_NAME - name of a symbol for the end of the text section, +# normally etext. +# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, +# so that .got can be in the RELRO area. It should be set to +# the number of bytes in the beginning of .got.plt which can be +# in the RELRO area as well. +# USER_LABEL_PREFIX - prefix to add to user-visible symbols. +# RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names +# for standard sections, without initial "." or suffixes. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# .debug_info .gnu.linkonce.wi.foo +# .tdata .gnu.linkonce.td.foo +# .tbss .gnu.linkonce.tb.foo +# .lrodata .gnu.linkonce.lr.foo +# .ldata .gnu.linkonce.l.foo +# .lbss .gnu.linkonce.lb.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$RODATA_NAME" && RODATA_NAME=rodata +test -z "$SDATA_NAME" && SDATA_NAME=sdata +test -z "$SBSS_NAME" && SBSS_NAME=sbss +test -z "$BSS_NAME" && BSS_NAME=bss +test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_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=. +test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext +test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" +test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" +test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT +test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" +DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" +DATA_SEGMENT_RELRO_END="" +DATA_SEGMENT_END="" +if test -n "${COMMONPAGESIZE}"; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" + DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" +fi +if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then + INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" +fi +if test -z "$PLT"; then + IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" + PLT=".plt ${RELOCATING-0} : { *(.plt)${IREL_IN_PLT+ *(.iplt)} } + ${IREL_IN_PLT-$IPLT}" +fi +test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes +if test -z "$GOT"; then + if test -z "$SEPARATE_GOTPLT"; then + GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }" + else + GOT=".got ${RELOCATING-0} : { *(.got) *(.igot) }" + GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) }" + fi +fi +REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }" +RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }" +REL_IPLT=".rel.iplt ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}} + *(.rel.iplt) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}} + }" +RELA_IPLT=".rela.iplt ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}} + *(.rela.iplt) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}} + }" +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" +DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }" +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" +if test -z "${NO_SMALL_DATA}"; then + SBSS=".${SBSS_NAME} ${RELOCATING-0} : + { + ${RELOCATING+${SBSS_START_SYMBOLS}} + ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)} + *(.dyn${SBSS_NAME}) + *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*}) + *(.scommon) + ${RELOCATING+${SBSS_END_SYMBOLS}} + }" + SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }" + SDATA="/* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .${SDATA_NAME} ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)} + *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*}) + }" + SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} : + { + ${RELOCATING+${SDATA2_START_SYMBOLS}} + *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*}) + }" + REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) } + .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }" + REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) } + .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }" + REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) } + .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }" + REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) } + .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }" +else + NO_SMALL_DATA=" " +fi +if test -z "${DATA_GOT}"; then + if test -n "${NO_SMALL_DATA}"; then + DATA_GOT=" " + fi +fi +if test -z "${SDATA_GOT}"; then + if test -z "${NO_SMALL_DATA}"; then + SDATA_GOT=" " + fi +fi +test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " +test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" + .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } + .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } + .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } + .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } + .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } + .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" +test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS=" + ${OTHER_BSS_SECTIONS} + .lbss ${RELOCATING-0} : + { + *(.dynlbss) + *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) + *(LARGE_COMMON) + }" +test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" + .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : + { + *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) + } + .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : + { + *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) + ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + }" +INIT_ARRAY=".init_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} + }" +FINI_ARRAY=".fini_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} + }" +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)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" +DTOR=".dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} + *(.stack) + }" + +TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" +SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" + +# 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}) +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} + ${INITIAL_READONLY_SECTIONS} + .note.gnu.build-id : { *(.note.gnu.build-id) } +EOF + +test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN +test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= +cat > ldscripts/dyntmp.$$ <<EOF + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } +EOF + +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + ${INITIAL_RELOC_SECTIONS} + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) } + .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) } + .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) } + .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + ${OTHER_READWRITE_RELOC_SECTIONS} + .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } + .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } + .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } + .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + ${REL_SDATA} + ${REL_SBSS} + ${REL_SDATA2} + ${REL_SBSS2} + .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) } + .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) } + ${REL_LARGE} + ${IREL_IN_PLT+$REL_IFUNC} + ${IREL_IN_PLT+$RELA_IFUNC} + ${IREL_IN_PLT-$REL_IPLT} + ${IREL_IN_PLT-$RELA_IPLT} +EOF + +if [ -n "$COMBRELOC" ]; then +cat >> ldscripts/dyntmp.$$ <<EOF + .rel.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ +cat >> ldscripts/dyntmp.$$ <<EOF + } + .rela.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ +cat >> ldscripts/dyntmp.$$ <<EOF + } +EOF +fi + +cat >> ldscripts/dyntmp.$$ <<EOF + .rel.plt ${RELOCATING-0} : + { + *(.rel.plt) + ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}} + ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}} + ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}} + } + .rela.plt ${RELOCATING-0} : + { + *(.rela.plt) + ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}} + ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}} + ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}} + } + ${OTHER_PLT_RELOC_SECTIONS} +EOF + +if test -z "${NON_ALLOC_DYN}"; then + if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then + cat ldscripts/dyntmp.$$ + else + if test -z "${NO_REL_RELOCS}"; then + sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$ + fi + if test -z "${NO_RELA_RELOCS}"; then + sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$ + fi + fi + rm -f ldscripts/dyntmp.$$ +fi + +cat <<EOF + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } =${NOP-0} + + ${TEXT_PLT+${PLT}} + ${TINY_READONLY_SECTION} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + ${RELOCATING+*(.text.unlikely .text.*_unlikely)} + ${RELOCATING+*(.text.exit .text.exit.*)} + ${RELOCATING+*(.text.startup .text.startup.*)} + ${RELOCATING+*(.text.hot .text.hot.*)} + *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} + ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} + ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} + ${WRITABLE_RODATA-${RODATA}} + .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) } + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${OTHER_READONLY_SECTIONS} + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } + + /* 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-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + + /* Exception handling */ + .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + + /* Thread Local Storage sections */ + .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } + .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } + + .preinit_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} + KEEP (*(.preinit_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} + } + ${RELOCATING+${INIT_ARRAY}} + ${RELOCATING+${FINI_ARRAY}} + ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} + ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} + .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } + + ${RELOCATING+${DATARELRO}} + ${OTHER_RELRO_SECTIONS} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${DATA_GOT+${RELRO_NOW+${GOT}}} + ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} + ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} + ${RELOCATING+${DATA_SEGMENT_RELRO_END}} + ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} + ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} + + ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} + ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} + ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}} + ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}} + ${SDATA_GOT+${GOT}} + ${SDATA_GOT+${OTHER_GOT_SECTIONS}} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} + ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${SBSS} + ${BSS_PLT+${PLT}} + .${BSS_NAME} ${RELOCATING-0} : + { + *(.dyn${BSS_NAME}) + *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*}) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + } + ${OTHER_BSS_SECTIONS} + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${LARGE_SECTIONS} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} + ${RELOCATING+${DATA_SEGMENT_END}} +EOF + +if test -n "${NON_ALLOC_DYN}"; then + if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then + cat ldscripts/dyntmp.$$ + else + if test -z "${NO_REL_RELOCS}"; then + sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$ + fi + if test -z "${NO_RELA_RELOCS}"; then + sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$ + fi + fi + rm -f ldscripts/dyntmp.$$ +fi + +cat <<EOF + /* 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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes .zdebug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges .zdebug_ranges) } + + ${TINY_DATA_SECTION} + ${TINY_BSS_SECTION} + + ${STACK_ADDR+${STACK}} + ${ATTRS_SECTIONS} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_SYMBOLS}} + ${RELOCATING+${DISCARDED}} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32cr16.sc b/binutils-2.21/ld/scripttempl/elf32cr16.sc new file mode 100644 index 0000000..b40bfbd --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32cr16.sc @@ -0,0 +1,169 @@ +# Linker Script for National Semiconductor's CR16-ELF32. + +# The next line should be uncommented if it is desired to link +# without libstart.o and directly enter main. + +# ENTRY=_main + +test -z "$ENTRY" && ENTRY=_start +cat <<EOF + +/* Example Linker Script for linking NS CR16 elf32 files. */ + +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+ENTRY(${ENTRY})} + +/* Define memory regions. */ +MEMORY +{ + rom : ORIGIN = 0x2, LENGTH = 3M + ram : ORIGIN = 4M, LENGTH = 10M +} + +/* Many sections come in three flavours. There is the 'real' section, + like ".data". Then there are the per-procedure or per-variable + sections, generated by -ffunction-sections and -fdata-sections in GCC, + and useful for --gc-sections, which for a variable "foo" might be + ".data.foo". Then there are the linkonce sections, for which the linker + eliminates duplicates, which are named like ".gnu.linkonce.d.foo". + The exact correspondences are: + + Section Linkonce section + .text .gnu.linkonce.t.foo + .rdata .gnu.linkonce.r.foo + .data .gnu.linkonce.d.foo + .bss .gnu.linkonce.b.foo + .debug_info .gnu.linkonce.wi.foo */ + +SECTIONS +{ + .init : + { + __INIT_START = .; + KEEP (*(.init)) + __INIT_END = .; + } > rom + + .fini : + { + __FINI_START = .; + KEEP (*(.fini)) + __FINI_END = .; + } > rom + + .jcr : + { + KEEP (*(.jcr)) + } > rom + + .text : + { + __TEXT_START = .; + *(.text) *(.text.*) *(.gnu.linkonce.t.*) + __TEXT_END = .; + } > rom + + .rdata : + { + __RDATA_START = .; + *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*) + __RDATA_END = .; + } > rom + + .ctor ALIGN(4) : + { + __CTOR_START = .; + /* The compiler 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 + 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)) + __CTOR_END = .; + } > rom + + .dtor ALIGN(4) : + { + __DTOR_START = .; + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END = .; + } > rom + + .data : + { + __DATA_START = .; + *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*) + __DATA_END = .; + } > ram AT > rom + + .bss (NOLOAD) : + { + __BSS_START = .; + *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*) + __BSS_END = .; + } > ram + +/* You may change the sizes of the following sections to fit the actual + size your program requires. + + The heap and stack are aligned to the bus width, as a speed optimization + for accessing data located there. */ + + .heap (NOLOAD) : + { + . = ALIGN(4); + __HEAP_START = .; + . += 0x2000; __HEAP_MAX = .; + } > ram + + .stack (NOLOAD) : + { + . = ALIGN(4); + . += 0x6000; + __STACK_START = .; + } > ram + + .istack (NOLOAD) : + { + . = ALIGN(4); + . += 0x100; + __ISTACK_START = .; + } > ram + + .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. */ + + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } +} + +__DATA_IMAGE_START = LOADADDR(.data); +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32cr16c.sc b/binutils-2.21/ld/scripttempl/elf32cr16c.sc new file mode 100644 index 0000000..84fc61c --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32cr16c.sc @@ -0,0 +1,45 @@ +# Linker Script for National Semiconductor's CR16C-ELF32. + +test -z "$ENTRY" && ENTRY=_start +cat <<EOF + +/* Example Linker Script for linking NS CR16C or CR16CPlus + elf32 files, which were compiled with either the near data + model or the default data model. */ + +${RELOCATING+ENTRY(${ENTRY})} + +MEMORY +{ + near_rom : ORIGIN = 0x4, LENGTH = 512K - 4 + near_ram : ORIGIN = 512K, LENGTH = 512K - 64K + rom : ORIGIN = 1M, LENGTH = 3M + ram : ORIGIN = 4M, LENGTH = 10M +} + +SECTIONS +{ +/* The heap is located in near memory, to suit both the near and + default data models. The heap and stack are aligned to the bus + width, as a speed optimization for accessing data located + there. The alignment to 4 bytes is compatible for both the CR16C + bus width (2 bytes) and CR16CPlus bus width (4 bytes). */ + + .text : { __TEXT_START = .; *(.text) __TEXT_END = .; } > rom + .rdata : { __RDATA_START = .; *(.rdata_4) *(.rdata_2) *(.rdata_1) __RDATA_END = .; } > near_rom + .ctor ALIGN(4) : { __CTOR_LIST = .; *(.ctors) __CTOR_END = .; } > near_rom + .dtor ALIGN(4) : { __DTOR_LIST = .; *(.dtors) __DTOR_END = .; } > near_rom + .data : { __DATA_START = .; *(.data_4) *(.data_2) *(.data_1) *(.data) __DATA_END = .; } > ram AT > rom + .bss (NOLOAD) : { __BSS_START = .; *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) __BSS_END = .; } > ram + .nrdata : { __NRDATA_START = .; *(.nrdat_4) *(.nrdat_2) *(.nrdat_1) __NRDATA_END = .; } > near_rom + .ndata : { __NDATA_START = .; *(.ndata_4) *(.ndata_2) *(.ndata_1) __NDATA_END = .; } > near_ram AT > rom + .nbss (NOLOAD) : { __NBSS_START = .; *(.nbss_4) *(.nbss_2) *(.nbss_1) *(.ncommon) __NBSS_END = .; } > near_ram + .heap (NOLOAD) : { . = ALIGN(4); __HEAP_START = .; . += 0x2000; __HEAP_MAX = .; } > near_ram + .stack (NOLOAD) : { . = ALIGN(4); . += 0x6000; __STACK_START = .; } > ram + .istack (NOLOAD) : { . = ALIGN(2); . += 0x100; __ISTACK_START = .; } > ram +} + +__DATA_IMAGE_START = LOADADDR(.data); +__NDATA_IMAGE_START = LOADADDR(.ndata); + +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32crx.sc b/binutils-2.21/ld/scripttempl/elf32crx.sc new file mode 100644 index 0000000..e36e27f --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32crx.sc @@ -0,0 +1,171 @@ +# Linker Script for National Semiconductor's CRX-ELF32. + +# The next line should be uncommented if it is desired to link +# without libstart.o and directly enter main. + +# ENTRY=_main + +test -z "$ENTRY" && ENTRY=_start +cat <<EOF + +/* Example Linker Script for linking NS CRX elf32 files. */ + +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+ENTRY(${ENTRY})} + +/* Define memory regions. */ +MEMORY +{ + rom : ORIGIN = 0x2, LENGTH = 3M + ram : ORIGIN = 4M, LENGTH = 10M +} + +/* Many sections come in three flavours. There is the 'real' section, + like ".data". Then there are the per-procedure or per-variable + sections, generated by -ffunction-sections and -fdata-sections in GCC, + and useful for --gc-sections, which for a variable "foo" might be + ".data.foo". Then there are the linkonce sections, for which the linker + eliminates duplicates, which are named like ".gnu.linkonce.d.foo". + The exact correspondences are: + + Section Linkonce section + .text .gnu.linkonce.t.foo + .rdata .gnu.linkonce.r.foo + .data .gnu.linkonce.d.foo + .bss .gnu.linkonce.b.foo + .debug_info .gnu.linkonce.wi.foo */ + +SECTIONS +{ + .init : + { + __INIT_START = .; + KEEP (*(.init)) + __INIT_END = .; + } > rom + + .fini : + { + __FINI_START = .; + KEEP (*(.fini)) + __FINI_END = .; + } > rom + + .jcr : + { + KEEP (*(.jcr)) + } > rom + + .text : + { + __TEXT_START = .; + *(.text) *(.text.*) *(.gnu.linkonce.t.*) + __TEXT_END = .; + } > rom + + .rdata : + { + __RDATA_START = .; + *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata.*) + __RDATA_END = .; + } > rom + + .ctor ALIGN(4) : + { + __CTOR_START = .; + /* The compiler 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)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END = .; + } > rom + + .dtor ALIGN(4) : + { + __DTOR_START = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END = .; + } > rom + + .data : + { + __DATA_START = .; + *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*) + __DATA_END = .; + } > ram AT > rom + + .bss (NOLOAD) : + { + __BSS_START = .; + *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*) + __BSS_END = .; + } > ram + +/* You may change the sizes of the following sections to fit the actual + size your program requires. + + The heap and stack are aligned to the bus width, as a speed optimization + for accessing data located there. */ + + .heap (NOLOAD) : + { + . = ALIGN(4); + __HEAP_START = .; + . += 0x2000; __HEAP_MAX = .; + } > ram + + .stack (NOLOAD) : + { + . = ALIGN(4); + . += 0x6000; + __STACK_START = .; + } > ram + + .istack (NOLOAD) : + { + . = ALIGN(4); + . += 0x100; + __ISTACK_START = .; + } > ram + + .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. */ + + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } +} + +__DATA_IMAGE_START = LOADADDR(.data); +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32msp430.sc b/binutils-2.21/ld/scripttempl/elf32msp430.sc new file mode 100644 index 0000000..54c35be --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32msp430.sc @@ -0,0 +1,249 @@ +#!/bin/sh + +HEAP_SECTION_MSP430=" " +HEAP_MEMORY_MSP430=" " + +if test ${GOT_HEAP_MSP-0} -ne 0 +then +HEAP_SECTION_MSP430=".heap ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__heap_data_start = .) ; } + *(.heap*) + ${RELOCATING+ PROVIDE (_heap_data_end = .) ; } + ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+ PROVIDE (__heap_bottom = .) ; } + ${RELOCATING+ PROVIDE (__heap_top = ${HEAP_START} + ${HEAP_LENGTH}) ; } + } ${RELOCATING+ > heap}" +HEAP_MEMORY_MSP430="heap(rwx) : ORIGIN = $HEAP_START, LENGTH = $HEAP_LENGTH" +fi + + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + text (rx) : ORIGIN = $ROM_START, LENGTH = $ROM_SIZE + data (rwx) : ORIGIN = $RAM_START, LENGTH = $RAM_SIZE + vectors (rw) : ORIGIN = 0xffe0, LENGTH = 0x20 + bootloader(rx) : ORIGIN = 0x0c00, LENGTH = 1K + infomem(rx) : ORIGIN = 0x1000, LENGTH = 256 + infomemnobits(rx) : ORIGIN = 0x1000, LENGTH = 256 + ${HEAP_MEMORY_MSP430} +} + +SECTIONS +{ + /* Read-only sections, merged into text segment. */ + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t*)} + } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d*)} + } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Internal text space. */ + .text : + { + ${RELOCATING+. = ALIGN(2);} + *(.init) + *(.init0) /* Start here after reset. */ + *(.init1) + *(.init2) /* Copy data loop */ + *(.init3) + *(.init4) /* Clear bss */ + *(.init5) + *(.init6) /* C++ constructors. */ + *(.init7) + *(.init8) + *(.init9) /* Call main(). */ + + ${CONSTRUCTING+ __ctors_start = . ; } + ${CONSTRUCTING+ *(.ctors) } + ${CONSTRUCTING+ __ctors_end = . ; } + ${CONSTRUCTING+ __dtors_start = . ; } + ${CONSTRUCTING+ *(.dtors) } + ${CONSTRUCTING+ __dtors_end = . ; } + + ${RELOCATING+. = ALIGN(2);} + *(.text) + ${RELOCATING+. = ALIGN(2);} + *(.text.*) + + ${RELOCATING+. = ALIGN(2);} + *(.fini9) /* */ + *(.fini8) + *(.fini7) + *(.fini6) /* C++ destructors. */ + *(.fini5) + *(.fini4) + *(.fini3) + *(.fini2) + *(.fini1) + *(.fini0) /* Infinite loop after program termination. */ + *(.fini) + + _etext = .; + } ${RELOCATING+ > text} + + .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))} + { + ${RELOCATING+ PROVIDE (__data_start = .) ; } + ${RELOCATING+. = ALIGN(2);} + *(.data) + ${RELOCATING+. = ALIGN(2);} + *(.gnu.linkonce.d*) + ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > data} + + /* Bootloader. */ + .bootloader ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__boot_start = .) ; } + *(.bootloader) + ${RELOCATING+. = ALIGN(2);} + *(.bootloader.*) + } ${RELOCATING+ > bootloader} + + /* Information memory. */ + .infomem ${RELOCATING-0} : + { + *(.infomem) + ${RELOCATING+. = ALIGN(2);} + *(.infomem.*) + } ${RELOCATING+ > infomem} + + /* Information memory (not loaded into MPU). */ + .infomemnobits ${RELOCATING-0} : + { + *(.infomemnobits) + ${RELOCATING+. = ALIGN(2);} + *(.infomemnobits.*) + } ${RELOCATING+ > infomemnobits} + + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + ${RELOCATING+ PROVIDE (__bss_start = .) ; } + *(.bss) + *(COMMON) + ${RELOCATING+ PROVIDE (__bss_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > data} + + .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} : + { + ${RELOCATING+ PROVIDE (__noinit_start = .) ; } + *(.noinit) + *(COMMON) + ${RELOCATING+ PROVIDE (__noinit_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > data} + + .vectors ${RELOCATING-0}: + { + ${RELOCATING+ PROVIDE (__vectors_start = .) ; } + *(.vectors*) + ${RELOCATING+ _vectors_end = . ; } + } ${RELOCATING+ > vectors} + + ${HEAP_SECTION_MSP430} + + /* Stabs for profiling information*/ + .profiler 0 : { *(.profiler) } + + /* 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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + PROVIDE (__stack = ${STACK}) ; + PROVIDE (__data_start_rom = _etext) ; + PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ; + PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ; + PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ; + PROVIDE (__subdevice_has_heap = ${GOT_HEAP_MSP-0}) ; +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32msp430_3.sc b/binutils-2.21/ld/scripttempl/elf32msp430_3.sc new file mode 100644 index 0000000..1c44d93 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32msp430_3.sc @@ -0,0 +1,192 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + text (rx) : ORIGIN = $ROM_START, LENGTH = $ROM_SIZE + data (rwx) : ORIGIN = $RAM_START, LENGTH = $RAM_SIZE + vectors (rw) : ORIGIN = 0xffe0, LENGTH = 0x20 +} + +SECTIONS +{ + /* Read-only sections, merged into text segment. */ + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t*)} + } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d*)} + } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Internal text space. */ + .text : + { + ${RELOCATING+. = ALIGN(2);} + *(.init) + *(.init0) /* Start here after reset. */ + *(.init1) + *(.init2) + *(.init3) + *(.init4) + *(.init5) + *(.init6) /* C++ constructors. */ + *(.init7) + *(.init8) + *(.init9) /* Call main(). */ + + ${CONSTRUCTING+ __ctors_start = . ; } + ${CONSTRUCTING+ *(.ctors) } + ${CONSTRUCTING+ __ctors_end = . ; } + ${CONSTRUCTING+ __dtors_start = . ; } + ${CONSTRUCTING+ *(.dtors) } + ${CONSTRUCTING+ __dtors_end = . ; } + + ${RELOCATING+. = ALIGN(2);} + *(.text) + ${RELOCATING+. = ALIGN(2);} + *(.text.*) + + ${RELOCATING+. = ALIGN(2);} + *(.fini9) + *(.fini8) + *(.fini7) + *(.fini6) /* C++ destructors. */ + *(.fini5) + *(.fini4) + *(.fini3) + *(.fini2) + *(.fini1) + *(.fini0) /* Infinite loop after program termination. */ + *(.fini) + + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > text} + + .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))} + { + ${RELOCATING+ PROVIDE (__data_start = .) ; } + *(.data) + *(.gnu.linkonce.d*) + ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > data} + + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + ${RELOCATING+ PROVIDE (__bss_start = .) ; } + *(.bss) + *(COMMON) + ${RELOCATING+ PROVIDE (__bss_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > data} + + .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} : + { + ${RELOCATING+ PROVIDE (__noinit_start = .) ; } + *(.noinit) + *(COMMON) + ${RELOCATING+ PROVIDE (__noinit_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > data} + + .vectors ${RELOCATING-0}: + { + ${RELOCATING+ PROVIDE (__vectors_start = .) ; } + *(.vectors*) + ${RELOCATING+ _vectors_end = . ; } + } ${RELOCATING+ > vectors} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + PROVIDE (__stack = ${STACK}) ; + PROVIDE (__data_start_rom = _etext) ; + PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ; + PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ; + PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ; +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32sh-symbian.sc b/binutils-2.21/ld/scripttempl/elf32sh-symbian.sc new file mode 100644 index 0000000..b8fbcbc --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32sh-symbian.sc @@ -0,0 +1,387 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# INITIAL_READONLY_SECTIONS - at start of 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) +# ATTRS_SECTIONS - at the end +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# BSS_PLT - .plt should be in bss segment +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# STACK_ADDR - start of a .stack section. +# OTHER_SYMBOLS - symbols to place right at the end of the script. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# .debug_info .gnu.linkonce.wi.foo +# .tdata .gnu.linkonce.td.foo +# .tbss .gnu.linkonce.tb.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${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=. +test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" +test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" +test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" +DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" +DATA_SEGMENT_END="" +if test -n "${COMMONPAGESIZE}"; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" +fi + INTERP=".interp ALIGN(4) : { *(.interp) }" + PLT=".plt : { *(.plt) } :dynamic :dyn" +DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn" + RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) }" +test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn" +INIT_ARRAY=".init_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_start = .);}} + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_end = .);}} + }" +FINI_ARRAY=".fini_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_start = .);}} + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_end = .);}} + }" +CTOR=".ctors ALIGN(4) : + { + ${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)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + } :text" +DTOR=".dtors ALIGN(4) : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + } :text" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+_stack = .;} + *(.stack) + } :data" + +# 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}) +${RELOCATING+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. */} + +PHDRS +{ + headers PT_PHDR PHDRS ; + text PT_LOAD ; + data PT_LOAD ; + dyn PT_LOAD FLAGS (0) ; + dynamic PT_DYNAMIC ; +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}} + ${CREATE_SHLIB-${INTERP}} + + ${INITIAL_READONLY_SECTIONS} + + .init ALIGN(4) : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } :text =${NOP-0} + + .text ALIGN(4) : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + + .fini ALIGN(4) : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + + ${WRITABLE_RODATA-${RODATA}} + .rodata1 ALIGN(4) : { *(.rodata1) } + + ExportTable ALIGN(4) : { KEEP (*(ExportTable)) } + .eh_frame_hdr ALIGN(4) : { *(.eh_frame_hdr) } :text + + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN(128) + (. & (128 - 1)); + .preinit_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_start = .);}} + KEEP (*(.preinit_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_end = .);}} + } + ${RELOCATING+${INIT_ARRAY}} + ${RELOCATING+${FINI_ARRAY}} + + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + + .data ALIGN(4) : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } :data + + .data1 ALIGN(4) : { *(.data1) } :data + .tdata ALIGN(4) : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } :data + .tbss ALIGN(4) : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } :data + .eh_frame ALIGN(4) : { KEEP (*(.eh_frame)) } :data + .gcc_except_table ALIGN(4) : { *(.gcc_except_table) } :data + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${BSS_PLT+${PLT}} + .bss ALIGN(4) : + { + *(.dynbss) + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } :data + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${RELOCATING+_end = .;} + ${RELOCATING+PROVIDE (end = .);} + ${RELOCATING+${DATA_SEGMENT_END}} + + ${TEXT_DYNAMIC-${DYNAMIC}} + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } :dynamic :dyn + .dynsym ${RELOCATING-0} : { *(.dynsym) } :dynamic :dyn + .dynstr ${RELOCATING-0} : { *(.dynstr) } :dynamic :dyn + ${DATA_PLT-${BSS_PLT-${PLT}}} + .got.plt : { *(.got.plt) } :dynamic :dyn + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } +EOF +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT=cat +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } + .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } + .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } + .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } +EOF +if [ -n "$COMBRELOC" ]; then +cat <<EOF + .rel.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC +cat <<EOF + } + .rela.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC +cat <<EOF + } +EOF +fi +cat <<EOF + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} + + + /* 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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + ${STACK_ADDR+${STACK}} + ${ATTRS_SECTIONS} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_SYMBOLS}} + ${RELOCATING+${DISCARDED}} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32xc16x.sc b/binutils-2.21/ld/scripttempl/elf32xc16x.sc new file mode 100644 index 0000000..cb72508 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32xc16x.sc @@ -0,0 +1,61 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+ENTRY ("_start")} +MEMORY +{ + + vectarea : o =0x00000, l = 0x0300 + + introm : o = 0x00400, l = 0x16000 + /* The stack starts at the top of main ram. */ + + dram : o = 0x8000 , l = 0xffff + /* At the very top of the address space is the 8-bit area. */ + + ldata : o =0x4000 ,l = 0x0200 +} + +SECTIONS +{ +.init : + { + *(.init) + } ${RELOCATING+ >introm} + +.text : + { + *(.rodata) + *(.text.*) + *(.text) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > introm} +.data : + { + *(.data) + *(.data.*) + + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > dram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > dram} + + .ldata : + { + *(.ldata) + } ${RELOCATING+ > ldata} + + + .vects : + { + *(.vects) + } ${RELOCATING+ > vectarea} + +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32xc16xl.sc b/binutils-2.21/ld/scripttempl/elf32xc16xl.sc new file mode 100644 index 0000000..3565ece --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32xc16xl.sc @@ -0,0 +1,64 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+ENTRY ("_start")} +MEMORY +{ + vectarea : o =0xc00000, l = 0x0300 + + introm : o = 0xc00300, l = 0x16000 + /* The stack starts at the top of main ram. */ + + dram : o = 0x8000 , l = 0xffff + /* At the very top of the address space is the 8-bit area. */ + + ldata : o =0x4000 ,l = 0x0200 +} +SECTIONS +{ +/*.vects : + { + *(.vects) + } ${RELOCATING+ > vectarea} */ +.init : + { + *(.init) + } ${RELOCATING+ >introm} + +.text : + { + *(.rodata) + *(.text.*) + *(.text) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > introm} +.data : + { + *(.data) + *(.data.*) + + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > dram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > dram} + + .ldata : + { + *(.ldata) + } ${RELOCATING+ > ldata} + + + .vects : + { + *(.vects) + } ${RELOCATING+ > vectarea} + + +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf32xc16xs.sc b/binutils-2.21/ld/scripttempl/elf32xc16xs.sc new file mode 100644 index 0000000..3565ece --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf32xc16xs.sc @@ -0,0 +1,64 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+ENTRY ("_start")} +MEMORY +{ + vectarea : o =0xc00000, l = 0x0300 + + introm : o = 0xc00300, l = 0x16000 + /* The stack starts at the top of main ram. */ + + dram : o = 0x8000 , l = 0xffff + /* At the very top of the address space is the 8-bit area. */ + + ldata : o =0x4000 ,l = 0x0200 +} +SECTIONS +{ +/*.vects : + { + *(.vects) + } ${RELOCATING+ > vectarea} */ +.init : + { + *(.init) + } ${RELOCATING+ >introm} + +.text : + { + *(.rodata) + *(.text.*) + *(.text) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > introm} +.data : + { + *(.data) + *(.data.*) + + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > dram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > dram} + + .ldata : + { + *(.ldata) + } ${RELOCATING+ > ldata} + + + .vects : + { + *(.vects) + } ${RELOCATING+ > vectarea} + + +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf64hppa.sc b/binutils-2.21/ld/scripttempl/elf64hppa.sc new file mode 100644 index 0000000..5cbf212 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf64hppa.sc @@ -0,0 +1,576 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not +# empty. +# SMALL_DATA_CTOR - .ctors contains small data. +# SMALL_DATA_DTOR - .dtors contains small data. +# 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_RELRO_SECTIONS - other than .data.rel.ro ... +# (e.g. PPC32 .fixup, .got[12]) +# OTHER_BSS_SECTIONS - other than .bss .sbss ... +# ATTRS_SECTIONS - at the end +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_ADDR - the first byte of the text segment, after any +# headers. +# TEXT_BASE_ADDRESS - the first byte of the text segment. +# 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. +# DATA_END_SYMBOLS - symbols that appear at the end of the +# writeable data sections. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. +# BSS_PLT - .plt should be in bss segment +# NO_REL_RELOCS - Don't include .rel.* sections in script +# NO_RELA_RELOCS - Don't include .rela.* sections in script +# NON_ALLOC_DYN - Place dynamic sections after data segment. +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# STACK_ADDR - start of a .stack section. +# OTHER_SYMBOLS - symbols to place right at the end of the script. +# ETEXT_NAME - name of a symbol for the end of the text section, +# normally etext. +# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, +# so that .got can be in the RELRO area. It should be set to +# the number of bytes in the beginning of .got.plt which can be +# in the RELRO area as well. +# USER_LABEL_PREFIX - prefix to add to user-visible symbols. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# .debug_info .gnu.linkonce.wi.foo +# .tdata .gnu.linkonce.td.foo +# .tbss .gnu.linkonce.tb.foo +# .lrodata .gnu.linkonce.lr.foo +# .ldata .gnu.linkonce.l.foo +# .lbss .gnu.linkonce.lb.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +test "$LD_FLAG" = "N" && DATA_ADDR=. +test -z "${ETEXT_NAME}" && ETEXT_NAME=etext +test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" +test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" +test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT +test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" +DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" +DATA_SEGMENT_RELRO_END="" +DATA_SEGMENT_END="" +if test -n "${COMMONPAGESIZE}"; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" + DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" +fi +if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then + INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" +fi +if test -z "$PLT"; then + PLT=".plt ${RELOCATING-0} : { *(.plt) }" +fi +test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes +if test -z "$GOT"; then + if test -z "$SEPARATE_GOTPLT"; then + GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }" + else + GOT=".got ${RELOCATING-0} : { *(.got) }" + GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }" + fi +fi +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }" +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" +if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { + ${RELOCATING+${SBSS_START_SYMBOLS}} + ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)} + *(.dynsbss) + *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) + *(.scommon) + ${RELOCATING+${SBSS_END_SYMBOLS}} + }" + SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" + SDATA="/* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)} + *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) + }" + SDATA2=".sdata2 ${RELOCATING-0} : + { + ${RELOCATING+${SDATA2_START_SYMBOLS}} + *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) + }" + REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" + REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" + REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } + .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" + REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } + .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" +else + NO_SMALL_DATA=" " +fi +if test -z "${DATA_GOT}"; then + if test -n "${NO_SMALL_DATA}"; then + DATA_GOT=" " + fi +fi +if test -z "${SDATA_GOT}"; then + if test -z "${NO_SMALL_DATA}"; then + SDATA_GOT=" " + fi +fi +test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " +test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" + .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } + .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } + .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } + .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } + .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } + .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" +test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS=" + ${OTHER_BSS_SECTIONS} + .lbss ${RELOCATING-0} : + { + *(.dynlbss) + *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) + *(LARGE_COMMON) + }" +test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" + .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : + { + *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) + } + .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : + { + *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) + ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + }" +INIT_ARRAY=".init_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} + }" +FINI_ARRAY=".fini_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} + }" +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)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" +DTOR=".dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+_stack = .;} + *(.stack) + }" + +TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" +SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" + +# 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}) +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} + ${INITIAL_READONLY_SECTIONS} + .note.gnu.build-id : { *(.note.gnu.build-id) } +EOF + +test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN +test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= +cat > ldscripts/dyntmp.$$ <<EOF + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } +EOF + +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) } + .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) } + .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } + .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } + .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } + .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + ${REL_SDATA} + ${REL_SBSS} + ${REL_SDATA2} + ${REL_SBSS2} + .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } + ${REL_LARGE} +EOF + +if [ -n "$COMBRELOC" ]; then +cat >> ldscripts/dyntmp.$$ <<EOF + .rel.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ +cat >> ldscripts/dyntmp.$$ <<EOF + } + .rel.ifunc.dyn ${RELOCATING-0} : + { + *(.rel.ifunc.*) + } + .rela.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ +cat >> ldscripts/dyntmp.$$ <<EOF + } + .rela.ifunc.dyn ${RELOCATING-0} : + { + *(.rela.ifunc.*) + } +EOF +fi + +cat >> ldscripts/dyntmp.$$ <<EOF + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} +EOF + +if test -z "${NON_ALLOC_DYN}"; then + if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then + cat ldscripts/dyntmp.$$ + else + if test -z "${NO_REL_RELOCS}"; then + sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$ + fi + if test -z "${NO_RELA_RELOCS}"; then + sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$ + fi + fi + rm -f ldscripts/dyntmp.$$ +fi + +cat <<EOF + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } =${NOP-0} + + ${TEXT_PLT+${PLT}} + ${TINY_READONLY_SECTION} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} + ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} + ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} + ${WRITABLE_RODATA-${RODATA}} + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${OTHER_READONLY_SECTIONS} + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } + + /* 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-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + + /* Exception handling */ + .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + + /* Thread Local Storage sections */ + .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } + + .preinit_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} + KEEP (*(.preinit_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} + } + ${RELOCATING+${INIT_ARRAY}} + ${RELOCATING+${FINI_ARRAY}} + ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} + ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} + .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } + + ${RELOCATING+${DATARELRO}} + ${OTHER_RELRO_SECTIONS} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${DATA_GOT+${RELRO_NOW+${GOT}}} + ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} + ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} + ${RELOCATING+${DATA_SEGMENT_RELRO_END}} + ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} + ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} + + ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} + ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} + ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}} + ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}} + ${SDATA_GOT+${GOT}} + ${SDATA_GOT+${OTHER_GOT_SECTIONS}} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${SBSS} + ${BSS_PLT+${PLT}} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + } + ${OTHER_BSS_SECTIONS} + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${LARGE_SECTIONS} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} + ${RELOCATING+${DATA_SEGMENT_END}} +EOF + +if test -n "${NON_ALLOC_DYN}"; then + if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then + cat ldscripts/dyntmp.$$ + else + if test -z "${NO_REL_RELOCS}"; then + sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$ + fi + if test -z "${NO_RELA_RELOCS}"; then + sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$ + fi + fi + rm -f ldscripts/dyntmp.$$ +fi + +cat <<EOF + /* 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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes .zdebug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges .zdebug_ranges) } + + ${TINY_DATA_SECTION} + ${TINY_BSS_SECTION} + + ${STACK_ADDR+${STACK}} + ${ATTRS_SECTIONS} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_SYMBOLS}} + ${RELOCATING+${DISCARDED}} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elf_chaos.sc b/binutils-2.21/ld/scripttempl/elf_chaos.sc new file mode 100644 index 0000000..44279a9 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elf_chaos.sc @@ -0,0 +1,358 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not +# empty. +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# INITIAL_READONLY_SECTIONS - at start of text segment +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_TEXT_SECTIONS - these get put in .text when relocating +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# ATTRS_SECTIONS - at the end +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# BSS_PLT - .plt should be in bss segment +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# STACK_ADDR - start of a .stack section. +# OTHER_SYMBOLS - symbols to place right at the end of the script. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# .debug_info .gnu.linkonce.wi.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__sbss_start = .);} + ${RELOCATING+PROVIDE (___sbss_start = .);} + *(.dynsbss) + *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) + *(.scommon) + ${RELOCATING+PROVIDE (__sbss_end = .);} + ${RELOCATING+PROVIDE (___sbss_end = .);} + }" + SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" + SDATA="/* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) + }" + SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }" + REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" + REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" + REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } + .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" + REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } + .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" +fi +CTOR=" + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} +" +DTOR=" + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} +" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+_stack = .;} + *(.stack) + }" + +test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}} + ${CREATE_SHLIB-${INTERP}} + ${INITIAL_READONLY_SECTIONS} + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } + +EOF +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT=cat +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + ${REL_SDATA} + ${REL_SBSS} + ${REL_SDATA2} + ${REL_SBSS2} + .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } +EOF +if [ -n "$COMBRELOC" ]; then +cat <<EOF + .rel.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC +cat <<EOF + } + .rela.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC +cat <<EOF + } +EOF +fi +cat <<EOF + . = ALIGN(0x1000); + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} + ${DATA_PLT-${BSS_PLT-${PLT}}} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + . = ALIGN(0x1000); + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${OTHER_READONLY_SECTIONS} + .eh_frame_hdr : { *(.eh_frame_hdr) } + + . = ALIGN(0x1000); + .data ${RELOCATING-0} : + { + *(.rodata .rodata.*) + *(.rodata1) + *(.gnu.linkonce.r.*) + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + KEEP (*(.eh_frame)) + *(.gcc_except_table) + ${CTOR} + ${DTOR} + KEEP (*(.jcr)) + } + .data1 ${RELOCATING-0} : { *(.data1) } + . = ALIGN(0x1000); + .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) } + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${DATA_PLT+${PLT}} + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + ${OTHER_GOT_SECTIONS} + ${CREATE_SHLIB+${SDATA2}} + ${CREATE_SHLIB+${SBSS2}} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${SBSS} + ${BSS_PLT+${PLT}} + . = ALIGN(0x1000); + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${RELOCATING+_end = .;} + ${RELOCATING+PROVIDE (end = .);} + + /* Stabs debugging sections. */ + . = ALIGN(0x1000); + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + + . = ALIGN(0x1000); + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + ${STACK_ADDR+${STACK}} + ${ATTRS_SECTIONS} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_SYMBOLS}} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elfd10v.sc b/binutils-2.21/ld/scripttempl/elfd10v.sc new file mode 100644 index 0000000..cf926d0 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elfd10v.sc @@ -0,0 +1,198 @@ +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)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" + +STACK=" .stack : { _stack = .; *(.stack) } >STACK " + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR}" +fi + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} + +MEMORY +{ + /* These are the values for the D10V-TS3 board. + There are other memory regions available on + the TS3 (eg ROM, FLASH, etc) but these are not + used by this script. */ + + INSN : org = 0x01000000, len = 256K + DATA : org = 0x02000000, len = 48K + + /* This is a fake memory region at the top of the + on-chip RAM, used as the start of the + (descending) stack. */ + + STACK : org = 0x0200BFFC, len = 4 +} + +SECTIONS +{ + .text ${RELOCATING+${TEXT_START_ADDR}} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + KEEP (*(.init)) + KEEP (*(.init.*)) + KEEP (*(.fini)) + KEEP (*(.fini.*)) + *(.text) + *(.text.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + } ${RELOCATING+ >INSN} =${NOP-0} + + .rodata ${RELOCATING+${READONLY_START_ADDR}} : { + *(.rodata) + *(.gnu.linkonce.r*) + *(.rodata.*) + } ${RELOCATING+ >DATA} + + .rodata1 ${RELOCATING-0} : { + *(.rodata1) + *(.rodata1.*) + } ${RELOCATING+ >DATA} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + ${CONSTRUCTING+CONSTRUCTORS} + } ${RELOCATING+ >DATA} + + .data1 ${RELOCATING-0} : { + *(.data1) + *(.data1.*) + } ${RELOCATING+ >DATA} + + ${RELOCATING+${CTOR} >DATA} + ${RELOCATING+${DTOR} >DATA} + + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : { + *(.sdata) + *(.sdata.*) + } ${RELOCATING+ >DATA} + + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } ${RELOCATING+ >DATA} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.dynbss.*) + *(.bss) + *(.bss.*) + *(COMMON) + } ${RELOCATING+ >DATA} + + ${RELOCATING+_end = . ;} + ${RELOCATING+PROVIDE (end = .);} + + ${RELOCATING+$STACK} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elfd30v.sc b/binutils-2.21/ld/scripttempl/elfd30v.sc new file mode 100644 index 0000000..431236f --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elfd30v.sc @@ -0,0 +1,225 @@ + +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)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *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 (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+ __DTOR_END__ = .; } + } ${RELOCATING+ > ${DATA_MEMORY}}" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + text ${TEXT_DEF_SECTION} : ORIGIN = ${TEXT_START_ADDR}, LENGTH = ${TEXT_SIZE} + data ${DATA_DEF_SECTION} : ORIGIN = ${DATA_START_ADDR}, LENGTH = ${DATA_SIZE} + emem ${EMEM_DEF_SECTION} : ORIGIN = ${EMEM_START_ADDR}, LENGTH = ${EMEM_SIZE} + eit : ORIGIN = ${EIT_START_ADDR}, LENGTH = ${EIT_SIZE} +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.text ${RELOCATING-0} : { *(.rel.text) *(.rel.gnu.linkonce.t*) } + .rela.text ${RELOCATING-0} : { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rel.data ${RELOCATING-0} : { *(.rel.data) *(.rel.gnu.linkonce.d*) } + .rela.data ${RELOCATING-0} : { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rel.stext ${RELOCATING-0} : { *(.rel.stest) } + .rela.stext ${RELOCATING-0} : { *(.rela.stest) } + .rel.etext ${RELOCATING-0} : { *(.rel.etest) } + .rela.etext ${RELOCATING-0} : { *(.rela.etest) } + .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } + .rel.edata ${RELOCATING-0} : { *(.rel.edata) } + .rela.edata ${RELOCATING-0} : { *(.rela.edata) } + .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) } + .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) } + .rel.sbss ${RELOCATING-0} : { *(.rel.sbss) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) } + .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) } + .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) } + .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) } + .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) } + .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) } + .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + .init ${RELOCATING-0} : { *(.init) } =${NOP-0} + ${DATA_PLT-${PLT}} + + /* Internal text space */ + .stext ${RELOCATING-0} : { *(.stext) } ${RELOCATING+ > text} + + /* Internal text space or external memory */ + .text : + { + *(.text) + *(.gnu.linkonce.t*) + *(.init) + *(.fini) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Internal data space */ + .srodata ${RELOCATING-0} : { *(.srodata) } ${RELOCATING+ > data} + .sdata ${RELOCATING-0} : { *(.sdata) } ${RELOCATING+ > data} + + /* Internal data space or external memory */ + .rodata ${RELOCATING-0} : { *(.rodata) } ${RELOCATING+ > ${DATA_MEMORY}} + + /* C++ exception support. */ + .eh_frame ${RELOCATING-0} : { KEEP (*(.eh_frame)) } ${RELOCATING+ > ${DATA_MEMORY}} + .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) } ${RELOCATING+ > ${DATA_MEMORY}} + + /* Java class registration support. */ + .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } ${RELOCATING+ >${DATA_MEMORY}} + + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + + .data ${RELOCATING-0} : + { + *(.data) + *(.gnu.linkonce.d*) + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ${DATA_MEMORY}} + + /* External memory */ + .etext ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__etext_start = .) ; } + *(.etext) + ${RELOCATING+ PROVIDE (__etext_end = .) ; } + } ${RELOCATING+ > emem} + + .erodata ${RELOCATING-0} : { *(.erodata) } ${RELOCATING+ > emem} + .edata ${RELOCATING-0} : { *(.edata) } ${RELOCATING+ > emem} + + .sbss ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__sbss_start = .) ; } + *(.sbss) + ${RELOCATING+ PROVIDE (__sbss_end = .) ; } + } ${RELOCATING+ > data} + + .ebss ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__ebss_start = .) ; } + *(.ebss) + ${RELOCATING+ PROVIDE (__ebss_end = .) ; } + } ${RELOCATING+ > data} + + .bss ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__bss_start = .) ; } + *(.bss) + *(COMMON) + ${RELOCATING+ PROVIDE (__bss_end = .) ; } + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > ${DATA_MEMORY}} + + .eit_v ${RELOCATING-0} : + { + ${RELOCATING+ PROVIDE (__eit_start = .) ; } + *(.eit_v) + ${RELOCATING+ PROVIDE (__eit_end = .) ; } + } ${RELOCATING+ > eit} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + PROVIDE (__stack = ${STACK_START_ADDR}); +} +EOF + + + + diff --git a/binutils-2.21/ld/scripttempl/elfi370.sc b/binutils-2.21/ld/scripttempl/elfi370.sc new file mode 100644 index 0000000..b004b3f --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elfi370.sc @@ -0,0 +1,220 @@ +# +# This is just a raw copy of elfppc.sc and has not been otherwise modified +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# ATTRS_SECTIONS - at the end +# 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 -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" +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) }" +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+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);} +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) *(.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.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) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =${NOP-0} + .init ${RELOCATING-0} : { *(.init) } =${NOP-0} + .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} + .rodata ${RELOCATING-0} : { *(.rodata) *(.gnu.linkonce.r*) } + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${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) + *(.gnu.linkonce.d*) + ${CONSTRUCTING+CONSTRUCTORS} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${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_ = .);} + .got2 ${RELOCATING-0} : { *(.got2) } + + ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);} + .ctors ${RELOCATING-0} : { *(.ctors) } + ${RELOCATING+PROVIDE (__CTOR_END__ = .);} + + ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);} + .dtors ${RELOCATING-0} : { *(.dtors) } + ${RELOCATING+PROVIDE (__DTOR_END__ = .);} + + ${RELOCATING+PROVIDE (_FIXUP_START_ = .);} + .fixup ${RELOCATING-0} : { *(.fixup) } + ${RELOCATING+PROVIDE (_FIXUP_END_ = .);} + ${RELOCATING+PROVIDE (_GOT2_END_ = .);} + + ${RELOCATING+PROVIDE (_GOT_START_ = .);} + .got ${RELOCATING-0} : { *(.got) } + .got.plt ${RELOCATING-0} : { *(.got.plt) } + ${CREATE_SHLIB+${SDATA2}} + ${CREATE_SHLIB+${SBSS2}} + ${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 = .);} + .sbss ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__sbss_start = .);} + *(.sbss) + *(.scommon) + *(.dynsbss) + ${RELOCATING+PROVIDE (__sbss_end = .);} + } + ${PLT} + .bss ${RELOCATING-0} : + { + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${RELOCATING+PROVIDE (__bss_start = .);} + *(.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) } + + /* 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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + ${ATTRS_SECTIONS} + ${OTHER_SECTIONS} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elfm68hc11.sc b/binutils-2.21/ld/scripttempl/elfm68hc11.sc new file mode 100644 index 0000000..e3d5e9a --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elfm68hc11.sc @@ -0,0 +1,460 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# EMBEDDED - whether this is for an embedded system. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test "$LD_FLAG" = "N" && DATA_ADDR=. + +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); } + ${CONSTRUCTING+${CTOR_START}} + KEEP (*(.ctors)) + + ${CONSTRUCTING+${CTOR_END}} + ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); } + } ${RELOCATING+ > ${TEXT_MEMORY}}" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); } + KEEP (*(.dtors)) + ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); } + } ${RELOCATING+ > ${TEXT_MEMORY}}" + + +VECTORS=" + /* If the 'vectors_addr' symbol is defined, it indicates the start address + of interrupt vectors. This depends on the 68HC11 operating mode: + + Addr + Single chip 0xffc0 + Extended mode 0xffc0 + Bootstrap 0x00c0 + Test 0xbfc0 + + In general, the vectors address is 0xffc0. This can be overriden + with the '-defsym vectors_addr=0xbfc0' ld option. + + Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but + they are redirected to 0x00c0 by the internal PROM. Application's vectors + must also consist of jump instructions (see Motorola's manual). */ + + PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0); + .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 : + { + KEEP (*(.vectors)) + }" + +# +# We provide two emulations: a fixed on that defines some memory banks +# and a configurable one that includes a user provided memory definition. +# +case $GENERIC_BOARD in + yes|1|YES) + MEMORY_DEF=" +/* Get memory banks definition from some user configuration file. + This file must be located in some linker directory (search path + with -L<dir>). See fixed memory banks emulation script. */ +INCLUDE memory.x; +" + ;; + *) +MEMORY_DEF=" +/* Fixed definition of the available memory banks. + See generic emulation script for a user defined configuration. */ +MEMORY +{ + page0 (rwx) : ORIGIN = 0x0, LENGTH = 256 + text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE} + data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE} + eeprom : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE} +} + +/* Setup the stack on the top of the data memory bank. */ +PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1); +" + ;; +esac + +STARTUP_CODE=" + /* Startup code. */ + KEEP (*(.install0)) /* Section should setup the stack pointer. */ + KEEP (*(.install1)) /* Place holder for applications. */ + KEEP (*(.install2)) /* Optional installation of data sections in RAM. */ + KEEP (*(.install3)) /* Place holder for applications. */ + KEEP (*(.install4)) /* Section that calls the main. */ +" + +FINISH_CODE=" + /* Finish code. */ + KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */ + KEEP (*(.fini1)) /* Place holder for applications. */ + KEEP (*(.fini2)) /* C++ destructors. */ + KEEP (*(.fini3)) /* Place holder for applications. */ + KEEP (*(.fini4)) /* Runtime exit. */ +" + +PRE_COMPUTE_DATA_SIZE=" +/* SCz: this does not work yet... This is supposed to force the loading + of _map_data.o (from libgcc.a) when the .data section is not empty. + By doing so, this should bring the code that copies the .data section + from ROM to RAM at init time. + + ___pre_comp_data_size = SIZEOF(.data); + __install_data_sections = ___pre_comp_data_size > 0 ? + __map_data_sections : 0; +*/ +" + +INSTALL_RELOC=" + .install0 0 : { *(.install0) } + .install1 0 : { *(.install1) } + .install2 0 : { *(.install2) } + .install3 0 : { *(.install3) } + .install4 0 : { *(.install4) } +" + +FINISH_RELOC=" + .fini0 0 : { *(.fini0) } + .fini1 0 : { *(.fini1) } + .fini2 0 : { *(.fini2) } + .fini3 0 : { *(.fini3) } + .fini4 0 : { *(.fini4) } +" + +BSS_DATA_RELOC=" + .data1 0 : { *(.data1) } + + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata 0 : { *(.sdata) } + .sbss 0 : { *(.sbss) } + .scommon 0 : { *(.scommon) } +" + +SOFT_REGS_RELOC=" + .softregs 0 : { *(.softregs) } +" + +cat <<EOF +${RELOCATING+/* Linker script for 68HC11 executable (PROM). */} +${RELOCATING-/* Linker script for 68HC11 object file (ld -r). */} + +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${MEMORY_DEF}} + +SECTIONS +{ + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t.*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t.*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d.*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d.*)} + } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r.*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r.*)} + } + .rel.sdata ${RELOCATING-0} : + { + *(.rel.sdata) + ${RELOCATING+*(.rel.sdata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.s.*)} + } + .rela.sdata ${RELOCATING-0} : + { + *(.rela.sdata) + ${RELOCATING+*(.rela.sdata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.s.*)} + } + .rel.sbss ${RELOCATING-0} : + { + *(.rel.sbss) + ${RELOCATING+*(.rel.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rela.sbss ${RELOCATING-0} : + { + *(.rela.sbss) + ${RELOCATING+*(.rela.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rel.bss ${RELOCATING-0} : + { + *(.rel.bss) + ${RELOCATING+*(.rel.bss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.b.*)} + } + .rela.bss ${RELOCATING-0} : + { + *(.rela.bss) + ${RELOCATING+*(.rela.bss.*)} + ${RELOCATING+*(.rela.gnu.linkonce.b.*)} + } + .rel.stext ${RELOCATING-0} : { *(.rel.stest) } + .rela.stext ${RELOCATING-0} : { *(.rela.stest) } + .rel.etext ${RELOCATING-0} : { *(.rel.etest) } + .rela.etext ${RELOCATING-0} : { *(.rela.etest) } + .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } + .rel.edata ${RELOCATING-0} : { *(.rel.edata) } + .rela.edata ${RELOCATING-0} : { *(.rela.edata) } + .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) } + .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) } + .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) } + .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) } + .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) } + .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) } + .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) } + .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Concatenate .page0 sections. Put them in the page0 memory bank + unless we are creating a relocatable file. */ + .page0 : + { + *(.page0) + ${RELOCATING+*(.softregs)} + } ${RELOCATING+ > page0} + + /* Start of text section. */ + .stext ${RELOCATING-0} : + { + *(.stext) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .init ${RELOCATING-0} : + { + *(.init) + } ${RELOCATING+=${NOP-0}} + + ${RELOCATING-${INSTALL_RELOC}} + ${RELOCATING-${FINISH_RELOC}} + + .text ${RELOCATING-0}: + { + /* Put startup code at beginning so that _start keeps same address. */ + ${RELOCATING+${STARTUP_CODE}} + + ${RELOCATING+*(.init)} + *(.text) + ${RELOCATING+*(.text.*)} + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.gnu.linkonce.t.*)} + ${RELOCATING+*(.tramp)} + ${RELOCATING+*(.tramp.*)} + + ${RELOCATING+${FINISH_CODE}} + + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .eh_frame ${RELOCATING-0} : + { + KEEP (*(.eh_frame)) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .gcc_except_table ${RELOCATING-0} : + { + *(.gcc_except_table) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .rodata ${RELOCATING-0} : + { + *(.rodata) + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .rodata1 ${RELOCATING-0} : + { + *(.rodata1) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Constructor and destructor tables are in ROM. */ + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + + .jcr ${RELOCATING-0} : + { + KEEP (*(.jcr)) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Start of the data section image in ROM. */ + ${RELOCATING+__data_image = .;} + ${RELOCATING+PROVIDE (__data_image = .);} + + /* All read-only sections that normally go in PROM must be above. + We construct the DATA image section in PROM at end of all these + read-only sections. The data image must be copied at init time. + Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */ + .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)} + { + ${RELOCATING+__data_section_start = .;} + ${RELOCATING+PROVIDE (__data_section_start = .);} + + ${RELOCATING+${DATA_START_SYMBOLS}} + ${RELOCATING+*(.sdata)} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.data1)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+CONSTRUCTORS} + + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + } ${RELOCATING+ > ${DATA_MEMORY}} + + ${RELOCATING+__data_section_size = SIZEOF(.data);} + ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));} + ${RELOCATING+__data_image_end = __data_image + __data_section_size;} + + ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}} + + /* .install ${RELOCATING-0}: + { + . = _data_image_end; + } ${RELOCATING+ > ${TEXT_MEMORY}} */ + + /* Relocation for some bss and data sections. */ + ${RELOCATING-${BSS_DATA_RELOC}} + ${RELOCATING-${SOFT_REGS_RELOC}} + + .bss ${RELOCATING-0} : + { + ${RELOCATING+__bss_start = .;} + ${RELOCATING+*(.sbss)} + ${RELOCATING+*(.scommon)} + + *(.dynbss) + *(.bss) + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.gnu.linkonce.b.*)} + *(COMMON) + ${RELOCATING+PROVIDE (_end = .);} + } ${RELOCATING+ > ${DATA_MEMORY}} + ${RELOCATING+__bss_size = SIZEOF(.bss);} + ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));} + + .eeprom ${RELOCATING-0} : + { + *(.eeprom) + *(.eeprom.*) + } ${RELOCATING+ > ${EEPROM_MEMORY}} + + ${RELOCATING+${VECTORS}} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. + Treatment of DWARF debug section must be at end of the linker + script to avoid problems when there are undefined symbols. It's necessary + to avoid that the DWARF section is relocated before such undefined + symbols are found. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elfm68hc12.sc b/binutils-2.21/ld/scripttempl/elfm68hc12.sc new file mode 100644 index 0000000..48df867 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elfm68hc12.sc @@ -0,0 +1,463 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# EMBEDDED - whether this is for an embedded system. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test "$LD_FLAG" = "N" && DATA_ADDR=. + +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); } + ${CONSTRUCTING+${CTOR_START}} + KEEP (*(.ctors)) + + ${CONSTRUCTING+${CTOR_END}} + ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); } + } ${RELOCATING+ > ${TEXT_MEMORY}}" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); } + KEEP (*(.dtors)) + ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); } + } ${RELOCATING+ > ${TEXT_MEMORY}}" + + +VECTORS=" + /* If the 'vectors_addr' symbol is defined, it indicates the start address + of interrupt vectors. This depends on the 68HC11 operating mode: + + Addr + Single chip 0xffc0 + Extended mode 0xffc0 + Bootstrap 0x00c0 + Test 0xbfc0 + + In general, the vectors address is 0xffc0. This can be overriden + with the '-defsym vectors_addr=0xbfc0' ld option. + + Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but + they are redirected to 0x00c0 by the internal PROM. Application's vectors + must also consist of jump instructions (see Motorola's manual). */ + + PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0); + .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 : + { + KEEP (*(.vectors)) + }" + +# +# We provide two emulations: a fixed on that defines some memory banks +# and a configurable one that includes a user provided memory definition. +# +case $GENERIC_BOARD in + yes|1|YES) + MEMORY_DEF=" +/* Get memory banks definition from some user configuration file. + This file must be located in some linker directory (search path + with -L<dir>). See fixed memory banks emulation script. */ +INCLUDE memory.x; +" + ;; + *) +MEMORY_DEF=" +/* Fixed definition of the available memory banks. + See generic emulation script for a user defined configuration. */ +MEMORY +{ + page0 (rwx) : ORIGIN = 0x0, LENGTH = 256 + text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE} + data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE} + eeprom : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE} +} + +/* Setup the stack on the top of the data memory bank. */ +PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1); +" + ;; +esac + +STARTUP_CODE=" + /* Startup code. */ + KEEP (*(.install0)) /* Section should setup the stack pointer. */ + KEEP (*(.install1)) /* Place holder for applications. */ + KEEP (*(.install2)) /* Optional installation of data sections in RAM. */ + KEEP (*(.install3)) /* Place holder for applications. */ + KEEP (*(.install4)) /* Section that calls the main. */ +" + +FINISH_CODE=" + /* Finish code. */ + KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */ + KEEP (*(.fini1)) /* Place holder for applications. */ + KEEP (*(.fini2)) /* C++ destructors. */ + KEEP (*(.fini3)) /* Place holder for applications. */ + KEEP (*(.fini4)) /* Runtime exit. */ +" + +PRE_COMPUTE_DATA_SIZE=" +/* SCz: this does not work yet... This is supposed to force the loading + of _map_data.o (from libgcc.a) when the .data section is not empty. + By doing so, this should bring the code that copies the .data section + from ROM to RAM at init time. + + ___pre_comp_data_size = SIZEOF(.data); + __install_data_sections = ___pre_comp_data_size > 0 ? + __map_data_sections : 0; +*/ +" + +INSTALL_RELOC=" + .install0 0 : { *(.install0) } + .install1 0 : { *(.install1) } + .install2 0 : { *(.install2) } + .install3 0 : { *(.install3) } + .install4 0 : { *(.install4) } +" + +FINISH_RELOC=" + .fini0 0 : { *(.fini0) } + .fini1 0 : { *(.fini1) } + .fini2 0 : { *(.fini2) } + .fini3 0 : { *(.fini3) } + .fini4 0 : { *(.fini4) } +" + +BSS_DATA_RELOC=" + .data1 0 : { *(.data1) } + + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata 0 : { *(.sdata) } + .sbss 0 : { *(.sbss) } + .scommon 0 : { *(.scommon) } +" + +SOFT_REGS_RELOC=" + .softregs 0 : { *(.softregs) } +" + +cat <<EOF +${RELOCATING+/* Linker script for 68HC12 executable (PROM). */} +${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */} + +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${MEMORY_DEF}} + +SECTIONS +{ + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t.*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t.*)} + } + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d.*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d.*)} + } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r.*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r.*)} + } + .rel.sdata ${RELOCATING-0} : + { + *(.rel.sdata) + ${RELOCATING+*(.rel.sdata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.s.*)} + } + .rela.sdata ${RELOCATING-0} : + { + *(.rela.sdata) + ${RELOCATING+*(.rela.sdata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.s.*)} + } + .rel.sbss ${RELOCATING-0} : + { + *(.rel.sbss) + ${RELOCATING+*(.rel.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rela.sbss ${RELOCATING-0} : + { + *(.rela.sbss) + ${RELOCATING+*(.rela.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rel.bss ${RELOCATING-0} : + { + *(.rel.bss) + ${RELOCATING+*(.rel.bss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.b.*)} + } + .rela.bss ${RELOCATING-0} : + { + *(.rela.bss) + ${RELOCATING+*(.rela.bss.*)} + ${RELOCATING+*(.rela.gnu.linkonce.b.*)} + } + .rel.stext ${RELOCATING-0} : { *(.rel.stest) } + .rela.stext ${RELOCATING-0} : { *(.rela.stest) } + .rel.etext ${RELOCATING-0} : { *(.rel.etest) } + .rela.etext ${RELOCATING-0} : { *(.rela.etest) } + .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } + .rel.edata ${RELOCATING-0} : { *(.rel.edata) } + .rela.edata ${RELOCATING-0} : { *(.rela.edata) } + .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) } + .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) } + .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) } + .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) } + .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) } + .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) } + .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) } + .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + + /* Concatenate .page0 sections. Put them in the page0 memory bank + unless we are creating a relocatable file. */ + .page0 : + { + *(.page0) + } ${RELOCATING+ > page0} + + /* Start of text section. */ + .stext ${RELOCATING-0} : + { + *(.stext) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .init ${RELOCATING-0} : + { + *(.init) + } ${RELOCATING+=${NOP-0}} + + ${RELOCATING-${INSTALL_RELOC}} + ${RELOCATING-${FINISH_RELOC}} + + .text ${RELOCATING-0}: + { + /* Put startup code at beginning so that _start keeps same address. */ + ${RELOCATING+${STARTUP_CODE}} + + ${RELOCATING+*(.init)} + *(.text) + ${RELOCATING+*(.text.*)} + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.gnu.linkonce.t.*)} + ${RELOCATING+*(.tramp)} + ${RELOCATING+*(.tramp.*)} + + ${RELOCATING+${FINISH_CODE}} + + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + ${RELOCATING+. = ALIGN(2);} + } ${RELOCATING+ > ${TEXT_MEMORY} =0xa7a7a7a7} + + .eh_frame ${RELOCATING-0} : + { + KEEP (*(.eh_frame)) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .gcc_except_table ${RELOCATING-0} : + { + *(.gcc_except_table) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + .rodata ${RELOCATING-0} : + { + *(.rodata) + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + ${RELOCATING+. = ALIGN(2);} + } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff} + + .rodata1 ${RELOCATING-0} : + { + *(.rodata1) + ${RELOCATING+. = ALIGN(2);} + } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff} + + /* Constructor and destructor tables are in ROM. */ + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + + .jcr ${RELOCATING-0} : + { + KEEP (*(.jcr)) + } ${RELOCATING+ > ${TEXT_MEMORY}} + + /* Start of the data section image in ROM. */ + ${RELOCATING+__data_image = .;} + ${RELOCATING+PROVIDE (__data_image = .);} + + /* All read-only sections that normally go in PROM must be above. + We construct the DATA image section in PROM at end of all these + read-only sections. The data image must be copied at init time. + Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */ + .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)} + { + ${RELOCATING+__data_section_start = .;} + ${RELOCATING+PROVIDE (__data_section_start = .);} + + ${RELOCATING+${DATA_START_SYMBOLS}} + ${RELOCATING+*(.sdata)} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.data1)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+CONSTRUCTORS} + + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+. = ALIGN(2);} + } ${RELOCATING+ > ${DATA_MEMORY} =0xffffffff} + + ${RELOCATING+__data_section_size = SIZEOF(.data);} + ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));} + ${RELOCATING+__data_image_end = __data_image + __data_section_size;} + + ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}} + + /* .install ${RELOCATING-0}: + { + . = _data_image_end; + } ${RELOCATING+ > ${TEXT_MEMORY}} */ + + /* Relocation for some bss and data sections. */ + ${RELOCATING-${BSS_DATA_RELOC}} + ${RELOCATING-${SOFT_REGS_RELOC}} + + .bss ${RELOCATING-0} : + { + ${RELOCATING+__bss_start = .;} + ${RELOCATING+*(.softregs)} + ${RELOCATING+*(.sbss)} + ${RELOCATING+*(.scommon)} + + *(.dynbss) + *(.bss) + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.gnu.linkonce.b.*)} + *(COMMON) + ${RELOCATING+PROVIDE (_end = .);} + } ${RELOCATING+ > ${DATA_MEMORY}} + ${RELOCATING+__bss_size = SIZEOF(.bss);} + ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));} + + .eeprom ${RELOCATING-0} : + { + *(.eeprom) + *(.eeprom.*) + } ${RELOCATING+ > ${EEPROM_MEMORY}} + + ${RELOCATING+${VECTORS}} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. + Treatment of DWARF debug section must be at end of the linker + script to avoid problems when there are undefined symbols. It's necessary + to avoid that the DWARF section is relocated before such undefined + symbols are found. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elfmicroblaze.sc b/binutils-2.21/ld/scripttempl/elfmicroblaze.sc new file mode 100644 index 0000000..a54b891 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elfmicroblaze.sc @@ -0,0 +1,222 @@ +# Adapted from mips.sc +# These variables may be overridden by the emulation file. The +# defaults are appropriate for a DECstation running Ultrix. +test -z "$ENTRY" && ENTRY=_start + +#test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x0" + +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}") +/*${LIB_SEARCH_DIRS}*/ +${RELOCATING+${LIB_SEARCH_DIRS}} + +${RELOCATING+ENTRY (${ENTRY})} + +_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0; +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400; + +SECTIONS +{ + .vectors.reset 0x0 : { KEEP (*(.vectors.reset)) } = 0 + .vectors.sw_exception 0x8 : { KEEP (*(.vectors.sw_exception)) } = 0 + .vectors.interrupt 0x10 : { KEEP (*(.vectors.interrupt)) } = 0 + .vectors.debug_sw_break 0x18 : { KEEP (*(.vectors.debug_sw_break)) } = 0 + .vectors.hw_exception 0x20 : { KEEP (*(.vectors.hw_exception)) } = 0 + + ${RELOCATING+. = _TEXT_START_ADDR;} + + ${RELOCATING+ _ftext = .;} + .text : { + ${RELOCATING+*(.text)} + ${RELOCATING+*(.text.*)} + ${RELOCATING+*(.gnu.linkonce.t.*)} + } + ${RELOCATING+ _etext = .;} + + .init : { KEEP (*(.init)) } =0 + .fini : { KEEP (*(.fini)) } =0 + + ${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+ . = ALIGN(4);} + ${RELOCATING+ _frodata = . ;} + .rodata : { + ${RELOCATING+*(.rodata)} + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r.*)} + ${CONSTRUCTING+CONSTRUCTORS}; /* Is this needed? */ + } + ${RELOCATING+ _erodata = .;} + + /* Alignments by 8 to ensure that _SDA2_BASE_ on a word boundary */ + /* Note that .sdata2 and .sbss2 must be contiguous */ + ${RELOCATING+. = ALIGN(8);} + ${RELOCATING+ _ssrw = .;} + .sdata2 : { + ${RELOCATING+*(.sdata2)} + ${RELOCATING+*(.sdata2.*)} + ${RELOCATING+*(.gnu.linkonce.s2.*)} + } + ${RELOCATING+. = ALIGN(4);} + .sbss2 : { + ${RELOCATING+PROVIDE (__sbss2_start = .);} + ${RELOCATING+*(.sbss2)} + ${RELOCATING+*(.sbss2.*)} + ${RELOCATING+*(.gnu.linkonce.sb2.*)} + ${RELOCATING+PROVIDE (__sbss2_end = .);} + } + ${RELOCATING+. = ALIGN(8);} + ${RELOCATING+ _essrw = .;} + ${RELOCATING+ _ssrw_size = _essrw - _ssrw;} + ${RELOCATING+ PROVIDE (_SDA2_BASE_ = _ssrw + (_ssrw_size / 2 ));} + + ${RELOCATING+ . = ALIGN(4);} + ${RELOCATING+ _fdata = .;} + .data : { + ${RELOCATING+*(.data)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+CONSTRUCTORS}; /* Is this needed? */ + } + ${RELOCATING+ _edata = . ;} + + /* Added to handle pic code */ + .got : { + ${RELOCATING+*(.got)} + } + + .got1 : { + ${RELOCATING+*(.got1)} + } + + .got2 : { + ${RELOCATING+*(.got2)} + } + + /* Added by Sathya to handle C++ exceptions */ + .eh_frame : { + ${RELOCATING+*(.eh_frame)} + } + + .jcr : { + ${RELOCATING+*(.jcr)} + } + + .gcc_except_table : { + ${RELOCATING+*(.gcc_except_table)} + } + + /* Alignments by 8 to ensure that _SDA_BASE_ on a word boundary */ + /* Note that .sdata and .sbss must be contiguous */ + ${RELOCATING+. = ALIGN(8);} + ${RELOCATING+ _ssro = .;} + .sdata : { + ${RELOCATING+*(.sdata)} + ${RELOCATING+*(.sdata.*)} + ${RELOCATING+*(.gnu.linkonce.s.*)} + } + ${RELOCATING+. = ALIGN(4);} + .sbss : { + ${RELOCATING+PROVIDE (__sbss_start = .);} + ${RELOCATING+*(.sbss)} + ${RELOCATING+*(.sbss.*)} + ${RELOCATING+*(.gnu.linkonce.sb.*)} + ${RELOCATING+PROVIDE (__sbss_end = .);} + } + ${RELOCATING+. = ALIGN(8);} + ${RELOCATING+ _essro = .;} + ${RELOCATING+ _ssro_size = _essro - _ssro;} + ${RELOCATING+PROVIDE (_SDA_BASE_ = _ssro + (_ssro_size / 2 ));} + + ${RELOCATING+ . = ALIGN(4);} + ${RELOCATING+ _fbss = .;} + .bss : { + ${RELOCATING+PROVIDE (__bss_start = .);} + ${RELOCATING+*(.bss)} + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.gnu.linkonce.b.*)} + ${RELOCATING+*(COMMON)} + ${RELOCATING+. = ALIGN(4);} + + ${RELOCATING+PROVIDE (__bss_end = .);} + + } + + ${RELOCATING+ . = ALIGN(4);} + + .heap : { + ${RELOCATING+ _heap = .;} + ${RELOCATING+ _heap_start = .;} + ${RELOCATING+ . += _HEAP_SIZE;} + ${RELOCATING+ _heap_end = .;} + } + + ${RELOCATING+ . = ALIGN(4);} + + .stack : { + ${RELOCATING+ _stack_end = .;} + ${RELOCATING+ . += _STACK_SIZE;} + ${RELOCATING+ . = ALIGN(8);} + ${RELOCATING+ _stack = .;} + ${RELOCATING+ _end = .;} + } + + .tdata : { + ${RELOCATING+*(.tdata)} + ${RELOCATING+*(.tdata.*)} + ${RELOCATING+*(.gnu.linkonce.td.*)} + } + .tbss : { + ${RELOCATING+*(.tbss)} + ${RELOCATING+*(.tbss.*)} + ${RELOCATING+*(.gnu.linkonce.tb.*)} + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/elfxtensa.sc b/binutils-2.21/ld/scripttempl/elfxtensa.sc new file mode 100644 index 0000000..7d5d5ee --- /dev/null +++ b/binutils-2.21/ld/scripttempl/elfxtensa.sc @@ -0,0 +1,586 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not +# empty. +# SMALL_DATA_CTOR - .ctors contains small data. +# SMALL_DATA_DTOR - .dtors contains small data. +# 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_RELRO_SECTIONS - other than .data.rel.ro ... +# (e.g. PPC32 .fixup, .got[12]) +# OTHER_BSS_SECTIONS - other than .bss .sbss ... +# ATTRS_SECTIONS - at the end +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_ADDR - the first byte of the text segment, after any +# headers. +# TEXT_BASE_ADDRESS - the first byte of the text segment. +# 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. +# DATA_END_SYMBOLS - symbols that appear at the end of the +# writeable data sections. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. +# BSS_PLT - .plt should be in bss segment +# NO_REL_RELOCS - Don't include .rel.* sections in script +# NO_RELA_RELOCS - Don't include .rela.* sections in script +# NON_ALLOC_DYN - Place dynamic sections after data segment. +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# STACK_ADDR - start of a .stack section. +# OTHER_SYMBOLS - symbols to place right at the end of the script. +# ETEXT_NAME - name of a symbol for the end of the text section, +# normally etext. +# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, +# so that .got can be in the RELRO area. It should be set to +# the number of bytes in the beginning of .got.plt which can be +# in the RELRO area as well. +# USER_LABEL_PREFIX - prefix to add to user-visible symbols. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# .debug_info .gnu.linkonce.wi.foo +# .tdata .gnu.linkonce.td.foo +# .tbss .gnu.linkonce.tb.foo +# .lrodata .gnu.linkonce.lr.foo +# .ldata .gnu.linkonce.l.foo +# .lbss .gnu.linkonce.lb.foo +# +# plus exception-handling information for Tensilica's XCC compiler: +# .xt_except_table .gnu.linkonce.e.foo +# .xt_except_desc .gnu.linkonce.h.foo +# +# plus Xtensa-specific literal sections: +# .literal .gnu.linkonce.literal.foo +# .lit4 .gnu.linkonce.lit4.foo +# +# plus Xtensa-specific "property table" sections: +# .xt.lit .gnu.linkonce.p.foo +# .xt.insn .gnu.linkonce.x.foo (obsolete) +# .xt.prop .gnu.linkonce.prop.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +test "$LD_FLAG" = "N" && DATA_ADDR=. +test -z "${ETEXT_NAME}" && ETEXT_NAME=etext +test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" +test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" +test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT +test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" +DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" +DATA_SEGMENT_RELRO_END="" +DATA_SEGMENT_END="" +if test -n "${COMMONPAGESIZE}"; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" + DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" +fi +if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then + INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" +fi +if test -z "$PLT"; then + PLT=".plt ${RELOCATING-0} : { *(.plt) }" +fi +test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes +if test -z "$GOT"; then + if test -z "$SEPARATE_GOTPLT"; then + GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }" + else + GOT=".got ${RELOCATING-0} : { *(.got) }" + GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }" + fi +fi +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }" +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" +INIT_LIT=".init.literal 0 : { *(.init.literal) }" +INIT=".init 0 : { *(.init) }" +FINI_LIT=".fini.literal 0 : { *(.fini.literal) }" +FINI=".fini 0 : { *(.fini) }" +if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { + ${RELOCATING+${SBSS_START_SYMBOLS}} + ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)} + *(.dynsbss) + *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) + *(.scommon) + ${RELOCATING+${SBSS_END_SYMBOLS}} + }" + SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" + SDATA="/* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)} + *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) + }" + SDATA2=".sdata2 ${RELOCATING-0} : + { + ${RELOCATING+${SDATA2_START_SYMBOLS}} + *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) + }" + REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" + REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" + REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } + .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" + REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } + .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" +else + NO_SMALL_DATA=" " +fi +if test -z "${DATA_GOT}"; then + if test -n "${NO_SMALL_DATA}"; then + DATA_GOT=" " + fi +fi +if test -z "${SDATA_GOT}"; then + if test -z "${NO_SMALL_DATA}"; then + SDATA_GOT=" " + fi +fi +test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " +test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" + .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } + .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } + .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } + .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } + .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } + .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" +test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS=" + ${OTHER_BSS_SECTIONS} + .lbss ${RELOCATING-0} : + { + *(.dynlbss) + *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) + *(LARGE_COMMON) + }" +test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" + .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : + { + *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) + } + .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : + { + *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) + ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + }" +INIT_ARRAY=".init_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} + }" +FINI_ARRAY=".fini_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} + }" +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)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" +DTOR=".dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+_stack = .;} + *(.stack) + }" + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" +fi + +cat <<EOF +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} + ${INITIAL_READONLY_SECTIONS} + .note.gnu.build-id : { *(.note.gnu.build-id) } +EOF + +test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN +test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= +cat > ldscripts/dyntmp.$$ <<EOF + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } +EOF + +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) } + .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) } + .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } + .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } + .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } + .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + ${REL_SDATA} + ${REL_SBSS} + ${REL_SDATA2} + ${REL_SBSS2} + .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } + ${REL_LARGE} +EOF + +if [ -n "$COMBRELOC" ]; then +cat >> ldscripts/dyntmp.$$ <<EOF + .rel.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ +cat >> ldscripts/dyntmp.$$ <<EOF + } + .rela.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ +cat >> ldscripts/dyntmp.$$ <<EOF + } +EOF +fi + +cat >> ldscripts/dyntmp.$$ <<EOF + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} +EOF + +if test -z "${NON_ALLOC_DYN}"; then + if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then + cat ldscripts/dyntmp.$$ + else + if test -z "${NO_REL_RELOCS}"; then + sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$ + fi + if test -z "${NO_RELA_RELOCS}"; then + sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$ + fi + fi + rm -f ldscripts/dyntmp.$$ +fi + +cat <<EOF + ${RELOCATING-$INIT_LIT} + ${RELOCATING-$INIT} + + ${TEXT_PLT+${PLT}} + ${TINY_READONLY_SECTION} + .text ${RELOCATING-0} : + { + *(.got.plt* .plt*) + + ${RELOCATING+${INIT_START}} + ${RELOCATING+KEEP (*(.init.literal))} + ${RELOCATING+KEEP (*(.init))} + ${RELOCATING+${INIT_END}} + + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.literal .text .stub${RELOCATING+ .literal.* .text.* .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + + ${RELOCATING+${FINI_START}} + ${RELOCATING+KEEP (*(.fini.literal))} + ${RELOCATING+KEEP (*(.fini))} + ${RELOCATING+${FINI_END}} + } =${NOP-0} + + ${RELOCATING-$FINI_LIT} + ${RELOCATING-$FINI} + + ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} + ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} + ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} + ${WRITABLE_RODATA-${RODATA}} + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${OTHER_READONLY_SECTIONS} + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } + + /* 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-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + + /* Exception handling */ + .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + + /* Thread Local Storage sections */ + .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } + .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } + + .preinit_array ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} + KEEP (*(.preinit_array)) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} + } + ${RELOCATING+${INIT_ARRAY}} + ${RELOCATING+${FINI_ARRAY}} + ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} + ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} + .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } + + ${RELOCATING+${DATARELRO}} + ${OTHER_RELRO_SECTIONS} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${DATA_GOT+${RELRO_NOW+${GOT}}} + ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} + ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} + ${RELOCATING+${DATA_SEGMENT_RELRO_END}} + ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} + ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} + + ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} + ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} + ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}} + ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}} + ${SDATA_GOT+${GOT}} + ${SDATA_GOT+${OTHER_GOT_SECTIONS}} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${SBSS} + ${BSS_PLT+${PLT}} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + } + ${OTHER_BSS_SECTIONS} + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${LARGE_SECTIONS} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} + ${RELOCATING+${DATA_SEGMENT_END}} +EOF + +if test -n "${NON_ALLOC_DYN}"; then + if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then + cat ldscripts/dyntmp.$$ + else + if test -z "${NO_REL_RELOCS}"; then + sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$ + fi + if test -z "${NO_RELA_RELOCS}"; then + sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$ + fi + fi + rm -f ldscripts/dyntmp.$$ +fi + +cat <<EOF + /* 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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes .zdebug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges .zdebug_ranges) } + + ${TINY_DATA_SECTION} + ${TINY_BSS_SECTION} + + ${STACK_ADDR+${STACK}} + ${ATTRS_SECTIONS} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_SYMBOLS}} + ${RELOCATING+${DISCARDED}} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/epocpe.sc b/binutils-2.21/ld/scripttempl/epocpe.sc new file mode 100644 index 0000000..0651c01 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/epocpe.sc @@ -0,0 +1,152 @@ +# 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} + +${RELOCATING+ENTRY (_mainCRTStartup)} + +SECTIONS +{ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ *(.init)} + *(.text) + ${R_TEXT} + *(.glue_7t) + *(.glue_7) + ${RELOCATING+ *(.text.*)} + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); *(.ctors); *(.ctor); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); LONG (0); } + ${RELOCATING+ *(.fini)} + /* ??? Why is .gcc_exc here? */ + ${RELOCATING+ *(.gcc_exc)} + ${RELOCATING+ etext = .;} + *(.gcc_except_table) + + /* For EPOC the read only data is located at the end of the .text + section */ + *(.rdata) + ${R_RDATA} + *(.eh_frame) + } + + /* The Cygwin32 library uses a section to avoid copying certain data + on fork. This used to be named ".data$nocopy". The linker used + to include this between __data_start__ and __data_end__, but that + breaks building the cygwin32 dll. Instead, we name the section + ".data_cygwin_nocopy" and explictly include it after __data_end__. */ + + .data ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__data_start__ = . ;} + *(.data) + *(.data2) + ${R_DATA} + ${RELOCATING+__data_end__ = . ;} + ${RELOCATING+*(.data_cygwin_nocopy)} + } + + .bss ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__bss_start__ = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+__bss_end__ = . ;} + } + + .edata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.edata) + } + + /DISCARD/ : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${R_IDATA} + } + + .CRT ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${R_CRT} + } + + .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* end is deprecated, don't use it */ + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} + ${RELOCATING+ __end__ = .;} + } + + .reloc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.reloc) + } + + .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rsrc) + ${R_RSRC} + } + + .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + + .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } + +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8300.sc b/binutils-2.21/ld/scripttempl/h8300.sc new file mode 100644 index 0000000..f142f4b --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8300.sc @@ -0,0 +1,94 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +${RELOCATING+ENTRY ("_start")} + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + ram : o = 0x0100, l = 0xfdfc + /* The stack starts at the top of main ram. */ + topram : o = 0xfefc, l = 0x4 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + SHORT (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.init : + { + *(.init) + } ${RELOCATING+ > ram} + +.text : + { + *(.rodata) + *(.text) + *(.text.*) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + *(.data.*) + *(.tiny) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8300h.sc b/binutils-2.21/ld/scripttempl/h8300h.sc new file mode 100644 index 0000000..9a41537 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8300h.sc @@ -0,0 +1,97 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300h) +${RELOCATING+ENTRY ("_start")} + +/* The memory size is 256KB to coincide with the simulator. + Don't change either without considering the other. */ + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + /* We still only use 256k as the main ram size. */ + ram : o = 0x0100, l = 0x3fefc + /* The stack starts at the top of main ram. */ + topram : o = 0x3fffc, l = 0x4 + /* This holds variables in the "tiny" sections. */ + tiny : o = 0xff8000, l = 0x7f00 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xffff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + LONG (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.tiny : + { + *(.tiny) + } ${RELOCATING+ > tiny} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8300hn.sc b/binutils-2.21/ld/scripttempl/h8300hn.sc new file mode 100644 index 0000000..5cdfc5a --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8300hn.sc @@ -0,0 +1,87 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300hn) +${RELOCATING+ENTRY ("_start")} + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + ram : o = 0x0100, l = 0xfdfc + /* The stack starts at the top of main ram. */ + topram : o = 0xfefc, l = 0x4 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + SHORT (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + *(.tiny) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8300s.sc b/binutils-2.21/ld/scripttempl/h8300s.sc new file mode 100644 index 0000000..e07253d --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8300s.sc @@ -0,0 +1,97 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300s) +${RELOCATING+ENTRY ("_start")} + +/* The memory size is 256KB to coincide with the simulator. + Don't change either without considering the other. */ + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + /* We still only use 256k as the main ram size. */ + ram : o = 0x0100, l = 0x3fefc + /* The stack starts at the top of main ram. */ + topram : o = 0x3fffc, l = 0x4 + /* This holds variables in the "tiny" sections. */ + tiny : o = 0xff8000, l = 0x7f00 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xffff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + LONG (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.tiny : + { + *(.tiny) + } ${RELOCATING+ > tiny} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8300sn.sc b/binutils-2.21/ld/scripttempl/h8300sn.sc new file mode 100644 index 0000000..27ba4a1 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8300sn.sc @@ -0,0 +1,87 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300sn) +${RELOCATING+ENTRY ("_start")} + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + ram : o = 0x0100, l = 0xfdfc + /* The stack starts at the top of main ram. */ + topram : o = 0xfefc, l = 0x4 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + SHORT (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + *(.tiny) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8300sx.sc b/binutils-2.21/ld/scripttempl/h8300sx.sc new file mode 100644 index 0000000..247e977 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8300sx.sc @@ -0,0 +1,97 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300sx) +${RELOCATING+ENTRY ("_start")} + +/* The memory size is 256KB to coincide with the simulator. + Don't change either without considering the other. */ + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + /* We still only use 256k as the main ram size. */ + ram : o = 0x0100, l = 0x3fefc + /* The stack starts at the top of main ram. */ + topram : o = 0x3fffc, l = 0x4 + /* This holds variables in the "tiny" sections. */ + tiny : o = 0xff8000, l = 0x7f00 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xffff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + LONG (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.tiny : + { + *(.tiny) + } ${RELOCATING+ > tiny} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8300sxn.sc b/binutils-2.21/ld/scripttempl/h8300sxn.sc new file mode 100644 index 0000000..90bd789 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8300sxn.sc @@ -0,0 +1,87 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(h8300sxn) +${RELOCATING+ENTRY ("_start")} + +MEMORY +{ + /* 0xc4 is a magic entry. We should have the linker just + skip over it one day... */ + vectors : o = 0x0000, l = 0xc4 + magicvectors : o = 0xc4, l = 0x3c + ram : o = 0x0100, l = 0xfdfc + /* The stack starts at the top of main ram. */ + topram : o = 0xfefc, l = 0x4 + /* At the very top of the address space is the 8-bit area. */ + eight : o = 0xff00, l = 0x100 +} + +SECTIONS +{ +.vectors : + { + /* Use something like this to place a specific + function's address into the vector table. + + SHORT (ABSOLUTE (_foobar)). */ + + *(.vectors) + } ${RELOCATING+ > vectors} + +.text : + { + *(.rodata) + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + *(.tiny) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.eight : + { + *(.eight) + } ${RELOCATING+ > eight} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8500.sc b/binutils-2.21/ld/scripttempl/h8500.sc new file mode 100644 index 0000000..6b889dd --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8500.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Code and data 64k total */ + +SECTIONS +{ +.text ${RELOCATING+ 0x0000} : + { + *(.text) + ${RELOCATING+ _etext = . ; } + } + +.data ${RELOCATING+ . } : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } + +.rdata ${RELOCATING+ . } : + { + *(.rdata); + *(.strings) + + ${CONSTRUCTING+${TORS}} + } + +.bss ${RELOCATING+ . } : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } + +.stack ${RELOCATING+ 0xfff0} : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8500b.sc b/binutils-2.21/ld/scripttempl/h8500b.sc new file mode 100644 index 0000000..fb6c0e8 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8500b.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Code and data, both larger than 64k */ + +SECTIONS +{ +.text ${RELOCATING+ 0x10000} : + { + *(.text) + ${RELOCATING+ _etext = . ; } + } + +.data ${RELOCATING+ 0x20000} : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } + +.rdata ${RELOCATING+ 0x30000} : + { + *(.rdata); + *(.strings) + + ${CONSTRUCTING+${TORS}} + } + +.bss ${RELOCATING+ 0x40000} : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } + +.stack ${RELOCATING+ 0x50000} : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8500c.sc b/binutils-2.21/ld/scripttempl/h8500c.sc new file mode 100644 index 0000000..145ffc5 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8500c.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Compact model - code < 64k, data > 64k */ + +SECTIONS +{ +.text 0x10000 : + { + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + +.data 0x20000 : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.rdata 0x30000 : + { + *(.rdata); + + ${CONSTRUCTING+${TORS}} + } ${RELOCATING+ > ram} + +.bss 0x40000 : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack 0x5fff0 : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > topram} + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8500m.sc b/binutils-2.21/ld/scripttempl/h8500m.sc new file mode 100644 index 0000000..3314066 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8500m.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Code and data, both larger than 64k */ + +SECTIONS +{ +.text ${RELOCATING+ 0x10000} : + { + *(.text) + ${RELOCATING+ _etext = . ; } + } + +.data ${RELOCATING+ 0x20000} : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } + +.rdata ${RELOCATING+ . } : + { + *(.rdata); + *(.strings) + + ${CONSTRUCTING+${TORS}} + } + +.bss ${RELOCATING+ . } : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } + +.stack ${RELOCATING+ 0x2fff0} : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/h8500s.sc b/binutils-2.21/ld/scripttempl/h8500s.sc new file mode 100644 index 0000000..da4d210 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/h8500s.sc @@ -0,0 +1,61 @@ +TORS=" + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ;" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +/* Code and data, both 64k */ + +SECTIONS +{ +.text ${RELOCATING+ 0x10000} : + { + *(.text) + ${RELOCATING+ _etext = . ; } + } + +.rdata ${RELOCATING+ 0x20000} : + { + *(.rdata); + *(.strings) + + ${CONSTRUCTING+${TORS}} + } + +.data ${RELOCATING+ . } : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } + +.bss ${RELOCATING+ .} : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } + +.stack ${RELOCATING+ 0x2fff0} : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } + +.stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + +.stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/hppaelf.sc b/binutils-2.21/ld/scripttempl/hppaelf.sc new file mode 100644 index 0000000..a96ad54 --- /dev/null +++ b/binutils-2.21/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}) +${RELOCATING+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/binutils-2.21/ld/scripttempl/i386beos.sc b/binutils-2.21/ld/scripttempl/i386beos.sc new file mode 100644 index 0000000..f507acc --- /dev/null +++ b/binutils-2.21/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} + +${RELOCATING+ENTRY (__start)} +${RELOCATING+header = .;} +${RELOCATING+__fltused = .; /* set up floating pt for MS .obj\'s */} +${RELOCATING+__ldused = .;} +SECTIONS +{ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ __text_start__ = . ;} + ${RELOCATING+ *(.init)} + *(.text) + ${R_TEXT} + *(.glue_7t) + *(.glue_7) + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); *(.ctors); *(.ctor); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); LONG (0); } + ${RELOCATING+ *(.fini)} + /* ??? Why is .gcc_exc here? */ + ${RELOCATING+ *(.gcc_exc)} + ${RELOCATING+ etext = .;} + ${RELOCATING+ __text_end__ = .;} + *(.gcc_except_table) + } + + /* The Cygwin32 library uses a section to avoid copying certain data + on fork. This used to be named ".data$nocopy". The linker used + to include this between __data_start__ and __data_end__, but that + breaks building the cygwin32 dll. Instead, we name the section + ".data_cygwin_nocopy" and explictly include it after __data_end__. */ + + .data ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__data_start__ = . ;} + *(.data) + *(.data2) + ${R_DATA} + ${RELOCATING+__data_end__ = . ;} + ${RELOCATING+*(.data_cygwin_nocopy)} + } + + .bss ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__bss_start__ = . ;} + *(.bss) + *(COMMON) + /* link.exe apparently pulls in .obj's because of UNDEF common + symbols, which is not the coff way, but that's MS for you. */ + *(.CRT\$XCA) + *(.CRT\$XCZ) + *(.CRT\$XIA) + *(.CRT\$XIZ) + ${RELOCATING+__bss_end__ = . ;} + } + + .rdata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rdata) + ${R_RDATA} + *(.eh_frame) + } + + .edata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.edata) + } + + /DISCARD/ : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + *(.debug*) + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${R_IDATA} + } + .CRT ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${R_CRT} + } + + .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* end is deprecated, don't use it */ + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} + ${RELOCATING+ __end__ = .;} + } + + .reloc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.reloc) + } + + .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rsrc) + ${R_RSRC} + } + + .exc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.exc) + ${R_EXC} + } + + .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + + .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 ${RELOCATING+(NOLOAD)} : { *(.debug) } + .line 0 ${RELOCATING+(NOLOAD)} : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 ${RELOCATING+(NOLOAD)} : { *(.debug_srcinfo) } + .debug_sfnames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 ${RELOCATING+(NOLOAD)} : { *(.debug_aranges) } + .debug_pubnames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 ${RELOCATING+(NOLOAD)} : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_abbrev 0 ${RELOCATING+(NOLOAD)} : { *(.debug_abbrev) } + .debug_line 0 ${RELOCATING+(NOLOAD)} : { *(.debug_line) } + .debug_frame 0 ${RELOCATING+(NOLOAD)} : { *(.debug_frame) } + .debug_str 0 ${RELOCATING+(NOLOAD)} : { *(.debug_str) } + .debug_loc 0 ${RELOCATING+(NOLOAD)} : { *(.debug_loc) } + .debug_macinfo 0 ${RELOCATING+(NOLOAD)} : { *(.debug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_weaknames) } + .debug_funcnames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_funcnames) } + .debug_typenames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_typenames) } + .debug_varnames 0 ${RELOCATING+(NOLOAD)} : { *(.debug_varnames) } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/i386coff.sc b/binutils-2.21/ld/scripttempl/i386coff.sc new file mode 100644 index 0000000..da14632 --- /dev/null +++ b/binutils-2.21/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} + +${RELOCATING+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/binutils-2.21/ld/scripttempl/i386go32.sc b/binutils-2.21/ld/scripttempl/i386go32.sc new file mode 100644 index 0000000..e5bcf2a --- /dev/null +++ b/binutils-2.21/ld/scripttempl/i386go32.sc @@ -0,0 +1,79 @@ +# Linker script for i386 go32 (DJGPP) + +test -z "$ENTRY" && ENTRY=start +EXE=${CONSTRUCTING+${RELOCATING+-exe}} + +# These are substituted in as variables in order to get '}' in a shell +# conditional expansion. +CTOR='.ctor : { + *(SORT(.ctors.*)) + *(.ctor) + }' +DTOR='.dtor : { + *(SORT(.dtors.*)) + *(.dtor) + }' + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}${EXE}") + +${RELOCATING+ENTRY (${ENTRY})} + +SECTIONS +{ + .text ${RELOCATING+ ${TARGET_PAGE_SIZE}+SIZEOF_HEADERS} : { + *(.text) + ${RELOCATING+*(.text.*)} + ${RELOCATING+*(.gnu.linkonce.t*)} + *(.const*) + *(.ro*) + ${RELOCATING+*(.gnu.linkonce.r*)} + ${RELOCATING+etext = . ; PROVIDE(_etext = .) ;} + ${RELOCATING+. = ALIGN(${SEGMENT_SIZE});} + } + .data ${RELOCATING+ ${DATA_ALIGNMENT}} : { + ${RELOCATING+djgpp_first_ctor = . ; + *(SORT(.ctors.*)) + *(.ctor) + djgpp_last_ctor = . ;} + ${RELOCATING+djgpp_first_dtor = . ; + *(SORT(.dtors.*)) + *(.dtor) + djgpp_last_dtor = . ;} + *(.data) + ${RELOCATING+*(.data.*)} + + ${RELOCATING+*(.gcc_exc*)} + ${RELOCATING+___EH_FRAME_BEGIN__ = . ;} + ${RELOCATING+*(.eh_fram*)} + ${RELOCATING+___EH_FRAME_END__ = . ;} + ${RELOCATING+LONG(0);} + + ${RELOCATING+*(.gnu.linkonce.d*)} + ${RELOCATING+edata = . ; PROVIDE(_edata = .) ;} + ${RELOCATING+. = ALIGN(${SEGMENT_SIZE});} + } + ${CONSTRUCTING+${RELOCATING-$CTOR}} + ${CONSTRUCTING+${RELOCATING-$DTOR}} + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + *(COMMON) + ${RELOCATING+ end = . ; PROVIDE(_end = .) ;} + ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});} + } + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/i386msdos.sc b/binutils-2.21/ld/scripttempl/i386msdos.sc new file mode 100644 index 0000000..4d312e7 --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/i860coff.sc b/binutils-2.21/ld/scripttempl/i860coff.sc new file mode 100644 index 0000000..f268c6f --- /dev/null +++ b/binutils-2.21/ld/scripttempl/i860coff.sc @@ -0,0 +1,42 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} +PROVIDE (__stack = 0); +SECTIONS +{ + .text ${RELOCATING+ 0x1000000} : { + *(.text) + ${CONSTRUCTING+ . = ALIGN(4);} + ${RELOCATING+ etext = .;} + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + } + .data : { + *(.data) + ${RELOCATING+ edata = .}; + } + .bss : { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+ end = ALIGN(0x8)}; + ${RELOCATING+ _end = ALIGN(0x8)}; + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/i960.sc b/binutils-2.21/ld/scripttempl/i960.sc new file mode 100644 index 0000000..dc33555 --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/ip2k.sc b/binutils-2.21/ld/scripttempl/ip2k.sc new file mode 100644 index 0000000..b10013a --- /dev/null +++ b/binutils-2.21/ld/scripttempl/ip2k.sc @@ -0,0 +1,150 @@ +cat << EOF +OUTPUT_FORMAT("elf32-ip2k", "elf32-ip2k", "elf32-ip2k") +OUTPUT_ARCH(ip2k) +${RELOCATING+ENTRY(_start)} +SEARCH_DIR(.); + +/* IP2022 default linker script. */ + +MEMORY +{ + D_GPR : org = 0x01000080, len = 128 + D_RAM : org = 0x01000100, len = 4K - 256 + P_RAM : org = 0x02000000, len = 16K + P_ROM : org = 0x02010000, len = 64K - 32 + P_RESET : org = 0x0201FFE0, len = 32 + P_CONFIG : org = 0x02020000, len = 128 +} + +SECTIONS +{ + /* Allocated memory end markers + (initialized to start of appropiate memory address). */ + __data_end = 0x01000100; + __pram_end = 0x02000000; + __flash_end = 0x02010000; + + /* Global general purpose registers in direct addressing range. */ + .gpr 0x01000080 : + { + *(.gpr) + } >D_GPR + + /* Pre-allocated, pre-initialized data memory. */ + __data_run_begin = __data_end; + __data_load_begin = (__flash_end + 1) & 0xFFFFFFFE; + .data __data_run_begin : AT (__data_load_begin) + { + * (.data); + * (.rodata) + } >D_RAM + __data_run_end = __data_run_begin + SIZEOF(.data); + __data_load_end = __data_load_begin + SIZEOF(.data); + __data_end = __data_run_end; + __flash_end = __data_load_end; + + /* Pre-allocated, uninitialized data memory. */ + __bss_begin = __data_end; + .bss __bss_begin : + { + * (.bss) + } >D_RAM + __bss_end = __bss_begin + SIZEOF(.bss); + __data_end = __bss_end; + + /* Pre-allocated PRAM data memory. */ + __pram_data_begin = (__pram_end + 1) & 0xFFFFFFFE; + .pram_data __pram_data_begin : + { + * (.pram_data) + } >P_RAM + __pram_data_end = __pram_data_begin + SIZEOF(.pram_data); + __pram_end = __pram_data_end; + + /* PRAM code. */ + __pram_run_begin = (__pram_end + 1) & 0xFFFFFFFE; + __pram_load_begin = (__flash_end + 1) & 0xFFFFFFFE; + .pram __pram_run_begin : AT (__pram_load_begin) + { + * (.pram) + } >P_RAM + __pram_run_end = __pram_run_begin + SIZEOF(.pram); + __pram_load_end = __pram_load_begin + SIZEOF(.pram); + + __pram_load_shift = ((__pram_run_begin - __pram_load_begin) & 0x1FFFF) | 0x02000000; + __pram_end = __pram_run_end; + __flash_end = __pram_load_end; + + /* PRAM overlay code. */ + __pram_overlay_run_start = (__pram_end + 1) & 0xFFFFFFFE; + __pram_overlay_load_start = (__flash_end + 1) & 0xFFFFFFFE; + OVERLAY __pram_overlay_run_start : AT (__pram_overlay_load_start) + { + .pram1 { */overlay1/* (.pram); * (.pram1) } + .pram2 { */overlay2/* (.pram); * (.pram2) } + } >P_RAM + __pram_overlay_run_end = .; + __pram_overlay_load_end = __pram_overlay_load_start + SIZEOF(.pram1) + SIZEOF(.pram2); + __pram_end = __pram_overlay_run_end; + __flash_end = __pram_overlay_load_end; + + /* Flash code. */ + __text_begin = (__flash_end + 1) & 0xFFFFFFFE; + .text __text_begin : + { + * (.text); + * (.text.libgcc) + } >P_ROM = 0xffff + __text_end = __text_begin + SIZEOF(.text); + __flash_end = __text_end; + + /* Strings. */ + __strings_begin = (__flash_end + 1) & 0xFFFFFFFE; + .strings __strings_begin : + { + * (strings); + * (.progmem.data) + } >P_ROM = 0xffff + __strings_end = __strings_begin + SIZEOF (.strings); + __flash_end = __strings_end; + + .ctors : { * (.ctors) } > P_ROM + .dtors : { * (.dtors) } > P_ROM + + /* Reset code. */ + .reset : { * (.reset) } >P_RESET = 0xffff + + /* Configuration block. */ + .config : { * (.config) } >P_CONFIG = 0xffff + + /* Stack. */ + PROVIDE (__stack = 0x01000FFF); + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + + /* DWARF 1. */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions. */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + /* DWARF 1.1 and DWARF 2. */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + /* DWARF 2. */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/iq2000.sc b/binutils-2.21/ld/scripttempl/iq2000.sc new file mode 100644 index 0000000..acfc07e --- /dev/null +++ b/binutils-2.21/ld/scripttempl/iq2000.sc @@ -0,0 +1,444 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# INITIAL_READONLY_SECTIONS - at start of data segment +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_TEXT_SECTIONS - these get put in .text when relocating +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# BSS_PLT - .plt should be in bss segment +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }" +SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} }" +SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} }" +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" +fi + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +SECTIONS +{ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + ${TEXT_DYNAMIC+${DYNAMIC}} + +EOF +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT=cat +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : + { + *(.rel.text) + ${RELOCATING+*(.rel.text.*)} + ${RELOCATING+*(.rel.gnu.linkonce.t.*)} + } + .rela.text ${RELOCATING-0} : + { + *(.rela.text) + ${RELOCATING+*(.rela.text.*)} + ${RELOCATING+*(.rela.gnu.linkonce.t.*)} + } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : + { + *(.rel.rodata) + ${RELOCATING+*(.rel.rodata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.r.*)} + } + .rela.rodata ${RELOCATING-0} : + { + *(.rela.rodata) + ${RELOCATING+*(.rela.rodata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.r.*)} + } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data ${RELOCATING-0} : + { + *(.rel.data) + ${RELOCATING+*(.rel.data.*)} + ${RELOCATING+*(.rel.gnu.linkonce.d.*)} + } + .rela.data ${RELOCATING-0} : + { + *(.rela.data) + ${RELOCATING+*(.rela.data.*)} + ${RELOCATING+*(.rela.gnu.linkonce.d.*)} + } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + .rel.sdata ${RELOCATING-0} : + { + *(.rel.sdata) + ${RELOCATING+*(.rel.sdata.*)} + ${RELOCATING+*(.rel.gnu.linkonce.s.*)} + } + .rela.sdata ${RELOCATING-0} : + { + *(.rela.sdata) + ${RELOCATING+*(.rela.sdata.*)} + ${RELOCATING+*(.rela.gnu.linkonce.s.*)} + } + .rel.sbss ${RELOCATING-0} : + { + *(.rel.sbss) + ${RELOCATING+*(.rel.sbss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb.*)} + } + .rela.sbss ${RELOCATING-0} : + { + *(.rela.sbss) + ${RELOCATING+*(.rela.sbss.*)} + ${RELOCATING+*(.rela.gnu.linkonce.sb.*)} + } + .rel.sdata2 ${RELOCATING-0} : + { + *(.rel.sdata2) + ${RELOCATING+*(.rel.sdata2.*)} + ${RELOCATING+*(.rel.gnu.linkonce.s2.*)} + } + .rela.sdata2 ${RELOCATING-0} : + { + *(.rela.sdata2) + ${RELOCATING+*(.rela.sdata2.*)} + ${RELOCATING+*(.rela.gnu.linkonce.s2.*)} + } + .rel.sbss2 ${RELOCATING-0} : + { + *(.rel.sbss2) + ${RELOCATING+*(.rel.sbss2.*)} + ${RELOCATING+*(.rel.gnu.linkonce.sb2.*)} + } + .rela.sbss2 ${RELOCATING-0} : + { + *(.rela.sbss2) + ${RELOCATING+*(.rela.sbss2.*)} + ${RELOCATING+*(.rela.gnu.linkonce.sb2.*)} + } + .rel.bss ${RELOCATING-0} : + { + *(.rel.bss) + ${RELOCATING+*(.rel.bss.*)} + ${RELOCATING+*(.rel.gnu.linkonce.b.*)} + } + .rela.bss ${RELOCATING-0} : + { + *(.rela.bss) + ${RELOCATING+*(.rela.bss.*)} + ${RELOCATING+*(.rela.gnu.linkonce.b.*)} + } +EOF +if [ -n "$COMBRELOC" ]; then +cat <<EOF + .rel.dyn : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC +cat <<EOF + } + .rela.dyn : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC +cat <<EOF + } +EOF +fi +cat <<EOF + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} + + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } =${NOP-0} + + ${DATA_PLT-${BSS_PLT-${PLT}}} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text) + ${RELOCATING+*(.text.*)} + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.gnu.linkonce.t.*)} + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } + .data1 ${RELOCATING-0} : { *(.data1) } + .eh_frame ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__eh_frame_begin = .);} + *(.eh_frame) + LONG (0); + ${RELOCATING+PROVIDE (__eh_frame_end = .);} + } ${RELOCATING+} + .gcc_except_table : { *(.gcc_except_table) } + ${INITIAL_READONLY_SECTIONS} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + ${RODATA} + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${RELOCATING+${OTHER_READONLY_SECTIONS}} + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + .jcr : { KEEP (*(.jcr)) } + ${DATA_PLT+${PLT}} + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + ${RELOCATING+${OTHER_GOT_SECTIONS}} + ${CREATE_SHLIB+${SDATA2}} + ${CREATE_SHLIB+${SBSS2}} + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + *(.sdata) + ${RELOCATING+*(.sdata.*)} + ${RELOCATING+*(.gnu.linkonce.s.*)} + } + ${RELOCATING+${OTHER_SDATA_SECTIONS}} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .sbss ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__sbss_start = .);} + ${RELOCATING+PROVIDE (___sbss_start = .);} + *(.dynsbss) + *(.sbss) + ${RELOCATING+*(.sbss.*)} + ${RELOCATING+*(.gnu.linkonce.sb.*)} + *(.scommon) + ${RELOCATING+PROVIDE (__sbss_end = .);} + ${RELOCATING+PROVIDE (___sbss_end = .);} + } + ${BSS_PLT+${PLT}} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.gnu.linkonce.b.*)} + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + ${RELOCATING+${OTHER_RELOCATING_SECTIONS}} + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/m68kaux.sc b/binutils-2.21/ld/scripttempl/m68kaux.sc new file mode 100644 index 0000000..09032be --- /dev/null +++ b/binutils-2.21/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} + +${RELOCATING+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/binutils-2.21/ld/scripttempl/m68kcoff.sc b/binutils-2.21/ld/scripttempl/m68kcoff.sc new file mode 100644 index 0000000..f268c6f --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/m88kbcs.sc b/binutils-2.21/ld/scripttempl/m88kbcs.sc new file mode 100644 index 0000000..0cd6ab9 --- /dev/null +++ b/binutils-2.21/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}) +${RELOCATING+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/binutils-2.21/ld/scripttempl/mcorepe.sc b/binutils-2.21/ld/scripttempl/mcorepe.sc new file mode 100644 index 0000000..511fdb1 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/mcorepe.sc @@ -0,0 +1,163 @@ +# Linker script for MCore PE. + +if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then + RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +fi + +# We can't easily and portably get an unquoted $ in a shell +# substitution, so we do this instead. +# Sorting of the .foo$* sections is required by the definition of +# grouped sections in PE. +# Sorting of the file names in R_IDATA is required by the +# current implementation of dlltool (this could probably be changed to +# use grouped sections instead). +if test "${RELOCATING}"; then + R_TEXT='*(SORT(.text$*))' + R_DATA='*(SORT(.data$*))' + R_RDATA='*(SORT(.rdata$*))' + R_IDATA=' + SORT(*)(.idata$2) + SORT(*)(.idata$3) + /* These zeroes mark the end of the import list. */ + LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); + SORT(*)(.idata$4) + SORT(*)(.idata$5) + SORT(*)(.idata$6) + SORT(*)(.idata$7)' + R_CRT='*(SORT(.CRT$*))' + R_RSRC='*(SORT(.rsrc$*))' +else + R_TEXT= + R_DATA= + R_RDATA= + R_IDATA= + R_CRT= + R_RSRC= +fi + +if test "$RELOCATING"; then + # Can't use ${RELOCATING+blah "blah" blah} for this, + # because bash 2.x will lose the doublequotes. + cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +EOF +fi + +cat <<EOF +${LIB_SEARCH_DIRS} + +${RELOCATING+ENTRY (_mainCRTStartup)} + +SECTIONS +{ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ *(.init)} + *(.text) + ${R_TEXT} + ${RELOCATING+ *(.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/binutils-2.21/ld/scripttempl/mep.sc b/binutils-2.21/ld/scripttempl/mep.sc new file mode 100644 index 0000000..82a2b25 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/mep.sc @@ -0,0 +1,444 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not +# empty. +# SMALL_DATA_CTOR - .ctors contains small data. +# SMALL_DATA_DTOR - .dtors contains small data. +# 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_RELRO_SECTIONS - other than .data.rel.ro ... +# (e.g. PPC32 .fixup, .got[12]) +# OTHER_BSS_SECTIONS - other than .bss .sbss ... +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_ADDR - the first byte of the text segment, after any +# headers. +# TEXT_BASE_ADDRESS - the first byte of the text segment. +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got. +# OTHER_SDATA_SECTIONS - sections just after .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. +# BSS_PLT - .plt should be in bss segment +# TEXT_DYNAMIC - .dynamic in text segment, not data segment. +# EMBEDDED - whether this is for an embedded system. +# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set +# start address of shared library. +# INPUT_FILES - INPUT command of files to always include +# WRITABLE_RODATA - if set, the .rodata section should be writable +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# STACK_ADDR - start of a .stack section. +# OTHER_END_SYMBOLS - symbols to place right at the end of the script. +# SEPARATE_GOTPLT - if set, .got.plt should be separate output section, +# so that .got can be in the RELRO area. It should be set to +# the number of bytes in the beginning of .got.plt which can be +# in the RELRO area as well. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# .debug_info .gnu.linkonce.wi.foo +# .tdata .gnu.linkonce.td.foo +# .tbss .gnu.linkonce.tb.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${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=. +test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" +test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" +test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT +DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" +DATA_SEGMENT_RELRO_END="" +DATA_SEGMENT_RELRO_GOTPLT_END="" +DATA_SEGMENT_END="" +if test -n "${COMMONPAGESIZE}"; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" + if test -n "${SEPARATE_GOTPLT}"; then + DATA_SEGMENT_RELRO_GOTPLT_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT}, .);" + else + DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (0, .);" + fi +fi +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" +if test -z "$GOT"; then + if test -z "$SEPARATE_GOTPLT"; then + GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }" + else + GOT=".got ${RELOCATING-0} : { *(.got) }" + GOTPLT="${RELOCATING+${DATA_SEGMENT_RELRO_GOTPLT_END}} + .got.plt ${RELOCATING-0} : { *(.got.plt) }" + fi +fi +DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" +RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }" +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" +if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { + ${RELOCATING+PROVIDE (__sbss_start = .);} + ${RELOCATING+PROVIDE (___sbss_start = .);} + ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)} + *(.dynsbss) + *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) + *(.scommon) + ${RELOCATING+PROVIDE (__sbss_end = .);} + ${RELOCATING+PROVIDE (___sbss_end = .);} + }" + SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" + SDATA="/* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : + { + ${RELOCATING+${SDATA_START_SYMBOLS}} + ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)} + *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) + }" + SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }" + REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } + .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" + REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } + .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" + REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } + .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" + REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } + .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" +else + NO_SMALL_DATA=" " +fi +test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + }" +DTOR=".dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + }" +STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + { + ${RELOCATING+_stack = .;} + *(.stack) + }" + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" +fi + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +${RELOCATING+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-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + ${INITIAL_READONLY_SECTIONS} + ${TEXT_DYNAMIC+${DYNAMIC}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } + +EOF +if [ "x$COMBRELOC" = x ]; then + COMBRELOCCAT=cat +else + COMBRELOCCAT="cat > $COMBRELOC" +fi +eval $COMBRELOCCAT <<EOF + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } + .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } + ${OTHER_READONLY_RELOC_SECTIONS} + .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+*}) } + .rela.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+*}) } + .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } + .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } + .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } + .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } + .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } + .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + ${OTHER_GOT_RELOC_SECTIONS} + ${REL_SDATA} + ${REL_SBSS} + ${REL_SDATA2} + ${REL_SBSS2} + .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } +EOF +if [ -n "$COMBRELOC" ]; then +cat <<EOF + .rel.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC +cat <<EOF + } + .rela.dyn ${RELOCATING-0} : + { +EOF +sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC +cat <<EOF + } +EOF +fi +cat <<EOF + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + ${OTHER_PLT_RELOC_SECTIONS} + + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } =${NOP-0} + + ${DATA_PLT-${BSS_PLT-${PLT}}} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } =${NOP-0} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } =${NOP-0} + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + ${WRITABLE_RODATA-${RODATA}} + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${CREATE_SHLIB-${SDATA2}} + ${CREATE_SHLIB-${SBSS2}} + ${OTHER_READONLY_SECTIONS} + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } + + /* 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-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} + + /* Exception handling */ + .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } + + /* Thread Local Storage sections */ + .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } + .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } + + .preinit_array ${RELOCATING-0} : { KEEP (*(.preinit_array)) } + .init_array ${RELOCATING-0} : { KEEP (*(.init_array)) } + .fini_array ${RELOCATING-0} : { KEEP (*(.fini_array)) } + + ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} + ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} + .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } + + ${RELOCATING+${DATARELRO}} + ${OTHER_RELRO_SECTIONS} + ${TEXT_DYNAMIC-${DYNAMIC}} + ${NO_SMALL_DATA+${RELRO_NOW+${GOT}}} + ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} + ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT+${GOTPLT}}}} + ${RELOCATING+${DATA_SEGMENT_RELRO_END}} + ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} + + ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${WRITABLE_RODATA+${RODATA}} + ${OTHER_READWRITE_SECTIONS} + ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} + ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} + ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}} + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + ${NO_SMALL_DATA-${GOT}} + ${OTHER_GOT_SECTIONS} + ${SDATA} + ${OTHER_SDATA_SECTIONS} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + ${SBSS} + ${BSS_PLT+${PLT}} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } + ${OTHER_BSS_SECTIONS} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+_end = .;} + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+PROVIDE (end = .);} + ${RELOCATING+${DATA_SEGMENT_END}} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + ${STACK_ADDR+${STACK}} + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${RELOCATING+${DISCARDED}} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/mips.sc b/binutils-2.21/ld/scripttempl/mips.sc new file mode 100644 index 0000000..f53558a --- /dev/null +++ b/binutils-2.21/ld/scripttempl/mips.sc @@ -0,0 +1,69 @@ +# 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} + +${RELOCATING+ENTRY (${ENTRY})} + +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : { + ${RELOCATING+ _ftext = . }; + *(.init) + ${RELOCATING+ eprol = .}; + *(.text) + *(.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/binutils-2.21/ld/scripttempl/mipsbsd.sc b/binutils-2.21/ld/scripttempl/mipsbsd.sc new file mode 100644 index 0000000..b222b33 --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/mmo.sc b/binutils-2.21/ld/scripttempl/mmo.sc new file mode 100644 index 0000000..bdb345e --- /dev/null +++ b/binutils-2.21/ld/scripttempl/mmo.sc @@ -0,0 +1,137 @@ +# MMO is not a relocateable format, and we don't want to require an +# explicit (e.g.) "-m elf64mmix" when -r is used. +test -z $RELOCATEABLE_OUTPUT_FORMAT && RELOCATEABLE_OUTPUT_FORMAT=$OUTPUT_FORMAT +test -z ${RELOCATING+0} && OUTPUT_FORMAT=$RELOCATEABLE_OUTPUT_FORMAT +cat <<EOF +OUTPUT_FORMAT("$OUTPUT_FORMAT") +OUTPUT_ARCH(mmix) +${RELOCATING+ENTRY(Main)} +SECTIONS +{ + .text ${RELOCATING+ ${TEXT_START_ADDR}}: + { + *(.text) + ${RELOCATING+*(.text.*)} + ${RELOCATING+*(.gnu.linkonce.t*)} + ${RELOCATING+*(.rodata)} + ${RELOCATING+*(.rodata.*)} + ${RELOCATING+*(.gnu.linkonce.r*)} + + /* FIXME: Move .init, .fini, .ctors and .dtors to their own sections. */ + ${RELOCATING+ PROVIDE (_init_start = .);} + ${RELOCATING+ PROVIDE (_init = .);} + ${RELOCATING+ KEEP (*(.init))} + ${RELOCATING+ PROVIDE (_init_end = .);} + + ${RELOCATING+ PROVIDE (_fini_start = .);} + ${RELOCATING+ PROVIDE (_fini = .);} + ${RELOCATING+ KEEP (*(.fini))} + ${RELOCATING+ PROVIDE (_fini_end = .);} + + /* FIXME: Align ctors, dtors, ehframe. */ + ${RELOCATING+ PROVIDE (_ctors_start = .);} + ${RELOCATING+ PROVIDE (__ctors_start = .);} + ${RELOCATING+ PROVIDE (_ctors = .);} + ${RELOCATING+ PROVIDE (__ctors = .);} + ${RELOCATING+ KEEP (*crtbegin.o(.ctors))} + ${RELOCATING+ KEEP (*crtbegin?.o(.ctors))} + ${RELOCATING+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors))} + ${RELOCATING+ KEEP (*(SORT(.ctors.*)))} + ${RELOCATING+ KEEP (*(.ctors))} + ${RELOCATING+ PROVIDE (_ctors_end = .);} + ${RELOCATING+ PROVIDE (__ctors_end = .);} + + ${RELOCATING+ PROVIDE (_dtors_start = .);} + ${RELOCATING+ PROVIDE (__dtors_start = .);} + ${RELOCATING+ PROVIDE (_dtors = .);} + ${RELOCATING+ PROVIDE (__dtors = .);} + ${RELOCATING+ KEEP (*crtbegin.o(.dtors))} + ${RELOCATING+ KEEP (*crtbegin?.o(.dtors))} + ${RELOCATING+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors))} + ${RELOCATING+ KEEP (*(SORT(.dtors.*)))} + ${RELOCATING+ KEEP (*(.dtors))} + ${RELOCATING+ PROVIDE (_dtors_end = .);} + ${RELOCATING+ PROVIDE (__dtors_end = .);} + + ${RELOCATING+KEEP (*(.jcr))} + ${RELOCATING+KEEP (*(.eh_frame))} + ${RELOCATING+*(.gcc_except_table)} + + ${RELOCATING+ PROVIDE(etext = .);} + ${RELOCATING+ PROVIDE(_etext = .);} + ${RELOCATING+ PROVIDE(__etext = .);} + ${RELOCATING+Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : ADDR (.text));} + } + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + .debug_ranges 0 : { *(.debug_ranges .zdebug_ranges) } + + .data ${RELOCATING+ ${DATA_ADDR}}: + { + ${RELOCATING+ PROVIDE(__Sdata = .);} + + *(.data); + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d*)} + + ${RELOCATING+ PROVIDE(__Edata = .);} + + /* Deprecated, use __Edata. */ + ${RELOCATING+ PROVIDE(edata = .);} + ${RELOCATING+ PROVIDE(_edata = .);} + ${RELOCATING+ PROVIDE(__edata = .);} + } + + /* At the moment, although perhaps we should, we can't map sections + without contents to sections *with* contents due to FIXME: a BFD bug. + Anyway, the mmo back-end ignores sections without contents when + writing out sections, so this works fine. */ + .bss : + { + ${RELOCATING+ PROVIDE(__Sbss = .);} + ${RELOCATING+ PROVIDE(__bss_start = .);} + ${RELOCATING+ *(.sbss);} + ${RELOCATING+ *(.bss);} + ${RELOCATING+*(.bss.*)} + ${RELOCATING+ *(COMMON);} + ${RELOCATING+ PROVIDE(__Ebss = .);} + } + + /* Deprecated, use __Ebss or __Eall as appropriate. */ + ${RELOCATING+ PROVIDE(end = .);} + ${RELOCATING+ PROVIDE(_end = .);} + ${RELOCATING+ PROVIDE(__end = .);} + ${RELOCATING+ PROVIDE(__Eall = .);} + + .MMIX.reg_contents : + { + /* Note that this section always has a fixed VMA - that of its + first register * 8. */ + *(.MMIX.reg_contents.linker_allocated); + *(.MMIX.reg_contents); + } + + /* By default, put the high end of the stack where the register stack + begins. They grow in opposite directions. */ + PROVIDE (__Stack_start = 0x6000000000000000); + + /* Unfortunately, stabs are not mappable from ELF to MMO. + It can probably be fixed with some amount of work. */ + /DISCARD/ : + { ${RELOCATING+ *(.gnu.warning.*);} } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/moxie.sc b/binutils-2.21/ld/scripttempl/moxie.sc new file mode 100644 index 0000000..f7d788f --- /dev/null +++ b/binutils-2.21/ld/scripttempl/moxie.sc @@ -0,0 +1,52 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +SECTIONS +{ + .text : + { + *(.text) + .init : { KEEP (*(.init)) } =0 + .fini : { KEEP (*(.fini)) } =0 + *(.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/binutils-2.21/ld/scripttempl/nw.sc b/binutils-2.21/ld/scripttempl/nw.sc new file mode 100644 index 0000000..3fb9bce --- /dev/null +++ b/binutils-2.21/ld/scripttempl/nw.sc @@ -0,0 +1,130 @@ +# +# Unusual variables checked by this code: +# NOP - four byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_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) } + ${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) } + ${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) } + + ${OTHER_SECTIONS} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/or32.sc b/binutils-2.21/ld/scripttempl/or32.sc new file mode 100644 index 0000000..2825b1e --- /dev/null +++ b/binutils-2.21/ld/scripttempl/or32.sc @@ -0,0 +1,37 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +SECTIONS +{ + .text : { + *(.text) + ${RELOCATING+ __etext = .}; + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + *(.lit) + *(.shdata) + } + .shbss SIZEOF(.text) + ADDR(.text) : { + *(.shbss) + } + .data : { + *(.data) + ${RELOCATING+ __edata = .}; + } + .bss SIZEOF(.data) + ADDR(.data) : + { + *(.bss) + *(COMMON) + ${RELOCATING+ __end = ALIGN(0x8)}; + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/pe.sc b/binutils-2.21/ld/scripttempl/pe.sc new file mode 100644 index 0000000..7d52cc5 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/pe.sc @@ -0,0 +1,304 @@ +# 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$*))' + if test "x$LD_FLAG" = "xauto_import" ; then + R_DATA='*(SORT(.data$*)) + *(.rdata) + *(SORT(.rdata$*))' + R_RDATA='' + else + R_DATA='*(SORT(.data$*))' + R_RDATA='*(.rdata) + *(SORT(.rdata$*))' + fi + R_IDATA234=' + 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)' + R_IDATA5='SORT(*)(.idata$5)' + R_IDATA67=' + SORT(*)(.idata$6) + SORT(*)(.idata$7)' + R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */' + R_CRT_XI='*(SORT(.CRT$XI*)) /* C++ initialization */' + R_CRT_XL='*(SORT(.CRT$XL*)) /* TLS callbacks */' + R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */' + R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */' + R_TLS=' + *(.tls) + *(.tls$) + *(SORT(.tls$*))' + R_RSRC='*(SORT(.rsrc$*))' +else + R_TEXT= + R_DATA= + R_RDATA='*(.rdata)' + R_IDATA234= + R_IDATA5= + R_IDATA67= + R_CRT= + R_RSRC= +fi + +cat <<EOF +${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} +${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} +${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})} + +${LIB_SEARCH_DIRS} + +SECTIONS +{ + ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is} + ${RELOCATING+ lower than the target page size. */} + ${RELOCATING+. = SIZEOF_HEADERS;} + ${RELOCATING+. = ALIGN(__section_alignment__);} + .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} : + { + ${RELOCATING+ *(.init)} + *(.text) + ${R_TEXT} + ${RELOCATING+ *(.text.*)} + *(.glue_7t) + *(.glue_7) + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); } + ${RELOCATING+ *(.fini)} + /* ??? Why is .gcc_exc here? */ + ${RELOCATING+ *(.gcc_exc)} + ${RELOCATING+PROVIDE (etext = .);} + ${RELOCATING+ *(.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} + *(.jcr) + ${RELOCATING+__data_end__ = . ;} + ${RELOCATING+*(.data_cygwin_nocopy)} + } + + .rdata ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${R_RDATA} + ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;} + ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;} + *(.rdata_runtime_pseudo_reloc) + ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + } + + .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.eh_frame) + } + + .pdata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.pdata) + } + + .bss ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__bss_start__ = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+__bss_end__ = . ;} + } + + .edata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.edata) + } + + /DISCARD/ : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + ${RELOCATING+ *(.note.GNU-stack)} + ${RELOCATING+ *(.gnu.lto_*)} + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${R_IDATA234} + ${RELOCATING+__IAT_start__ = .;} + ${R_IDATA5} + ${RELOCATING+__IAT_end__ = .;} + ${R_IDATA67} + } + .CRT ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+___crt_xc_start__ = . ;} + ${R_CRT_XC} + ${RELOCATING+___crt_xc_end__ = . ;} + ${RELOCATING+___crt_xi_start__ = . ;} + ${R_CRT_XI} + ${RELOCATING+___crt_xi_end__ = . ;} + ${RELOCATING+___crt_xl_start__ = . ;} + ${R_CRT_XL} + /* ___crt_xl_end__ is defined in the TLS Directory support code */ + ${RELOCATING+___crt_xp_start__ = . ;} + ${R_CRT_XP} + ${RELOCATING+___crt_xp_end__ = . ;} + ${RELOCATING+___crt_xt_start__ = . ;} + ${R_CRT_XT} + ${RELOCATING+___crt_xt_end__ = . ;} + } + + .tls ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+___tls_start__ = . ;} + ${R_TLS} + ${RELOCATING+___tls_end__ = . ;} + } + + .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* end is deprecated, don't use it */ + ${RELOCATING+PROVIDE (end = .);} + ${RELOCATING+PROVIDE ( _end = .);} + ${RELOCATING+ __end__ = .;} + } + + .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rsrc) + ${R_RSRC} + } + + .reloc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.reloc) + } + + .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. Unlike other targets that fake this by putting the + section VMA at 0, the PE format will not allow it. */ + + /* DWARF 1.1 and DWARF 2. */ + .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_aranges) + } + + .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_pubnames) + } + + .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_pubtypes) + } + + /* DWARF 2. */ + .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_info) *(.gnu.linkonce.wi.*) + } + + .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_abbrev) + } + + .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_line) + } + + .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_frame) + } + + .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_str) + } + + .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_loc) + } + + .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_macinfo) + } + + /* SGI/MIPS DWARF 2 extensions. */ + .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_weaknames) + } + + .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_funcnames) + } + + .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_typenames) + } + + .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_varnames) + } + + /* DWARF 3. */ + .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_ranges) + } + + /* DWARF 4. */ + .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_types) *(.gnu.linkonce.wt.*) + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/pep.sc b/binutils-2.21/ld/scripttempl/pep.sc new file mode 100644 index 0000000..8fa5f05 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/pep.sc @@ -0,0 +1,310 @@ +# 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$*))' + if test "x$LD_FLAG" = "xauto_import" ; then + R_DATA='*(SORT(.data$*)) + *(.rdata) + *(SORT(.rdata$*))' + R_RDATA='' + else + R_DATA='*(SORT(.data$*))' + R_RDATA='*(.rdata) + *(SORT(.rdata$*))' + fi + R_IDATA234=' + 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)' + R_IDATA5='SORT(*)(.idata$5)' + R_IDATA67=' + SORT(*)(.idata$6) + SORT(*)(.idata$7)' + R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */' + R_CRT_XI='*(SORT(.CRT$XI*)) /* C++ initialization */' + R_CRT_XL='*(SORT(.CRT$XL*)) /* TLS callbacks */' + R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */' + R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */' + R_TLS=' + *(.tls) + *(.tls$) + *(SORT(.tls$*))' + R_RSRC='*(SORT(.rsrc$*))' +else + R_TEXT= + R_DATA= + R_RDATA='*(.rdata)' + R_IDATA234= + R_IDATA5= + R_IDATA67= + R_CRT= + R_RSRC= +fi + +cat <<EOF +${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} +${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} +${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})} + +${LIB_SEARCH_DIRS} + +SECTIONS +{ + ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is} + ${RELOCATING+ lower than the target page size. */} + ${RELOCATING+. = SIZEOF_HEADERS;} + ${RELOCATING+. = ALIGN(__section_alignment__);} + .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} : + { + ${RELOCATING+ *(.init)} + *(.text) + ${R_TEXT} + ${RELOCATING+ *(.text.*)} + *(.glue_7t) + *(.glue_7) + ${CONSTRUCTING+. = ALIGN(8);} + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); LONG (0); } + ${RELOCATING+ *(.fini)} + /* ??? Why is .gcc_exc here? */ + ${RELOCATING+ *(.gcc_exc)} + ${RELOCATING+PROVIDE (etext = .);} + ${RELOCATING+ *(.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} + *(.jcr) + ${RELOCATING+__data_end__ = . ;} + ${RELOCATING+*(.data_cygwin_nocopy)} + } + + .rdata ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${R_RDATA} + ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;} + ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;} + *(.rdata_runtime_pseudo_reloc) + ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + } + + .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.eh_frame) + } + + .pdata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.pdata*) + } + + .xdata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.xdata*) + } + + .bss ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+__bss_start__ = . ;} + *(.bss) + *(COMMON) + ${RELOCATING+__bss_end__ = . ;} + } + + .edata ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.edata) + } + + /DISCARD/ : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + ${RELOCATING+ *(.note.GNU-stack)} + ${RELOCATING+ *(.gnu.lto_*)} + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pep.em:sort_sections. */ + ${R_IDATA234} + ${RELOCATING+__IAT_start__ = .;} + ${R_IDATA5} + ${RELOCATING+__IAT_end__ = .;} + ${R_IDATA67} + } + .CRT ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+___crt_xc_start__ = . ;} + ${R_CRT_XC} + ${RELOCATING+___crt_xc_end__ = . ;} + ${RELOCATING+___crt_xi_start__ = . ;} + ${R_CRT_XI} + ${RELOCATING+___crt_xi_end__ = . ;} + ${RELOCATING+___crt_xl_start__ = . ;} + ${R_CRT_XL} + /* ___crt_xl_end__ is defined in the TLS Directory support code */ + ${RELOCATING+___crt_xp_start__ = . ;} + ${R_CRT_XP} + ${RELOCATING+___crt_xp_end__ = . ;} + ${RELOCATING+___crt_xt_start__ = . ;} + ${R_CRT_XT} + ${RELOCATING+___crt_xt_end__ = . ;} + } + + .tls ${RELOCATING+BLOCK(__section_alignment__)} : + { + ${RELOCATING+___tls_start__ = . ;} + ${R_TLS} + ${RELOCATING+___tls_end__ = . ;} + } + + .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* end is deprecated, don't use it */ + ${RELOCATING+PROVIDE (end = .);} + ${RELOCATING+PROVIDE ( _end = .);} + ${RELOCATING+ __end__ = .;} + } + + .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.rsrc) + ${R_RSRC} + } + + .reloc ${RELOCATING+BLOCK(__section_alignment__)} : + { + *(.reloc) + } + + .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. Unlike other targets that fake this by putting the + section VMA at 0, the PE format will not allow it. */ + + /* DWARF 1.1 and DWARF 2. */ + .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_aranges) + } + + .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_pubnames) + } + + .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_pubtypes) + } + + /* DWARF 2. */ + .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_info) *(.gnu.linkonce.wi.*) + } + + .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_abbrev) + } + + .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_line) + } + + .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_frame) + } + + .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_str) + } + + .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_loc) + } + + .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_macinfo) + } + + /* SGI/MIPS DWARF 2 extensions. */ + .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_weaknames) + } + + .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_funcnames) + } + + .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_typenames) + } + + .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_varnames) + } + + /* DWARF 3. */ + .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_ranges) + } + + /* DWARF 4. */ + .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : + { + *(.debug_types) *(.gnu.linkonce.wt.*) + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/pj.sc b/binutils-2.21/ld/scripttempl/pj.sc new file mode 100644 index 0000000..93981a5 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/pj.sc @@ -0,0 +1,55 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + ram : o = 0x1000, l = 512M +} + +SECTIONS +{ + .text : + { + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + ${CONSTRUCTING+${TORS}} + .data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + .bss : + { + ${RELOCATING+ _bss_start = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > ram} + .stack ${RELOCATING+ 0x30000 } : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > ram} + .stab 0 ${RELOCATING+(NOLOAD)} : + { + *(.stab) + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + *(.stabstr) + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/ppcpe.sc b/binutils-2.21/ld/scripttempl/ppcpe.sc new file mode 100644 index 0000000..182fbe5 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/ppcpe.sc @@ -0,0 +1,199 @@ +# 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. +*/ + +${RELOCATING+ENTRY (mainCRTStartup)} + +SECTIONS +{ + + /* text - the usual meaning */ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ *(.init);} + *(.text) + ${RELOCATING+ *(.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/binutils-2.21/ld/scripttempl/psos.sc b/binutils-2.21/ld/scripttempl/psos.sc new file mode 100644 index 0000000..ab8c6c7 --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/riscix.sc b/binutils-2.21/ld/scripttempl/riscix.sc new file mode 100644 index 0000000..c801a0c --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/sh.sc b/binutils-2.21/ld/scripttempl/sh.sc new file mode 100644 index 0000000..e7f049f --- /dev/null +++ b/binutils-2.21/ld/scripttempl/sh.sc @@ -0,0 +1,64 @@ +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+*(.gcc_exc*)} + ${RELOCATING+___EH_FRAME_BEGIN__ = . ;} + ${RELOCATING+*(.eh_fram*)} + ${RELOCATING+___EH_FRAME_END__ = . ;} + ${RELOCATING+LONG(0);} + ${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/binutils-2.21/ld/scripttempl/sparccoff.sc b/binutils-2.21/ld/scripttempl/sparccoff.sc new file mode 100644 index 0000000..309aa83 --- /dev/null +++ b/binutils-2.21/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} + +${RELOCATING+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/binutils-2.21/ld/scripttempl/st2000.sc b/binutils-2.21/ld/scripttempl/st2000.sc new file mode 100644 index 0000000..7ee132a --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/tic30aout.sc b/binutils-2.21/ld/scripttempl/tic30aout.sc new file mode 100644 index 0000000..28baed3 --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/tic30coff.sc b/binutils-2.21/ld/scripttempl/tic30coff.sc new file mode 100644 index 0000000..df2d4f7 --- /dev/null +++ b/binutils-2.21/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/binutils-2.21/ld/scripttempl/tic4xcoff.sc b/binutils-2.21/ld/scripttempl/tic4xcoff.sc new file mode 100644 index 0000000..83245ca --- /dev/null +++ b/binutils-2.21/ld/scripttempl/tic4xcoff.sc @@ -0,0 +1,151 @@ +# In microcomputer (MC) mode, the vectors are mapped into the on-chip ROM, +# otherwise in microprocessor (MP) mode the vectors are mapped to address 0 +# on the external bus. In MC mode, the on-chip ROM contains a bootloader program +# that loads the internal RAM from the serial port or external ROM. +# +# Common configurations: +# 1. MC mode, no external memory (serial boot). +# 2. MC mode, external RAM (serial boot). +# 3. MC mode, external ROM. +# 4. MC mode, external ROM, external RAM. +# 5. MP mode, external ROM. +# 6. MP mode, external ROM, external RAM. +# 7. MP mode, external RAM (dual-port with hosting CPU or external debugger). +# +# Config TEXT DATA/BSS +# 1. INT_RAM INT_RAM (mcmode,onchip) +# 2. EXT_RAM EXT_RAM (mcmode,extram) +# 3. INT_RAM INT_RAM (mcmode,onchip) +# 4. EXT_RAM EXT_RAM (mcmode,extram) +# 5. EXT_ROM INT_RAM (mpmode,onchip,extrom) +# 6. EXT_ROM EXT_RAM (mpmode,extram,extrom) +# 7. EXT_RAM EXT_RAM (mpmode,extram) +# +# In MC mode, TEXT and DATA are copied into RAM by the bootloader. +# +# In MP mode with external ROM, DATA needs to be copied into RAM at boot time. +# +# If there is external RAM it is better to use that and reserve the internal RAM +# for data buffers. However, the address of the external RAM needs to be specified. +# +# This emulation assumes config 7. + +case $OUTPUT_ARCH in + tic3x) OUTPUT_ARCHNAME="TMS320C3x" ;; + tic4x) OUTPUT_ARCHNAME="TMS320C4x" ;; +esac + +case $ONCHIP in + yes) RAM=RAM; + STACK_SIZE_DEFAULT=128; + HEAP_SIZE_DEFAULT=0; + ;; + *) RAM=EXT0; + STACK_SIZE_DEFAULT=0x1000; + HEAP_SIZE_DEFAULT=0x4000; + ;; +esac + +TEXT_MEMORY=$RAM; +DATA_MEMORY=$RAM; + + +MEMORY_DEF=" +/* C30 memory space. */ +MEMORY +{ + EXT0 : org = 0x0000000, len = 0x800000 /* External address bus. */ + XBUS : org = 0x0800000, len = 0x002000 /* Expansion bus. */ + IOBUS : org = 0x0804000, len = 0x002000 /* I/O BUS. */ + RAM0 : org = 0x0809800, len = 0x000400 /* Internal RAM block 0. */ + RAM1 : org = 0x0809a00, len = 0x000400 /* Internal RAM block 1. */ + RAM : org = 0x0809800, len = 0x000800 /* Internal RAM. */ + EXT1 : org = 0x080a000, len = 0x7f6000 /* External address bus. */ +} +" + +test -z "$ENTRY" && ENTRY=_start + +cat <<EOF +${RELOCATING+/* Linker script for $OUTPUT_ARCHNAME executable. */} +${RELOCATING-/* Linker script for $OUTPUT_ARCHNAME object file (ld -r). */} + +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH("${OUTPUT_ARCH}") +${LIB_SEARCH_DIRS} +${RELOCATING+ENTRY (${ENTRY})} + +${RELOCATING+ __HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : ${HEAP_SIZE_DEFAULT};} +${RELOCATING+ __STACK_SIZE = DEFINED(__STACK_SIZE) ? __STACK_SIZE : ${STACK_SIZE_DEFAULT};} + +${RELOCATING+${MEMORY_DEF}} + +/* In the small memory model the .data and .bss sections must be contiguous + when loaded and fit within the same page. The DP register is loaded + with the page address. */ + +SECTIONS +{ + /* Reset, interrupt, and trap vectors. */ + .vectors ${RELOCATING+ 0} : { + *(.vectors) + } ${RELOCATING+ > ${TEXT_MEMORY}} + /* Constants. */ + .const : { + *(.const) + } ${RELOCATING+ > ${TEXT_MEMORY}} + /* Program code. */ + .text : { + ${RELOCATING+ __text = .;} + ${RELOCATING+ *(.init)} + *(.text) + ${CONSTRUCTING+ ___CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG(___CTOR_END__ - ___CTOR_LIST__ - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0);} + ${CONSTRUCTING+ ___CTOR_END__ = .;} + ${CONSTRUCTING+ ___DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG(___DTOR_END__ - ___DTOR_LIST__ - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ ___DTOR_END__ = .;} + ${RELOCATING+ *(.fini)} + ${RELOCATING+ __etext = .;} + } ${RELOCATING+ > ${TEXT_MEMORY}} + /* Global initialised variables. */ + .data : + { + ${RELOCATING+ __data = .;} + *(.data) + ${RELOCATING+ __edata = .;} + } ${RELOCATING+ > ${DATA_MEMORY}} + /* Global uninitialised variables. */ + .bss : { + ${RELOCATING+ __bss = .;} + *(.bss) + *(COMMON) + ${RELOCATING+ __end = .;} + } ${RELOCATING+ > ${DATA_MEMORY}} + /* Heap. */ + .heap : + { + ${RELOCATING+ __heap = .;} + ${RELOCATING+ . += __HEAP_SIZE}; + } ${RELOCATING+ > ${DATA_MEMORY}} + /* Stack (grows upward). */ + .stack : + { + ${RELOCATING+ __stack = .;} + *(.stack) + ${RELOCATING+ . = . + __STACK_SIZE}; + } ${RELOCATING+ > ${DATA_MEMORY}} + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/tic54xcoff.sc b/binutils-2.21/ld/scripttempl/tic54xcoff.sc new file mode 100644 index 0000000..f17b480 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/tic54xcoff.sc @@ -0,0 +1,52 @@ +# default linker script for c54x, TI COFF(1). +# patterned after description in TI Assembler Tools PDF, SPRU102C, 7-53 +test -z "$ENTRY" && ENTRY=_c_int00 + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH("${OUTPUT_ARCH}") + +MEMORY +{ + /*PAGE 0 : */ prog (RXI) : ORIGIN = 0x00000080, LENGTH = 0xFF00 + /*PAGE 1 : */ data (W) : ORIGIN = 0x01000080, LENGTH = 0xFF80 +} + +${RELOCATING+ENTRY (${ENTRY})} + +SECTIONS +{ + .text : + { + ___text__ = .; + *(.text) + etext = .; + ___etext__ = .; + } > prog + .data : + { + ___data__ = .; + __data = .; + *(.data) + __edata = .; + edata = .; + ___edata__ = .; + } > prog + /* all other initialized sections should be allocated here */ + .cinit : + { + *(.cinit) + } > prog + .bss : + { + ___bss__ = .; + __bss = .; + *(.bss) + *(COMMON) + __ebss = .; + end = .; + ___end__ = .; + } > data + /* all other uninitialized sections should be allocated here */ +} +EOF diff --git a/binutils-2.21/ld/scripttempl/tic80coff.sc b/binutils-2.21/ld/scripttempl/tic80coff.sc new file mode 100644 index 0000000..f28e904 --- /dev/null +++ b/binutils-2.21/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} + +${RELOCATING+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/binutils-2.21/ld/scripttempl/v850.sc b/binutils-2.21/ld/scripttempl/v850.sc new file mode 100644 index 0000000..40b627c --- /dev/null +++ b/binutils-2.21/ld/scripttempl/v850.sc @@ -0,0 +1,231 @@ +cat << EOF +OUTPUT_FORMAT("elf32-v850", "elf32-v850", + "elf32-v850") +OUTPUT_ARCH(v850) +${RELOCATING+ENTRY(_start)} +SEARCH_DIR(.); +EXTERN(__ctbp __ep __gp); +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.gcc_except_table : { *(.rel.gcc_except_table) } + .rela.gcc_except_table : { *(.rela.gcc_except_table) } + .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 : + { + ${CONSTRUCTING+___ctors = .;} + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*crtend(.ctors)) + ${CONSTRUCTING+___ctors_end = .;} + } + .dtors : + { + ${CONSTRUCTING+___dtors = .;} + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*crtend.o(.dtors)) + ${CONSTRUCTING+___dtors_end = .;} + } + .jcr : + { + KEEP (*(.jcr)) + } + + .gcc_except_table : { *(.gcc_except_table) } + + .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 .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions. */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + /* User stack. */ + .stack 0x200000 : + { + ${RELOCATING+__stack = .;} + *(.stack) + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/vanilla.sc b/binutils-2.21/ld/scripttempl/vanilla.sc new file mode 100644 index 0000000..1798480 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/vanilla.sc @@ -0,0 +1 @@ +# Nothing to do. diff --git a/binutils-2.21/ld/scripttempl/w65.sc b/binutils-2.21/ld/scripttempl/w65.sc new file mode 100644 index 0000000..f92d999 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/w65.sc @@ -0,0 +1,65 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + ram : o = 0x1000, l = 512k +} + +SECTIONS +{ +.text : + { + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + + ${CONSTRUCTING+${TORS}} + +.data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + +.bss : + { + ${RELOCATING+ _bss_start = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ >ram} + +.stack ${RELOCATING+ 0x30000 } : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > ram} + +.stab . (NOLOAD) : + { + [ .stab ] + } + +.stabstr . (NOLOAD) : + { + [ .stabstr ] + } +} +EOF + + + + diff --git a/binutils-2.21/ld/scripttempl/xstormy16.sc b/binutils-2.21/ld/scripttempl/xstormy16.sc new file mode 100644 index 0000000..68a8379 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/xstormy16.sc @@ -0,0 +1,241 @@ +# +# Unusual variables checked by this code: +# NOP - two byte opcode for no-op (defaults to 0) +# INITIAL_READONLY_SECTIONS - at start of text segment +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_TEXT_SECTIONS - these get put in .text when relocating +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_GOT_SYMBOLS - symbols defined just before .got. +# OTHER_GOT_SECTIONS - sections just after .got and .sdata. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# INPUT_FILES - INPUT command of files to always include +# INIT_START, INIT_END - statements just before and just after +# combination of .init sections. +# FINI_START, FINI_END - statements just before and just after +# combination of .fini sections. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# Many sections come in three flavours. There is the 'real' section, +# like ".data". Then there are the per-procedure or per-variable +# sections, generated by -ffunction-sections and -fdata-sections in GCC, +# and useful for --gc-sections, which for a variable "foo" might be +# ".data.foo". Then there are the linkonce sections, for which the linker +# eliminates duplicates, which are named like ".gnu.linkonce.d.foo". +# The exact correspondences are: +# +# Section Linkonce section +# .text .gnu.linkonce.t.foo +# .rodata .gnu.linkonce.r.foo +# .data .gnu.linkonce.d.foo +# .bss .gnu.linkonce.b.foo +# .sdata .gnu.linkonce.s.foo +# .sbss .gnu.linkonce.sb.foo +# .sdata2 .gnu.linkonce.s2.foo +# .sbss2 .gnu.linkonce.sb2.foo +# +# Each of these can also have corresponding .rel.* and .rela.* sections. + +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test -z "${ELFSIZE}" && ELFSIZE=32 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" +CTOR=".ctors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${CTOR_START}} + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + + /* We don't want to include the .ctor section 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 *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} + } > ROM" + +DTOR=" .dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} + } > ROM" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +${RELOCATING+ENTRY(${ENTRY})} + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+${INPUT_FILES}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} + +/* There are two memory regions we care about, one from 0 through 0x7F00 + that is RAM and one from 0x8000 up which is ROM. */ +MEMORY +{ + RAM (w) : ORIGIN = 0, LENGTH = 0x7F00 + ROM (!w) : ORIGIN = 0x8000, LENGTH = 0xFF8000 +} + +SECTIONS +{ + .data ${RELOCATING-0} : + { + ${RELOCATING+__rdata = .;} + ${RELOCATING+__data = .;} + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d.*)} + ${CONSTRUCTING+SORT(CONSTRUCTORS)} + } > RAM + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + ${RELOCATING+${OTHER_GOT_SECTIONS}} + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + ${RELOCATING+*(.bss.*)} + ${RELOCATING+*(.gnu.linkonce.b.*)} + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + } > RAM + ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} + ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+${OTHER_END_SYMBOLS}} + ${RELOCATING+_end = .;} + ${RELOCATING+__stack = .;} + ${RELOCATING+PROVIDE (end = .);} + + /* Read-only sections in ROM. */ + .int_vec ${RELOCATING-0} : { *(.int_vec) } ${RELOCATING+> ROM} + + .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } ${RELOCATING+> ROM} + ${RELOCATING+${CTOR}} + ${RELOCATING+${DTOR}} + .jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ROM} + .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ROM} + .gcc_except_table : { *(.gcc_except_table) *(.gcc_except_table.*) } ${RELOCATING+> ROM} + .plt : { *(.plt) } ${RELOCATING+> ROM} + + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text) + ${RELOCATING+*(.text.*)} + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + ${RELOCATING+*(.gnu.linkonce.t.*)} + ${RELOCATING+${OTHER_TEXT_SECTIONS}} + } ${RELOCATING+> ROM =${NOP-0}} + .init ${RELOCATING-0} : + { + ${RELOCATING+${INIT_START}} + KEEP (*(.init)) + ${RELOCATING+${INIT_END}} + } ${RELOCATING+> ROM =${NOP-0}} + .fini ${RELOCATING-0} : + { + ${RELOCATING+${FINI_START}} + KEEP (*(.fini)) + ${RELOCATING+${FINI_END}} + } ${RELOCATING+> ROM =${NOP-0}} + ${RELOCATING+PROVIDE (__etext = .);} + ${RELOCATING+PROVIDE (_etext = .);} + ${RELOCATING+PROVIDE (etext = .);} + ${RELOCATING+${OTHER_READONLY_SECTIONS}} + + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo .zdebug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames .zdebug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges .zdebug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*} .zdebug_info) } + .debug_abbrev 0 : { *(.debug_abbrev .zdebug_abbrev) } + .debug_line 0 : { *(.debug_line .zdebug_line) } + .debug_frame 0 : { *(.debug_frame .zdebug_frame) } + .debug_str 0 : { *(.debug_str .zdebug_str) } + .debug_loc 0 : { *(.debug_loc .zdebug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo .zdebug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) } + .debug_varnames 0 : { *(.debug_varnames .zdebug_varnames) } + + ${RELOCATING+${OTHER_RELOCATING_SECTIONS}} + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF diff --git a/binutils-2.21/ld/scripttempl/z80.sc b/binutils-2.21/ld/scripttempl/z80.sc new file mode 100644 index 0000000..8c004da --- /dev/null +++ b/binutils-2.21/ld/scripttempl/z80.sc @@ -0,0 +1,35 @@ +if [ x${LD_FLAG} = x ] +then +cat << EOF +/* Create a cp/m executable; load and execute at 0x100. */ +OUTPUT_FORMAT("binary") +. = 0x100; +__Ltext = .; +ENTRY (__Ltext) +EOF +else + echo "OUTPUT_FORMAT(\"${OUTPUT_FORMAT}\")" +fi +cat <<EOF +OUTPUT_ARCH("${OUTPUT_ARCH}") +SECTIONS +{ +.text : { + *(.text) + *(text) + ${RELOCATING+ __Htext = .;} + } +.data : { + ${RELOCATING+ __Ldata = .;} + *(.data) + *(data) + ${RELOCATING+ __Hdata = .;} + } +.bss : { + ${RELOCATING+ __Lbss = .;} + *(.bss) + *(bss) + ${RELOCATING+ __Hbss = .;} + } +} +EOF diff --git a/binutils-2.21/ld/scripttempl/z8000.sc b/binutils-2.21/ld/scripttempl/z8000.sc new file mode 100644 index 0000000..b03f5d8 --- /dev/null +++ b/binutils-2.21/ld/scripttempl/z8000.sc @@ -0,0 +1,57 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH("${OUTPUT_ARCH}") +${RELOCATING+ENTRY (_start)} + +SECTIONS +{ +.text ${BIG+ ${RELOCATING+ 0x0000000}} : + { + *(.text) + *(.strings) + *(.rdata) + } + +.ctors ${BIG+ ${RELOCATING+ 0x2000000}} : + { + ${CONSTRUCTING+ ___ctors = . ; } + *(.ctors); + ${CONSTRUCTING+ ___ctors_end = . ; } + ___dtors = . ; + *(.dtors); + ${CONSTRUCTING+ ___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 + + + + |