Anton Bikineev Tuesday, April 25, 2017 4:24 PM
Nice article and good practical introduction, thanks.
It's a shame that neither C Standard nor C++ defines default symbol visibility. Things get even worse when it comes to OS specific default policies. For example in Windows for symbol to become visible one should explicitly mark it with __declspec(public) whereas in Linux all symbols are visible by default (not taking -fvisibility=hidden into account). This substantially degrades load times, binary size and symbol lookup.
flapenguin Friday, April 28, 2017 4:22 PM
Thanks for your comment.
Symbol visibility is an interesting topic. I think the reason why standard lacks support of it is because it's the linker who needs to know about symbol visibility. Linker should be able to link your C, C++, Asm and Rust shared libraries. So it's not only about adding keyword for visibility in C/C++, but also about specifying how linker should work with it, which potentially leads to specifying object and shared library formats and their capabilities. And that's what committee is avoiding as hard as they can.
Correct me if I'm wrong.
BTW, internal linkage is effectively the same thing as hidden symbols, so there's at least one standard way to specify symbol visibility: by using static functions. But that surely doesn't help if you have multiple object files.
Rajkumar Ramasamy Tuesday, September 12, 2017 10:34 AM
Firstly, thanks for explaining this with a great example. :)
I have been working through the example you have provided. While constructing the hash table, I am seeing the following.
elf_hash(pthread_mutex_lock) % nbucket = 0x0de6a18b % 4 = 3.
But bucket = 4, which is a collision, so I want to use chain.
Since chain is not used so far, wont chain = 6, instead?
I see in the example you have mentioned chain = 0.
Can you clarify this?
I never answered this in Disqus, so: chain is not unused, it has 0, which means "end of symbols single linked list for this bucket". Also ix in chain[ix]is the symbol index, so you can't really have different one for pthread_mutex_lock.
I think procedure for walking "getspen" is wrong. The comment says "chain continues at 5" but next line shows lookup in symbols, same goes with next step in chain - comment says we continue at 7 but lookup happens at symbols.