shared library loading

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
User avatar
Shaun
Member
Member
Posts: 43
Joined: Mon Sep 17, 2012 3:14 am
Contact:

shared library loading

Post by Shaun »

hi, guys!

i wanna add elf shared library support to my os. but i found it is really a tough work.
as far as i can know,in kernel space, i should load a .so file called interpreter(in linux, it is ld-linux.so.2) first if i want to load a dynamic linked app. and the problem is:

1,in kernel space, i should build a auxiliary vector that is used by interpreter on app's stack and then call the interpreter's entry point. i wanna know how to build this vector,and what is needed i should supply to interpreter?
i do a little homework looking up linux kernel source code, the create_elf_tables() does these stuff, but it is hard to comprehension. hope someone can give me more details. Spec is also ok.

2,for the interpreter, do i must implement it by my self? can i port some existing ones? glibc contains a shared library loader, uclibc also does, but they all for linux platform, and it's hard to porting. any one has good ideas?


thanks.
User avatar
max
Member
Member
Posts: 616
Joined: Mon Mar 05, 2012 11:23 am
Libera.chat IRC: maxdev
Location: Germany
Contact:

Re: shared library loading

Post by max »

Hey Shaun :)

I have not done dynamic linking yet, so I can only tell you about some resource I found that might help you. Theres this wiki page about dynamic linking and here is some information on the interpreter.

As far as I can tell you'll have to write your own interpreter binary, because it's specific to your OS (has to lookup the binaries of the searched libraries). Your system design could be entirely different and require different steps for loading the binaries etc.

Greets, Max
User avatar
Shaun
Member
Member
Posts: 43
Joined: Mon Sep 17, 2012 3:14 am
Contact:

Re: shared library loading

Post by Shaun »

@max
I have not done dynamic linking yet, so I can only tell you about some resource I found that might help you. Theres this wiki page about dynamic linking and here is some information on the interpreter.
great thanks for your effort.
As far as I can tell you'll have to write your own interpreter binary, because it's specific to your OS (has to lookup the binaries of the searched libraries). Your system design could be entirely different and require different steps for loading the binaries etc.
OH,god! it's really a bad news to me. :cry:

i think i have met another long long way to go.
martinFTW
Posts: 15
Joined: Sun Jun 08, 2014 10:39 am
Contact:

Re: shared library loading

Post by martinFTW »

Shaun wrote:@max
I have not done dynamic linking yet, so I can only tell you about some resource I found that might help you. Theres this wiki page about dynamic linking and here is some information on the interpreter.
great thanks for your effort.
As far as I can tell you'll have to write your own interpreter binary, because it's specific to your OS (has to lookup the binaries of the searched libraries). Your system design could be entirely different and require different steps for loading the binaries etc.
OH,god! it's really a bad news to me. :cry:

i think i have met another long long way to go.
Writing a shared library loader is no big thing. Of course it is probably complicated to generate and write ld.so as shared static lib, but who forces you to do that, I implemented it as a static library which was quite easy (look here: https://github.com/MartinErhardt/Lizarx ... /ld_a/ld.c). The coding style is horrific no comments redundancy in resolve references, also it is not a complete support only I386/X86_64_GLOB_DATA and I386/X86_64_JMP_SLOT bindings, but for me it works(I currently write a ramfs as shared lib)
Post Reply