I'd like to post the bochs log but the issue I posted above with the floppy controller prevents me from getting to this problem.
Doesn't elf's entry address default to something higher than 0x300000? Why are you using this address?
I'm not sure. I modeled my executable build process from something I saw on github. Basically I'm using this linker script:
Code: Select all
ENTRY(_start)
phys = 0x00300000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
/DISCARD/ :
{
*(.comment)
*(.eh_frame)
*(.note.gnu.build-id)
}
}
_start refers to this assembly file which is supposed to start the program:
Code: Select all
[BITS 32]
[GLOBAL _start]
_start:
pop eax ; I dont know if this is needed
extern main
call main
I compile that file plus the C file using my i686-elf cross compiler built from the instructions on the wiki.
The ss that comes in the page fault is 0x23. I push that value when going to user mode. And I do use iret using this code:
Code: Select all
asm volatile(" \
mov $0x23, %%ax; \
mov %%ax, %%ds; \
mov %%ax, %%es; \
mov %%ax, %%fs; \
mov %%ax, %%gs; \
pushl $0x23; \
push %0; \
pushl $0x200; \
pushl $0x1B; \
push %1; \
iret; \
":: "r" (mainThread->frame.esp), "m" (mainThread->frame.eip));