2017-10-07 00:16:47 +00:00
|
|
|
cat <<EOF
|
|
|
|
OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
|
|
|
|
OUTPUT_ARCH(${ARCH})
|
|
|
|
|
2022-10-27 18:45:45 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test -n "${RELOCATING}" && cat <<EOF
|
|
|
|
/* Allow memory sizes to be overridden from command line. */
|
|
|
|
__IMEM_SIZE = DEFINED(__IMEM_SIZE) ? __IMEM_SIZE : $TEXT_LENGTH;
|
|
|
|
__DMEM_SIZE = DEFINED(__DMEM_SIZE) ? __DMEM_SIZE : $DATA_LENGTH;
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
MEMORY
|
|
|
|
{
|
2022-10-27 18:45:45 +00:00
|
|
|
imem (x) : ORIGIN = $TEXT_ORIGIN, LENGTH = __IMEM_SIZE
|
|
|
|
dmem (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DMEM_SIZE
|
2017-10-07 00:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : 32;
|
|
|
|
__STACK_SIZE = DEFINED(__STACK_SIZE) ? __STACK_SIZE : 512;
|
|
|
|
|
2022-10-27 18:45:45 +00:00
|
|
|
PROVIDE (_stack_top = ORIGIN(dmem) + LENGTH(dmem));
|
|
|
|
|
|
|
|
ENTRY (_start)
|
2017-10-07 00:16:47 +00:00
|
|
|
|
2022-10-27 18:45:45 +00:00
|
|
|
EOF
|
2017-10-07 00:16:47 +00:00
|
|
|
|
2022-10-27 18:45:45 +00:00
|
|
|
cat <<EOF
|
2017-10-07 00:16:47 +00:00
|
|
|
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.*)}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+*(.rel.text:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+*(.rel.gnu.linkonce.t*)}
|
|
|
|
}
|
|
|
|
.rela.text ${RELOCATING-0} :
|
|
|
|
{
|
|
|
|
*(.rela.text)
|
|
|
|
${RELOCATING+*(.rela.text.*)}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+*(.rela.text:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${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.*)}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+*(.rel.rodata:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+*(.rel.gnu.linkonce.r*)}
|
|
|
|
}
|
|
|
|
.rela.rodata ${RELOCATING-0} :
|
|
|
|
{
|
|
|
|
*(.rela.rodata)
|
|
|
|
${RELOCATING+*(.rela.rodata.*)}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+*(.rela.rodata:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+*(.rela.gnu.linkonce.r*)}
|
|
|
|
}
|
|
|
|
.rel.data ${RELOCATING-0} :
|
|
|
|
{
|
|
|
|
*(.rel.data)
|
|
|
|
${RELOCATING+*(.rel.data.*)}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+*(.rel.data:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+*(.rel.gnu.linkonce.d*)}
|
|
|
|
}
|
|
|
|
.rela.data ${RELOCATING-0} :
|
|
|
|
{
|
|
|
|
*(.rela.data)
|
|
|
|
${RELOCATING+*(.rela.data.*)}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+*(.rela.data:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+*(.rela.gnu.linkonce.d*)}
|
|
|
|
}
|
2018-12-28 15:25:28 +00:00
|
|
|
.rel.init_array ${RELOCATING-0} : { *(.rel.init_array) }
|
|
|
|
.rela.init_array ${RELOCATING-0} : { *(.rela.init_array) }
|
|
|
|
.rel.fini_array ${RELOCATING-0} : { *(.rel.fini_array) }
|
|
|
|
.rela.fini_array ${RELOCATING-0} : { *(.rela.fini_array) }
|
|
|
|
.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) }
|
2017-10-07 00:16:47 +00:00
|
|
|
|
|
|
|
/* Internal text space. */
|
|
|
|
.text ${RELOCATING-0} :
|
|
|
|
{
|
|
|
|
${RELOCATING+ _text_start = . ; }
|
|
|
|
|
|
|
|
${RELOCATING+. = ALIGN(4);}
|
|
|
|
|
|
|
|
${RELOCATING+*(.init0) /* Start here after reset. */}
|
|
|
|
${RELOCATING+KEEP (*(.init0))}
|
|
|
|
|
|
|
|
${RELOCATING+. = ALIGN(4);}
|
|
|
|
*(.text)
|
|
|
|
${RELOCATING+. = ALIGN(4);}
|
|
|
|
${RELOCATING+*(.text.*)}
|
|
|
|
${RELOCATING+. = ALIGN(4);}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+*(.text:*)}
|
|
|
|
${RELOCATING+. = ALIGN(4);}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+*(.gnu.linkonce.t*)}
|
|
|
|
${RELOCATING+. = ALIGN(4);}
|
|
|
|
|
|
|
|
${RELOCATING+ _text_end = . ; }
|
|
|
|
} ${RELOCATING+ > imem}
|
|
|
|
|
|
|
|
.data ${RELOCATING-0} :
|
|
|
|
{
|
|
|
|
/* Optional variable that user is prepared to have NULL address. */
|
|
|
|
${RELOCATING+ *(.data.atzero*)}
|
|
|
|
|
|
|
|
/* CRT is prepared for constructor/destructor table to have
|
|
|
|
a "valid" NULL address. */
|
2022-10-27 18:45:45 +00:00
|
|
|
${CONSTRUCTING+ __init_array_start = . ; }
|
2018-12-28 15:25:28 +00:00
|
|
|
${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))}
|
|
|
|
${CONSTRUCTING+ KEEP (*(.init_array))}
|
|
|
|
${CONSTRUCTING+ __init_array_end = . ; }
|
2022-10-27 18:45:45 +00:00
|
|
|
${CONSTRUCTING+ __fini_array_start = . ; }
|
2018-12-28 15:25:28 +00:00
|
|
|
${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))}
|
|
|
|
${CONSTRUCTING+ KEEP (*(.fini_array))}
|
|
|
|
${CONSTRUCTING+ __fini_array_end = . ; }
|
2017-10-07 00:16:47 +00:00
|
|
|
|
2022-10-27 18:45:45 +00:00
|
|
|
${RELOCATING+/* DATA memory starts at address 0. So to avoid placing a valid static
|
2017-10-07 00:16:47 +00:00
|
|
|
variable at the invalid NULL address, we introduce the .data.atzero
|
|
|
|
section. If CRT can make some use of it - great. Otherwise skip a
|
|
|
|
word. In all cases .data/.bss sections must start at non-zero. */
|
2022-10-27 18:45:45 +00:00
|
|
|
. += (. == 0 ? 4 : 0);}
|
2017-10-07 00:16:47 +00:00
|
|
|
|
|
|
|
${RELOCATING+ PROVIDE (_data_start = .) ; }
|
|
|
|
*(.data)
|
|
|
|
${RELOCATING+ *(.data*)}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+ *(.data:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+ *(.rodata) /* We need to include .rodata here if gcc is used. */}
|
|
|
|
${RELOCATING+ *(.rodata.*) /* with -fdata-sections. */}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+ *(.rodata:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+*(.gnu.linkonce.d*)}
|
|
|
|
${RELOCATING+*(.gnu.linkonce.r*)}
|
|
|
|
${RELOCATING+. = ALIGN(4);}
|
|
|
|
${RELOCATING+ PROVIDE (_data_end = .) ; }
|
|
|
|
} ${RELOCATING+ > dmem }
|
|
|
|
|
2022-10-27 18:45:45 +00:00
|
|
|
/* Linux remoteproc loader requires the resource_table section
|
|
|
|
start address to be aligned to 8 bytes. */
|
|
|
|
.resource_table ${RELOCATING-0} ${RELOCATING+ ALIGN(8)} :
|
2017-10-07 00:16:47 +00:00
|
|
|
{
|
|
|
|
KEEP (*(.resource_table))
|
2022-10-27 18:45:45 +00:00
|
|
|
} ${RELOCATING+ > dmem}
|
2017-10-07 00:16:47 +00:00
|
|
|
|
|
|
|
.bss ${RELOCATING-0} :
|
|
|
|
{
|
|
|
|
${RELOCATING+ PROVIDE (_bss_start = .) ; }
|
|
|
|
*(.bss)
|
|
|
|
${RELOCATING+ *(.bss.*)}
|
2018-12-28 15:25:28 +00:00
|
|
|
${RELOCATING+ *(.bss:*)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+*(.gnu.linkonce.b*)}
|
2022-10-27 18:45:45 +00:00
|
|
|
${RELOCATING+*(COMMON)}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+ PROVIDE (_bss_end = .) ; }
|
|
|
|
} ${RELOCATING+ > dmem}
|
|
|
|
|
|
|
|
/* Global data not cleared after reset. */
|
2022-10-27 18:45:45 +00:00
|
|
|
.noinit ${RELOCATING-0} :
|
2017-10-07 00:16:47 +00:00
|
|
|
{
|
|
|
|
${RELOCATING+ PROVIDE (_noinit_start = .) ; }
|
2022-10-27 18:45:45 +00:00
|
|
|
*(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+ PROVIDE (_noinit_end = .) ; }
|
|
|
|
${RELOCATING+ PROVIDE (_heap_start = .) ; }
|
|
|
|
${RELOCATING+ . += __HEAP_SIZE ; }
|
2022-10-27 18:45:45 +00:00
|
|
|
${RELOCATING+/* Stack is not here really. It will be put at the end of DMEM.
|
2017-10-07 00:16:47 +00:00
|
|
|
But we take into account its size here, in order to allow
|
2022-10-27 18:45:45 +00:00
|
|
|
for MEMORY overflow checking during link time. */}
|
2017-10-07 00:16:47 +00:00
|
|
|
${RELOCATING+ . += __STACK_SIZE ; }
|
|
|
|
} ${RELOCATING+ > dmem}
|
|
|
|
|
2022-10-27 18:45:45 +00:00
|
|
|
/* Remoteproc loader in Linux kernel 5.10 and later reads this section
|
|
|
|
to setup the PRUSS interrupt controller. The interrupt map section
|
|
|
|
is never referenced from PRU firmware, so there is no need to
|
|
|
|
place it in the target dmem memory. */
|
|
|
|
.pru_irq_map 0 : { *(.pru_irq_map) }
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
/* 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) }
|
2022-10-27 18:45:45 +00:00
|
|
|
.note.gnu.build-id ${RELOCATING-0} : { *(.note.gnu.build-id) }
|
2017-10-07 00:16:47 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
. $srcdir/scripttempl/DWARF.sc
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
}
|
|
|
|
EOF
|