Page 1 of 1

elf object files with hash and w/o dynamic section

Posted: Fri Nov 06, 2009 5:11 am
by FlashBurn
As the topic tells you, I want to know if it is possible to have the hash table for static symbols in an elf object file w/o a dynamic section.

I want to speed up my loader and because I link my kernel at run time it would be faster if I could use a hash table for the symbols.

Re: elf object files with hash and w/o dynamic section

Posted: Fri Nov 06, 2009 6:51 am
by JamesM
Not AFAIK. The hashtable is intended to speed up the userspace dynamic linker, kernels weren't really thought of!

What I do is to read the static symbol table into a structure, then use that structure for lookups instead of the linear search through the static symtab. The structure I use is a Patricia Trie (also called a radix tree) - which gives O(k) access times where k is the length of the key you're looking for.

You could construct your own hashtable in kernel-land, or even run a script to preprocess the object files, creating a hashtable and objcopying it into a new section, which your kernel reads. In fact, the possibilities are endless :-)

Re: elf object files with hash and w/o dynamic section

Posted: Fri Nov 06, 2009 6:54 am
by FlashBurn
Ok, I like the idea to create the hashtable of my own and insert it into the object file. My question is now how do I do this? I mean how do I create a new section in my object files and insert my hashtable? Is there a utility I can use or have I to write my own?

Re: elf object files with hash and w/o dynamic section

Posted: Fri Nov 06, 2009 8:17 am
by JamesM
JamesM wrote:and objcopying it