From c419bbb341528a97d2de88539caf200c9dec1ffb Mon Sep 17 00:00:00 2001 From: Venkata Ramanaiah Nalamothu Date: Wed, 3 Jan 2024 12:22:16 +0530 Subject: RISC-V: fix setting up std streams in init_semihosting() Currently init_semihosting() assumes the return value from _open() call as the file descriptor handle and that is incorrect. The semihost _open() call returns the fdtable index returned by the __add_fdentry() for the file opened. --- libgloss/riscv/semihost-sys_fdtable.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'libgloss') diff --git a/libgloss/riscv/semihost-sys_fdtable.c b/libgloss/riscv/semihost-sys_fdtable.c index 152c92d15..d62e3f970 100644 --- a/libgloss/riscv/semihost-sys_fdtable.c +++ b/libgloss/riscv/semihost-sys_fdtable.c @@ -24,25 +24,26 @@ static struct fdentry fdtable[RISCV_MAX_OPEN_FILES]; void __attribute__ ((constructor)) init_semihosting () { - int handle; + int i; - for (int i=0; i