Keep the tests at the start of RAM but bound them with a MEMORY region, and use this to define __stack_top, which the multiarch system test boot code will use.
Add more sections generated by the test binaries so they are placed explicitly. Split text and data into separate rx/rw regions, instead of one rwx region to avoid binutils warnings. A -kernel boot jumps to the lowest loaded address rather than the ELF entry point, so _start must be first in .text. Use a .text._start input section to make that explicit. Signed-off-by: Joel Stanley <[email protected]> --- tests/tcg/riscv64/semihost.ld | 47 +++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/tests/tcg/riscv64/semihost.ld b/tests/tcg/riscv64/semihost.ld index a59cc56b289a..eff3701e4a19 100644 --- a/tests/tcg/riscv64/semihost.ld +++ b/tests/tcg/riscv64/semihost.ld @@ -1,21 +1,46 @@ +/* + * Linker script for the RISC-V system tests + * SPDX-License-Identifier: GPL-2.0-or-later + */ + ENTRY(_start) +MEMORY +{ + /* + * Virt machine, RAM starts at 2GB + * + * Separate sections for executable and writable data to avoid linker + * warnings. + */ + TXT (rx) : ORIGIN = 0x80000000, LENGTH = 2M + DAT (rw) : ORIGIN = 0x80000000 + 2M, LENGTH = 2M +} + SECTIONS { - /* virt machine, RAM starts at 2gb */ - . = 0x80000000; .text : { + *(.text._start) *(.text) - } + } > TXT + .rodata : { - *(.rodata) - } - /* align r/w section to next 2mb */ - . = ALIGN(1 << 21); + *(.rodata .rodata.*) + *(.eh_frame) + } > TXT + + .got : { + *(.got .got.plt) + } > DAT + .data : { - *(.data) - } + *(.data .data.* .sdata .sdata.*) + } > DAT + .bss : { - *(.bss) - } + *(.bss .bss.* .sbss .sbss.*) + } > DAT + + /* Stack grows down from the end of the data region */ + __stack_top = ORIGIN(DAT) + LENGTH(DAT); } -- 2.47.3
