Bug: cosmocc resulting binary can't boot
low severity
### Contact Details
_No response_
### What happened?
I've compiled the file vga2.c from example directory. I've tested in ARM64 and x86-64 and it works. However, even if `file` recognize it as a boot sector, `qemu-system-x86_64` doesn't boot it: This is the output after compiling:
```
~/Test $ cosmocc vga2.c -o vga.com
~/Test $ ls *.com*
vga.com vga.com.dbg
~/Test $ file vga.com
vga.com: DOS/MBR boot sector; partition 1 : ID=0x7f, active, start-CHS (0x0,0,1), end-CHS (0x3ff,255,63), startsector 0, 4294967295 sectors
~/Test $ file vga.com.dbg
vga.com.dbg: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, with debug_info, not stripped
~/Test $ ls -lh vga.com
-rwx------. 1 u0_a289 u0_a289 618K Aug 11 15:11 vga.com
```
I think the value of `sectors` have nonsense. The file vga.c can't compile, maybe is outdated:
```
~/Test $ cosmocc ~/cosmopolitan/examples/vga.c -o vga.com
/home/cosmopolitan/examples/vga.c: In function 'main':
/home/cosmopolitan/examples/vga.c:58:16: error: implicit declaration of function 'readansi' [-Wimplicit-function-declaration]
58 | if ((res = readansi(0, buf, 16)) > 0) {
| ^~~~~~~~
~/Test $
```
### Version
cosmocc (GCC) 14.1.0
### What operating system are you seeing the problem on?
BIOS
### Relevant log output
```shell
```
0 条评论