ELF 86_64 Relocatable file :: relocation issue

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

ELF 86_64 Relocatable file :: relocation issue

Post by SanderR »

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.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: ELF 86_64 Relocatable file :: relocation issue

Post by iansjack »

You seem to be just reading the file into memory rather than loading the sections to the appropriate addresses.
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

Re: ELF 86_64 Relocatable file :: relocation issue

Post by SanderR »

Yeah, I want to dynamically load the program. So the program must be loaded at any place that I wan.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: ELF 86_64 Relocatable file :: relocation issue

Post by iansjack »

So you are compiling the code as position-independent?
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

Re: ELF 86_64 Relocatable file :: relocation issue

Post by SanderR »

Exactly
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: ELF 86_64 Relocatable file :: relocation issue

Post by iansjack »

OK. I must have missed the switch for that in your compile command.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: ELF 86_64 Relocatable file :: relocation issue

Post by Octocontrabass »

What is the address of the "hello world" string?

What address is being passed to k_printf?
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

Re: ELF 86_64 Relocatable file :: relocation issue

Post by SanderR »

Thank you for the answer,

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