[PATCH] RISC-V: fix setting up std streams in init_semihosting()

Ram Nalamothu (QUIC) quic_vnalamot@quicinc.com
Wed Jan 3 08:03:49 GMT 2024


Without this patch, the following simple test would fail to run as expected.

#include <stdio.h>
int main() {
  int n;
  printf("Enter a number\n");
  scanf("%d", &n);
  printf("Entered number: %d\n", n);
  return 0;
}

If the patch looks good, could someone please commit it on behalf of me as I don't have commit rights.

-- 8< --

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-RISC-V-fix-setting-up-std-streams-in-init_semihostin.patch
Type: application/octet-stream
Size: 2051 bytes
Desc: 0001-RISC-V-fix-setting-up-std-streams-in-init_semihostin.patch
URL: <https://sourceware.org/pipermail/newlib/attachments/20240103/d911f60b/attachment.obj>


More information about the Newlib mailing list