Skip to content

Bug: cosmocc resulting binary can't boot #1435

@DuilioPerez

Description

@DuilioPerez

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    low severityUsed to report low severity bugs (e.g. cosmetic issues, non critical UI glitches)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions