Page 1 of 1
module questions
Posted: Tue May 03, 2005 11:55 am
by Poseidon
The module support for my kernel is nearly finished
. I only can't figure out when the ELF-file tells me that the call is relative, how I can link that address to a function in my kernel. When I use an absolute address in my module (by using a function pointer), it works all fine - except printing strings. Direct values (using putchar) works fine - a whole string with puts prints a whole bunch of weird characters on the screen.
Anyone?
Thanks
.
Re:module questions
Posted: Wed May 04, 2005 3:26 pm
by Poseidon
i have figured out this code to link external relatives (and it works
):
Code: Select all
*((uint*)(section.bits + rel.r_offset)) = 0xfffffffc - ((target - exports[i].addr) + rel.r_offset + section.base);
/* section.bits = programbits
* 0xfffffffc = start at 0 at function (not sure about this, but it works)
* target = where the program is in the memory
* exports[i].addr = the address of the function in the kernel
* rel.r_offset = where in the kernel the function is called
*/
so this code works... but i'm not sure this'll work in all cases?
thanks
btw, strings do work now as well
:D