You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Giving a printf("hello world") APE (cosmocc -o hello hello.c) to qemu-system-x86_64 causes boot loops. Upon closer inspection, the bootloader (pc in ape.S) seems to be loading from the start of the file instead of where the code actually is (0x10000 into the file), causing it to try to execute the ELF header at 0x4e0 and fail.
Using a debugger to set the al, cl, dh, si, eflags registers and make it start loading from 0x10000 makes it go further along, failing after transition to long mode in __get_virtual.
0x000000000040107e <+109>: mov $0x1000,%ecx
0x0000000000401083 <+114>: xor %eax,%eax
0x0000000000401085 <+116>: rep stos %al,%es:(%rdi) // dies here
bochs log at this failure:
00026266026e[CPU0 ] interrupt(long mode): vector must be within IDT table limits, IDT.limit = 0x0
00026266026e[CPU0 ] interrupt(long mode): vector must be within IDT table limits, IDT.limit = 0x0
00026266026i[CPU0 ] CPU is in long mode (active)
00026266026i[CPU0 ] CS.mode = 64 bit
00026266026i[CPU0 ] SS.mode = 64 bit
00026266026i[CPU0 ] EFER = 0x00000d01
00026266026i[CPU0 ] | RAX=0000000000000000 RBX=ffff80000007c018
00026266026i[CPU0 ] | RCX=0000000000001000 RDX=00000000fffc0000
00026266026i[CPU0 ] | RSP=000000000007fe90 RBP=000000000007fed0
00026266026i[CPU0 ] | RSI=00000000fffc0000 RDI=ffff8000fffc0000
00026266026i[CPU0 ] | R8=0000000000000002 R9=0000000000000002
00026266026i[CPU0 ] | R10=0000000000000518 R11=0000000000000002
00026266026i[CPU0 ] | R12=ffff8000fffc0000 R13=000000000000001e
00026266026i[CPU0 ] | R14=0000000000000001 R15=ffff800000000000
00026266026i[CPU0 ] | IOPL=0 ID vip vif ac vm RF nt of df if tf sf ZF af PF cf
00026266026i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00026266026i[CPU0 ] | CS:0028( 0005| 0| 0) 00000000 ffffffff 1 0
00026266026i[CPU0 ] | DS:0030( 0006| 0| 0) 00000000 ffffffff 1 0
00026266026i[CPU0 ] | SS:0030( 0006| 0| 0) 00000000 ffffffff 1 0
00026266026i[CPU0 ] | ES:0030( 0006| 0| 0) 00000000 ffffffff 1 0
00026266026i[CPU0 ] | FS:0030( 0006| 0| 0) 00000000 ffffffff 1 0
00026266026i[CPU0 ] | GS:0030( 0006| 0| 0) 00000000 ffffffff 1 0
00026266026i[CPU0 ] | MSR_FS_BASE:0000000000000000
00026266026i[CPU0 ] | MSR_GS_BASE:0000000000000000
00026266026i[CPU0 ] | RIP=ffff800000101085 (ffff800000101085)
00026266026i[CPU0 ] | CR0=0xe0000013 CR2=0xffff8000fffc0000
00026266026i[CPU0 ] | CR3=0x000000000007e000 CR4=0x000002a0
00026266026e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
Version
cosmocc (GCC) 14.1.0
What operating system are you seeing the problem on?
BIOS
Relevant log output
No response
The text was updated successfully, but these errors were encountered:
Contact Details
No response
What happened?
Giving a printf("hello world") APE (
cosmocc -o hello hello.c
) toqemu-system-x86_64
causes boot loops. Upon closer inspection, the bootloader (pc
inape.S
) seems to be loading from the start of the file instead of where the code actually is (0x10000
into the file), causing it to try to execute the ELF header at0x4e0
and fail.Using a debugger to set the
al
,cl
,dh
,si
,eflags
registers and make it start loading from0x10000
makes it go further along, failing after transition to long mode in__get_virtual
.bochs log at this failure:
Version
cosmocc (GCC) 14.1.0
What operating system are you seeing the problem on?
BIOS
Relevant log output
No response
The text was updated successfully, but these errors were encountered: