Skip to content

Commit 0bccdb4

Browse files
Evgeny Iakovlevstsquad
Evgeny Iakovlev
authored andcommitted
semihosting: add O_BINARY flag in host_open for NT compatibility
Windows open(2) implementation opens files in text mode by default and needs a Windows-only O_BINARY flag to open files as binary. QEMU already knows about that flag in osdep and it is defined to 0 on non-Windows, so we can just add it to the host_flags for better compatibility. Signed-off-by: Evgeny Iakovlev <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Bin Meng <[email protected]> Message-Id: <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Message-Id: <[email protected]>
1 parent 978c2bf commit 0bccdb4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

semihosting/syscalls.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
253253
{
254254
CPUArchState *env G_GNUC_UNUSED = cs->env_ptr;
255255
char *p;
256-
int ret, host_flags;
256+
int ret, host_flags = O_BINARY;
257257

258258
ret = validate_lock_user_string(&p, cs, fname, fname_len);
259259
if (ret < 0) {
@@ -262,11 +262,11 @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
262262
}
263263

264264
if (gdb_flags & GDB_O_WRONLY) {
265-
host_flags = O_WRONLY;
265+
host_flags |= O_WRONLY;
266266
} else if (gdb_flags & GDB_O_RDWR) {
267-
host_flags = O_RDWR;
267+
host_flags |= O_RDWR;
268268
} else {
269-
host_flags = O_RDONLY;
269+
host_flags |= O_RDONLY;
270270
}
271271
if (gdb_flags & GDB_O_CREAT) {
272272
host_flags |= O_CREAT;

0 commit comments

Comments
 (0)