dr_get_proc_address incorrectly returns base-of-library results for undefined symbols with gnu hashes
I saw this on drcachesim's -record_heap running "ls" where it claims to find "malloc" and "free" in the ls binary but returns an address at the very base of the binary:
instru_funcs_module_load for ls
dr_get_proc_address found symbol malloc at pc=0x00007f0cfda4c000
Inserted hooks for ls!malloc @0x00007f0cfda4c000 == id 0
dr_get_proc_address found symbol free at pc=0x00007f0cfda4c000
Duplicate-pc hook: ls!free == id 0
Looks like DR is not ruling out undefined symbols:
$ readelf -s -D /bin/ls
Symbol table of `.gnu.hash' for image:
Num Buc: Value Size Type Bind Vis Ndx Name
111 0: 0000000000022600 8 OBJECT GLOBAL DEFAULT 26 __progname
112 2: 0000000000022610 4 OBJECT GLOBAL DEFAULT 26 optind
113 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND free
114 3: 0000000000022620 8 OBJECT WEAK DEFAULT 26 program_invocation_name
115 4: 0000000000022620 8 OBJECT GLOBAL DEFAULT 26 __progname_full
116 5: 00000000000163a0 41 FUNC GLOBAL DEFAULT 14 _obstack_memory_used
117 6: 00000000000225e0 8 OBJECT GLOBAL DEFAULT 25 obstack_alloc_failed_hand
118 6: 00000000000161b0 17 FUNC GLOBAL DEFAULT 14 _obstack_begin
119 7: 0000000000022640 8 OBJECT GLOBAL DEFAULT 26 stderr
120 8: 0000000000016330 101 FUNC GLOBAL DEFAULT 14 _obstack_free
121 8: 0000000000022600 8 OBJECT WEAK DEFAULT 26 program_invocation_short_
122 10: 00000000000162f0 55 FUNC GLOBAL DEFAULT 14 _obstack_allocated_p
123 10: 0000000000022618 8 OBJECT GLOBAL DEFAULT 26 optarg
124 11: 00000000000161d0 21 FUNC GLOBAL DEFAULT 14 _obstack_begin_1
125 12: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize
126 14: 00000000000161f0 251 FUNC GLOBAL DEFAULT 14 _obstack_newchunk
127 15: 0000000000000000 0 FUNC GLOBAL DEFAULT UND malloc
128 16: 0000000000022608 8 OBJECT GLOBAL DEFAULT 26 stdout
Looking at the code, DR does the right thing for non-gnu hash lookups, but not for gnu.