flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > OS Construction > Problem with loading ELF header

Author
Thread Post new topic Reply to topic
Szustarol



Joined: 11 Jul 2016
Posts: 9
Problem with loading ELF header
Hi!
I somehow encounter a triple fault when loading ELF header
Code of my second stage bootloader is here:
https://github.com/cuaox/RIOS/blob/master/BOOTLOADER/stage2.asm
with jmp $ i have noticed that if i place it before the loop directive it is not crashing, so why is the loop .loadloop triple faulting my OS?
Thanks for any help
Post 06 Mar 2017, 19:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15167
Location: GW170817
You have altered rcx within the loop with this line:

Code:
mov rcxr10

So when you get to the loop instruction rcx is zero.
Post 07 Mar 2017, 02:12
View user's profile Send private message Visit poster's website Reply with quote
Szustarol



Joined: 11 Jul 2016
Posts: 9
Okay but before I do this, I do
mov r15, rcx
and then I
mov rcx, r15

so its value should be restored, shouldn't it?
Post 07 Mar 2017, 15:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15167
Location: GW170817
Okay, I didn't see that.

Maybe your ELF file is malformed, or maybe you are reading the wrong addresses, or checking for the wrong values? Not sure. I can't run the code to check.
Post 07 Mar 2017, 16:47
View user's profile Send private message Visit poster's website Reply with quote
Szustarol



Joined: 11 Jul 2016
Posts: 9
So i have updated my repo.
I am sure it crashes at loop
rcx is fffffffffffffffe hex when the loop jumps so i guess thats the problem
any ideas?
I have no idea why the rcx is loaded wrongly

can you take a look at my makefile?
I dont think elf is malformed
Post 07 Mar 2017, 20:00
View user's profile Send private message Reply with quote
alkap



Joined: 18 Feb 2015
Posts: 39
Location: Dnipro, Ukraine
Not sure this is it, but I've noticed that your offsets are all 8 bytes except for the mov r10. is that by design, or an oversight?

Code:

mov r8, [rsi + 8]
mov r9, [rsi + 0x10]
mov r10, [rsi + 0x20; 16-byte offset
mov r11, [rsi + 0x28]


Post 08 Mar 2017, 10:00
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.