+# Copyright (C) 2014-2019 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
#
# Unusual variables checked by this code:
# NOP - two byte opcode for no-op (defaults to 0)
# .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.
+# combination of .init sections.
# FINI_START, FINI_END - statements just before and just after
-# combination of .fini sections.
+# 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.
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} :
+CTOR=".ctors ${CONSTRUCTING-0} :
{
${CONSTRUCTING+${CTOR_START}}
/* gcc uses crtbegin.o to find the start of
} > ROM"
cat <<EOF
+/* Copyright (C) 2014-2019 Free Software Foundation, Inc.
+
+ Copying and distribution of this script, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. */
+
OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
"${LITTLE_OUTPUT_FORMAT}")
OUTPUT_ARCH(${OUTPUT_ARCH})
-${RELOCATING+ENTRY(${ENTRY})}
+EOF
-${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. */}
+test -n "${RELOCATING}" && cat <<EOF
+ENTRY(${ENTRY})
+
+${LIB_SEARCH_DIRS}
+${EXECUTABLE_SYMBOLS}
+${INPUT_FILES}
/* 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
+MEMORY
{
RAM (w) : ORIGIN = 0, LENGTH = 0x7F00
ROM (!w) : ORIGIN = 0x8000, LENGTH = 0xFF8000
}
+EOF
+cat <<EOF
SECTIONS
{
.data ${RELOCATING-0} :
${RELOCATING+*(.data.*)}
${RELOCATING+*(.gnu.linkonce.d.*)}
${CONSTRUCTING+SORT(CONSTRUCTORS)}
- } > RAM
+ }${RELOCATING+ > RAM}
${RELOCATING+${OTHER_READWRITE_SECTIONS}}
${RELOCATING+${OTHER_GOT_SYMBOLS}}
${RELOCATING+${OTHER_GOT_SECTIONS}}
${RELOCATING+${OTHER_BSS_SYMBOLS}}
.bss ${RELOCATING-0} :
{
- *(.dynbss)
+ ${RELOCATING+*(.dynbss)}
*(.bss)
${RELOCATING+*(.bss.*)}
${RELOCATING+*(.gnu.linkonce.b.*)}
- *(COMMON)
+ ${RELOCATING+*(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
+ . = ALIGN(${ALIGNMENT});}
+ }${RELOCATING+ > RAM}
${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
${RELOCATING+. = ALIGN(${ALIGNMENT});}
${RELOCATING+${OTHER_END_SYMBOLS}}
${RELOCATING+PROVIDE (end = .);}
/* Read-only sections in ROM. */
- .int_vec ${RELOCATING-0} : { *(.int_vec) } ${RELOCATING+> ROM}
+ .int_vec ${RELOCATING-0} : { *(.int_vec) }${RELOCATING+ > ROM}
- .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } ${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}
+ .jcr : { KEEP (*(.jcr)) }${RELOCATING+ > ROM}
+ .eh_frame : { KEEP (*(.eh_frame)) }${RELOCATING+ > ROM}
+ .gcc_except_table : { *(.gcc_except_table)${RELOCATING+ *(.gcc_except_table.*)} }${RELOCATING+ > ROM}
+ .plt : { *(.plt) }${RELOCATING+ > ROM}
.text ${RELOCATING-0} :
{
*(.text)
${RELOCATING+*(.text.*)}
*(.stub)
- /* .gnu.warning sections are handled specially by elf32.em. */
+ /* .gnu.warning sections are handled specially by elf.em. */
*(.gnu.warning)
${RELOCATING+*(.gnu.linkonce.t.*)}
${RELOCATING+${OTHER_TEXT_SECTIONS}}
- } ${RELOCATING+> ROM =${NOP-0}}
- .init ${RELOCATING-0} :
- {
+ }${RELOCATING+ > ROM =${NOP-0}}
+ .init ${RELOCATING-0} :
+ {
${RELOCATING+${INIT_START}}
- KEEP (*(.init))
+ KEEP (*(SORT_NONE(.init)))
${RELOCATING+${INIT_END}}
- } ${RELOCATING+> ROM =${NOP-0}}
+ }${RELOCATING+ > ROM =${NOP-0}}
.fini ${RELOCATING-0} :
{
${RELOCATING+${FINI_START}}
- KEEP (*(.fini))
+ KEEP (*(SORT_NONE(.fini)))
${RELOCATING+${FINI_END}}
- } ${RELOCATING+> ROM =${NOP-0}}
+ }${RELOCATING+ > ROM =${NOP-0}}
${RELOCATING+PROVIDE (__etext = .);}
${RELOCATING+PROVIDE (_etext = .);}
${RELOCATING+PROVIDE (etext = .);}
EOF
-source $srcdir/scripttempl/DWARF.sc
+. $srcdir/scripttempl/DWARF.sc
cat <<EOF
${RELOCATING+${OTHER_RELOCATING_SECTIONS}}