question on glibc interposition

Alexander Monakov amonakov@ispras.ru
Sun Feb 11 16:36:00 GMT 2018


On Sat, 10 Feb 2018, christopher.aoki@oracle.com wrote:

> I have a question on glibc interposition.   Should calls to an
> interposed function (e.g., malloc) from within a shared library
> (e.g., libgfortran.so) bind to the interposing library, as opposed
> to the glibc version?

In general yes. There are exceptions related to dlopen or libc listed
earlier in DT_NEEDED tags (check readelf -d ./tonto*), but that seems
unlikely to be your case.

To investigate your situation, have a look at LD_DEBUG functionality
as documented in 'man ld.so'. You can do something like

  LD_DEBUG_OUTPUT=/tmp/lddbg.txt LD_DEBUG=all ./tonto...

and then peruse the output, or alternatively interactively in gdb like

  gdb --args ./tonto...
  (gdb) set env LD_DEBUG=all
  (gdb) set env LD_BIND_NOT=1
  (gdb) break _gfortran_string_trim
  (gdb) run
  [breakpoint hit]
  (gdb) fin

and after that LD_DEBUG stream between the 'run' and 'fin' commands should
show you how the malloc call was bound.

Hope that helps.
Alexander



More information about the Libc-alpha mailing list