summary refs log tree commit diff stats
path: root/results/scraper/box64/427
blob: ad59873d5a5f6520771cc460b70897e0dd173dba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Return value from main is not used as the exit code
For example, trying to emulate this program:

```c
int
main(void)
{
    return 1;
}
```

[return-1.gz](https://github.com/ptitSeb/box64/files/9809104/return-1.gz)

will result in an exit code of zero.

This patch appears to fix the problem:

```
diff --git a/src/emu/x64run_private.c b/src/emu/x64run_private.c
index 3b27f38..b7c206d 100755
--- a/src/emu/x64run_private.c
+++ b/src/emu/x64run_private.c
@@ -69,7 +69,7 @@ int32_t EXPORT my___libc_start_main(x64emu_t* emu, int *(main) (int, char * *, c
         SetRBP(emu, Pop64(emu));         // restore RBP
         emu->quit = 1;  // finished!
     }
-    return 0;
+    return GetEAX(emu);
 }
 
 const char* GetNativeName(void* p)
```

(I'm compiling some programs for Android by emulating the NDK, and `meson` relies on exit codes for compile-time feature checks. So far I don't think I've hit any other box64 bugs, apart from `lld` deadlocking if I don't pass `--threads=1` to disable multithreading. This is to be able to test against a Vulkan driver that doesn't have a GNU/Linux version, and also for compiling Mesa to use with waydroid.)