Building glibc with -finstrument-functions

Bogdan Harjoc harjoc@gmail.com
Fri Aug 25 13:16:00 GMT 2017


I'm trying to log the calls made by an app prior to a crash, including
libc calls. I've used the -finstrument-functions support in gcc with
my own libs but I can't build glibc with this instrumentation (I tried
with glibc 2.26 and 2.19, and gcc 6.3 and 5.4).

I added -finstrument-functions to libc_extra_cflags in 'configure' but
the build fails with "undefined reference to __libc_multiple_libcs"
and "multiple definition of _dl_signal_error" when linking
libc_pic.os. Building works fine without the instrumentation flags.

(running "CFLAGS=-finstrument-functions ./configure" doesn't work
because the configure tests fail since they don't define
__cyg_profile_func_enter/_exit).

I'm currently trying to figure out how to add instrumentation per
module (stdlib, io, string, etc) and looking through
libc/foo/Makefile's, it should be possible using e.g. CFLAGS_stdlib =
-finstrument-functions but the flag doesn't show up in gcc commands.

Is there a way to add per-module flags to the glibc build, or is glibc
known not to work with -finstrument-functions ?

Thanks,
Bogdan



More information about the Libc-help mailing list