From cbebc4b9010f13d9a84066f5fce8ddd99bb57b75 Mon Sep 17 00:00:00 2001 From: Huaqi Fang <578567190@qq.com> Date: Wed, 7 Feb 2024 21:16:33 +0800 Subject: [PATCH] libgloss/riscv: Fix wrong fdtable[i]->handle assignment This assignment is already done correctly in __add_fdentry if we do it after open, it is wrong, the _open is return the file handle index of fdtable not the handle return by semihost open call which is recorded in fdtable[i]->handle This should be able to fix unable to run qemu with semihosting in windows see https://gito.corp.nucleisys.com/software/devtools/qemu/-/issues/128 This will fix nuclei sdk make SEMIHOST=1 run_qemu not output issue Signed-off-by: Huaqi Fang <578567190@qq.com> --- libgloss/riscv/semihost-sys_fdtable.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libgloss/riscv/semihost-sys_fdtable.c b/libgloss/riscv/semihost-sys_fdtable.c index 152c92d15..546291a26 100644 --- a/libgloss/riscv/semihost-sys_fdtable.c +++ b/libgloss/riscv/semihost-sys_fdtable.c @@ -32,18 +32,12 @@ init_semihosting () /* Set up std streams. */ /* stdin. */ handle = _open (":tt", O_RDONLY); - fdtable[STDIN_FILENO].handle = handle; - fdtable[STDIN_FILENO].pos = 0; /* stdout. */ handle = _open (":tt", O_WRONLY|O_CREAT|O_TRUNC); - fdtable[STDOUT_FILENO].handle = handle; - fdtable[STDOUT_FILENO].pos = 0; /* stderr. */ handle = _open (":tt", O_WRONLY|O_CREAT|O_APPEND); - fdtable[STDERR_FILENO].handle = handle; - fdtable[STDERR_FILENO].pos = 0; } /* Add entry to fdtable. */