3 ms·
ELF: Better Symbol Lookup via Dt_gnu_hash (2017)
- loeg 6y ago(2017) (And the format dates to much, much earlier — but still interesting material if you like this kind of thing.) > The problem with it is that DT_GNU_HASH is not documented anywhere other than in GNU binutils and glibc source code. Not really documentation either, but it is of course also implemented in LLVM and e.g., FreeBSD rtld.
- dividuum 6y agoThis might be a stupid question, but why don't they construct a perfect hash (like gperf, etc) at build time?
- Someone 6y agoWouldn’t that mean having distinct hashes for every library? If so, that means you would have to, somehow, serialize the hash function inside each library and provide an efficient way to compute hashes. It also would mean having to hash each function name multiple times during linking (once for each library searched until you got a hit) Also, I think you would have to change the hash function (almost) every time a symbol is added to a library, but that isn’t a show stopper. In the end, the linker will compare strings, anyways.
- dividuum 6y agoThanks for you response. It would mean that, but if I understand the code at https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-lookup.c;h=3d2369dbf2b7ca219eaf80a820e2a8e1329fbf50;hb=HEAD#l364 https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-look... correctly, linear search through all mapped libraries happens already.
- JoshTriplett 6y agoI don't know the original reason, but that would substantially increase linking time, and wouldn't be simple to aggregate from multiple objects. It might be a good idea if you're already taking time to do things like LTO, though.
- deleted 6y ago[deleted]
- londons_explore 6y agoIf this is so great, why isn't it the default?