Page 1 of 1

ELF 86_64 Relocatable file :: relocation issue

Posted: Sun Jun 26, 2022 11:25 am
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.

Re: ELF 86_64 Relocatable file :: relocation issue

Posted: Sun Jun 26, 2022 1:42 pm
by iansjack
You seem to be just reading the file into memory rather than loading the sections to the appropriate addresses.

Re: ELF 86_64 Relocatable file :: relocation issue

Posted: Sun Jun 26, 2022 1:45 pm
by SanderR
Yeah, I want to dynamically load the program. So the program must be loaded at any place that I wan.

Re: ELF 86_64 Relocatable file :: relocation issue

Posted: Sun Jun 26, 2022 2:13 pm
by iansjack
So you are compiling the code as position-independent?

Re: ELF 86_64 Relocatable file :: relocation issue

Posted: Sun Jun 26, 2022 2:31 pm
by SanderR
Exactly

Re: ELF 86_64 Relocatable file :: relocation issue

Posted: Sun Jun 26, 2022 2:46 pm
by iansjack
OK. I must have missed the switch for that in your compile command.

Re: ELF 86_64 Relocatable file :: relocation issue

Posted: Sun Jun 26, 2022 4:25 pm
by Octocontrabass
What is the address of the "hello world" string?

What address is being passed to k_printf?

Re: ELF 86_64 Relocatable file :: relocation issue

Posted: Mon Jun 27, 2022 3:58 pm
by SanderR
Thank you for the answer,

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