unfortunately gdb server is not functioning normal with qemu, so i have not found out a way to do single step debuggingiansjack wrote:Single-step the code under a debugger to see what is going wrong.
binary format vs elf64 format
Re: binary format vs elf64 format
Re: binary format vs elf64 format
Try SimNow ( http://developer.amd.com/tools-and-sdks ... simulator/ ). It is a very good tool for debugging assembler programs. But when you get serious and start using C you'll need to sort out your gdb problem.
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: binary format vs elf64 format
You could also use Bochs, which has a built-in debugger that can be single-stepped; however, you would need a version of it built with the debugger option, and the standard builds that are distributed for Windows, MacOS, and most Linux package managers don't have that as the default, so you may need to build the Bochs executable yourself.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Re: binary format vs elf64 format
Now I think the most possible problem may be in the elf loader, because I did the app test at the kernel entry point right after boot loader passed over control to kernel, and the problem occurred. But the elf loader seemed so straight forward, really can't identify what's wrong
Re: binary format vs elf64 format
This is why you need to do some debugging.
Re: binary format vs elf64 format
I added below testing to both boot loader(right before jumping to kernel), and to the kernel(right after get control from boot loader)
the boot loader is okay to call the test procedure, but the kernel got GP exception, with RIP = 0.
that's really strange. the only difference is that the loader is in raw bin format, while the kernel is in elf64 format. does elf64 has any affect on memory protection attributes?
Code: Select all
simuapp_run:
mov rax, 0x0000c300001234b8 ; machine code for: mov rax 0x1234 + ret
mov rdi, 0x0000000000800000
stosq
call 0x0000000000800000
ret
that's really strange. the only difference is that the loader is in raw bin format, while the kernel is in elf64 format. does elf64 has any affect on memory protection attributes?
Re: binary format vs elf64 format
The elf format is just that - a file format. It only affects anything in the way that you interpret it.
Last time I'll say this: use a debugger to inspect the program.
Last time I'll say this: use a debugger to inspect the program.
- MichaelFarthing
- Member
- Posts: 167
- Joined: Thu Mar 10, 2016 7:35 am
- Location: Lancaster, England, Disunited Kingdom
Re: binary format vs elf64 format
You presumably mean machine code for: mov eax 0x1234 retcitop wrote:I added below testing to both boot loader(right before jumping to kernel), and to the kernel(right after get control from boot loader)
the boot loader is okay to call the test procedure, but the kernel got GP exception, with RIP = 0.Code: Select all
simuapp_run: mov rax, 0x0000c300001234b8 ; machine code for: mov rax 0x1234 + ret mov rdi, 0x0000000000800000 stosq call 0x0000000000800000 ret
that's really strange. the only difference is that the loader is in raw bin format, while the kernel is in elf64 format. does elf64 has any affect on memory protection attributes?
Not sure of your set up, and my 64 bit knowledge is rudimentary, but could it be that the boot loader is defaulting to 32 bit register size and the kernel to 64, so the boot is seeing the line above and the kernel is seeing mov rax 0xc300001234
Re: binary format vs elf64 format
not presumably. the machine code is generated by compiling the below source with nasm:MichaelFarthing wrote:You presumably mean machine code for: mov eax 0x1234 retcitop wrote:I added below testing to both boot loader(right before jumping to kernel), and to the kernel(right after get control from boot loader)
the boot loader is okay to call the test procedure, but the kernel got GP exception, with RIP = 0.Code: Select all
simuapp_run: mov rax, 0x0000c300001234b8 ; machine code for: mov rax 0x1234 + ret mov rdi, 0x0000000000800000 stosq call 0x0000000000800000 ret
that's really strange. the only difference is that the loader is in raw bin format, while the kernel is in elf64 format. does elf64 has any affect on memory protection attributes?
Not sure of your set up, and my 64 bit knowledge is rudimentary, but could it be that the boot loader is defaulting to 32 bit register size and the kernel to 64, so the boot is seeing the line above and the kernel is seeing mov rax 0xc300001234
Code: Select all
USE64
mov rax, 0x1234
ret