if your labels are very long (and especially if they're organized in a namespace_subspace_method way), you may want to group them by namespace, e.g. rather than having a flat list, you'd have a "tree" structure where all symbols with e.g. paging_* would be under a "paging" node.
That'd mean if you're looking (in a module) for "paging_create_table", you'd first look for "paging" in the top-level list, then for "create" in the "paging_*" list, and finally for "table" in "paging_create_*" list.
That will most likely shorten your searching time (shorter strings to compare) and might also reduce memory footprint (if you have enough symbols sharing the same prefix so that the cost for the prefix entry is "ammortized").
The problem with hashes is that it wouldn?t be easy (if it is possible) to do this in the compiler (fasm)
You're not forced to do them in the compiler proper: just have an additional tool that scan your sources, hash the symbols and produce the exporthashtable.asm that you'll later compile and link against the rest
I use the elf format, but not for the kernel (for modules and programs)
Maybe i underestimate your compiling sequence, but if you're just using -oformat binary, nothing should prevent you to create a big kernel.elf, grab symbols from there and _then_ objcopy the kernel.elf to kernel.bin ...
Or maybe you may want macros that define the symbol locally, but also add the "symbol table entry" in a specific section (that's the advantage of using asm: you'll have a better control over sections) so that they end up as a table when compilation is over.
e.g.
Code: Select all
#macro kexport(symbol)
.section ksymnames
kst_##symbol
db #stringify(symbol),0
.section ksymtab
dd symbol
dd kst_##symbol
.section text
symbol:
#endmacro
where i suppose symbol1##symbol2 creates a concatened symbol name on your assembler's preprocessor and that #stringify(xyz) is preprocessed into 'xyz'.
If that's not possible, we're in trouble here and the 'macro' trick cannot be used.
Btw, trust me when i say that, with >40 symbols in your kernel, maintaining a symbol table by hand is a nightmare (not even talking about typos, etc.)