I'm trying to get my userland programs to link nicely with my kernel. Essentially I'm using remote procedure calls, so userland programs actually have to call kernel functions directly. However, I don't want to compile any of the kernel code statically in to these programs (for obvious reasons). So, what I want to do, is have all references to kernel symbols (functions etc) to automatically resolve to the correct address in kernel code. I don't think I explained that all too well, so here's an example:
Userland program:
Code: Select all
push eax
call 0x100010 <readStackPointer>
So, I thought about several ways to do this. The first was to create a .so for my kernel, then bind the symbols dynamically when the program is loaded. This seems like an elegant solution to me, but I get the following error when linking with this .so (and before you ask I've tried every damn combination of ld flags both when linking the .so and linking the userland program
![Razz :P](./images/smilies/icon_razz.gif)
Code: Select all
james@james-desktop:~/Code/C/Linux/jimix2/jimix2/trunk/initrd/udev$ ld -o udev -Bsymbolic ../../src/lib/crt0.o main.o ../../src/lib/libjimix.a -L ../../src/ -lkernel
ld: warning: type and size of dynamic symbol `readStackPointer' are not defined
ld: dynamic variable `readStackPointer' is zero size
ld: main.o(.text+0x2c): unresolvable R_386_PC32 relocation against symbol `readStackPointer'
ld: final link failed: Nonrepresentable section on output
![Sad :(](./images/smilies/icon_sad.gif)
OK, so any help on that would be grand, but I tried another method - that is manually defining all kernel symbols at link-time.
I can do this with
Code: Select all
--defsym readStackPointer=0x666
Any help would be MUCH appreciated
![Smile :)](./images/smilies/icon_smile.gif)
And I have tried google. of course. But that link error pulled up 3 results, all 3 of which being the source code from ld that prints that error!
JamesM