1、DT_HASH
ELF 中的一个 Sections,保存了一个用于查找符号的散列表,用于支持符号表的访问,能够提高符号搜索速度。
2、--hash-style=style(
以下解释摘自 man ld)
Set the type of linker's hash table(s). style can be either "sysv" for classic ELF ".hash" section, "gnu" for new style GNU ".gnu.hash" section or "both" for both the classic ELF ".hash" and new style GNU ".gnu.hash" hash tables. The default is "sysv".
总的来说
--hash-style=style
参数有三种配置:sysv
、gnu
和both
,废话不多说,先试一把。
gcc -Wl,--hash-style=sysv
$ readelf -S libxxx.so | grep "hash"
[ 4] .hash HASH 0000000000003120 00003120
gcc -Wl,--hash-style=gnu
$ readelf -S libxxx.so | grep "hash"
[ 4] .gnu.hash GNU_HASH 0000000000003120 00003120
gcc -Wl,--hash-style=both
$ readelf -S libxxx.so | grep "hash"
[ 4] .gnu.hash GNU_HASH 0000000000003120 00003120
[ 5] .hash HASH 00000000000035f8 000035f8
(SAW:Game Over!)