OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Jun 12, 2021 9:19 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Invalid memory access, from faulty ELF loader
PostPosted: Sun May 09, 2021 2:47 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 354
Location: North Florida, USA
Note: I have been locked out of my account for months: I tried to reset my password and I forgot to click the link to activate the new password! Oh my am I a special case.

I have been attempting to write an ELF loader. I have written a simple little shell, dubbed "mnsh", and at first it was integrated into the kernel binary. Then, I shoved it into userspace and isolated it from the rest of the kernel. Now, I am attempting to load a separate executable via stivale modules and ELF loading. (The next step up is writing a proper FAT32 driver and a VFS, I'm a little stumped on that at the moment however and an ELF loader seemed to be the best option to work on at the moment.)

[ELF Loader Source Code: https://github.com/rizet/micron/tree/wa ... scheduling]
[MNSH Source Code: https://github.com/rizet/micron/tree/wa ... alpha/mnsh]

However, I printed the entry point address I am returning, and it seems to point to the correct code. However, when I actually do return the address, and call into it in the userspace entry, I page fault.
In particular, a faulty read that violated page protections during an instruction fetch for userspace code.

All the ELF headers/values seem to be correct, I've printed them out and objdump'd them a few times, just to cross-check. I originally believed that the loading executable was relocatable, but it is not: my memory has failed me.

So I am unsure if I lost the value in the long road from loading to executing, if the program segments are incorrectly loaded, or if I mapped the pages incorrectly.

Thank you in advance for your support.

_________________
Skylight: https://github.com/rizet/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".


Top
 Profile  
 
 Post subject: Re: Invalid memory access, from faulty ELF loader
PostPosted: Sun May 09, 2021 3:07 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 354
Location: North Florida, USA
Well all bugs come from simple mistakes.

I did indeed lose the value, from an incorrect asm statement.

mov rax, rdi
instead of
mov rdi, rax

I feel incredibly accomplished.

_________________
Skylight: https://github.com/rizet/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group