OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Aug 10, 2022 10:44 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: ELF 86_64 Relocatable file :: relocation issue
PostPosted: Sun Jun 26, 2022 11:25 am 
Offline
Member
Member

Joined: Tue Aug 30, 2016 1:31 pm
Posts: 58
Hello everyone,

I just started writing a 64bit OS.
I was trying to write a module loader.
https://github.com/AdeRegt/SanderOS64/b ... c/module.c
^ ^ ^ ^ this is my attempt

https://github.com/AdeRegt/SanderOS64/b ... keyboard.c
^ ^ ^ ^ this is an example driver

now, I expect the system to print out "Hello, world!".
But the system is printing out strange characters.
What am I doing wrong? I think something with the relocation is not going well.

Thank you in advantage.


Top
 Profile  
 
 Post subject: Re: ELF 86_64 Relocatable file :: relocation issue
PostPosted: Sun Jun 26, 2022 1:42 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4387
Location: Chichester, UK
You seem to be just reading the file into memory rather than loading the sections to the appropriate addresses.


Top
 Profile  
 
 Post subject: Re: ELF 86_64 Relocatable file :: relocation issue
PostPosted: Sun Jun 26, 2022 1:45 pm 
Offline
Member
Member

Joined: Tue Aug 30, 2016 1:31 pm
Posts: 58
Yeah, I want to dynamically load the program. So the program must be loaded at any place that I wan.


Top
 Profile  
 
 Post subject: Re: ELF 86_64 Relocatable file :: relocation issue
PostPosted: Sun Jun 26, 2022 2:13 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4387
Location: Chichester, UK
So you are compiling the code as position-independent?


Top
 Profile  
 
 Post subject: Re: ELF 86_64 Relocatable file :: relocation issue
PostPosted: Sun Jun 26, 2022 2:31 pm 
Offline
Member
Member

Joined: Tue Aug 30, 2016 1:31 pm
Posts: 58
Exactly


Top
 Profile  
 
 Post subject: Re: ELF 86_64 Relocatable file :: relocation issue
PostPosted: Sun Jun 26, 2022 2:46 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4387
Location: Chichester, UK
OK. I must have missed the switch for that in your compile command.


Top
 Profile  
 
 Post subject: Re: ELF 86_64 Relocatable file :: relocation issue
PostPosted: Sun Jun 26, 2022 4:25 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 4005
What is the address of the "hello world" string?

What address is being passed to k_printf?


Top
 Profile  
 
 Post subject: Re: ELF 86_64 Relocatable file :: relocation issue
PostPosted: Mon Jun 27, 2022 3:58 pm 
Offline
Member
Member

Joined: Tue Aug 30, 2016 1:31 pm
Posts: 58
Thank you for the answer,

This was indeed the problem, I solved the issue now, thanks allot!


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: nullplan, PetalBot [Bot] and 8 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