EOF is not detected, when semihosting is reading from stdin
Host environment
- Operating system: Ubuntu 22.04.3 LTS
- OS/kernel version: Linux 6.2.0-34-generic #34~22.04.1-Ubuntu
- Architecture: x86_64
- QEMU flavor: qemu-system-arm
- QEMU version: 8.1.50 (v8.1.0-2161-ga9526048)
- QEMU command line:
echo -n 1234 | ~/local/qemu/git/bin/qemu-system-arm -M mps2-an385 -cpu cortex-m3 -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -monitor none -serial none -nographic -device loader,file=test-stdin,cpu-num=0
Emulated/Virtualized environment
- Operating system: bare metal
- OS/kernel version: bare metal
- Architecture: arm
Description of problem
QEMU hangs.
Steps to reproduce
- Run the program with stdin from a pipe.
Additional information
The code is compiled from this source:
#include <stdio.h>
int main(int argc, char** argv) {
int i = -1;
int result = scanf("%d", &i);
printf("result = %d, i = %d\n", result, i);
return 0;
}
compiled with GCC and picolibc:
arm-none-eabi-gcc --specs=picolibc.specs -march=armv7-m ~/sources/picolibc/git/test-stdin.c -o test-stdin -lc -lsemihost --crt0=hosted -O0 -g
test-stdin The execution hangs at semihosting SYS_READC(0x7) call:
movs r0, #7
(...)
bkpt #0xab
Edited by Dominik Wójt