I have changed an ELF binary, and now I am trying to find out what I messed out.
My instrumented binary is called mutatee_out
on the pasted text below.
The symbol it's saying that is undefined is indeed in the dynamic table, I have checked. And also with the right address on .text
section.
So my question is: what are the reasons for an undefined symbol? (So I can examine what might have been gone wrong).
When I ran with LD_DEBUG=symbols
, I noticed it's not looking up this symbol in the file itself, hence the undefined symbol. The other symbols are looked up on the file as you can see below too.
Any ideas? Why would this symbol not be searched on the binary itself?
17405: symbol=_ZTVSt11regex_error; lookup in file=mutatee_out [0]
17405: symbol=_ZTVSt11regex_error; lookup in file=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0]
17405: symbol=__gxx_personality_v0; lookup in file=mutatee_out [0]
17405: symbol=_ZN9__gnu_cxx27__verbose_terminate_handlerEv; lookup in file=mutatee_out [0]
17405: symbol=_ZN9__gnu_cxx27__verbose_terminate_handlerEv; lookup in file=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0]
17405: symbol=_ZSt9terminatev; lookup in file=mutatee_out [0]
17405: symbol=_ZSt9terminatev; lookup in file=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0]
17405: symbol=__gmon_start__; lookup in file=mutatee_out [0]
17405: symbol=__gmon_start__; lookup in file=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0]
17405: symbol=__gmon_start__; lookup in file=/lib/x86_64-linux-gnu/libgcc_s.so.1 [0]
17405: symbol=__gmon_start__; lookup in file=/lib/x86_64-linux-gnu/libc.so.6 [0]
17405: symbol=__gmon_start__; lookup in file=/lib/x86_64-linux-gnu/libm.so.6 [0]
17405: symbol=__gmon_start__; lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
17405: symbol=__gmon_start__; lookup in file=/lib/x86_64-linux-gnu/libdl.so.2 [0]
17405: symbol=_ZN9decl_test8call_cppEi; lookup in file=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0]
17405: symbol=_ZN9decl_test8call_cppEi; lookup in file=/lib/x86_64-linux-gnu/libgcc_s.so.1 [0]
17405: symbol=_ZN9decl_test8call_cppEi; lookup in file=/lib/x86_64-linux-gnu/libc.so.6 [0]
17405: symbol=_ZN9decl_test8call_cppEi; lookup in file=/lib/x86_64-linux-gnu/libm.so.6 [0]
17405: symbol=_ZN9decl_test8call_cppEi; lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
17405: symbol=_ZN9decl_test8call_cppEi; lookup in file=/lib/x86_64-linux-gnu/libdl.so.2 [0]
17405: mutatee_out: error: symbol lookup error: undefined symbol: _ZN9decl_test8call_cppEi (fatal)
Which parts of the binary did you change? Just .dynsym
? Or .gnu.hash
as well? If the hash table is out of sync, ld.so
will not find some symbols.