flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Problem with loading ELF header

Author
Thread Post new topic Reply to topic
Szustarol



Joined: 11 Jul 2016
Posts: 9
Szustarol 06 Mar 2017, 19:04
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: 20363
Location: In your JS exploiting you and your system
revolution 07 Mar 2017, 02:12
You have altered rcx within the loop with this line:
Code:
mov rcx, r10    
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
Szustarol 07 Mar 2017, 15:44
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: 20363
Location: In your JS exploiting you and your system
revolution 07 Mar 2017, 16:47
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
Szustarol 07 Mar 2017, 20:00
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: 44
Location: Dnipro, Ukraine
alkap 08 Mar 2017, 10:00
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.