-finstrument-functions flags

Markus Kreidl markus.kreidl@gmail.com
Fri Mar 13 18:19:11 GMT 2020


Hi,

I am trying to record glibc calls and thought naively of compiling glibc with
-finstrument-functions flags and use __cyg_profile_func_{enter,exit} functions

../configure CFLAGS="-O3 -finstrument-functions" --prefix=some_path

Some function gave me a compilation error and I added to 3 functions:

__attribute__((__no_instrument_function__))

At the end I got:

gcc   -nostdlib -nostartfiles -r -o
/home/markus/work_ot/c_analysis/glibc/build/   elf/librtld.map.o
-Wl,--defsym='__stack_chk_fail=0' -Wl,--
defsym='__stack_chk_fail_local=0' \
    '-Wl,-(' /home/markus/work_ot/c_analysis/glibc/build/elf/dl-allobjs.os
/home/  markus/work_ot/c_analysis/glibc/build/libc_pic.a -lgcc
'-Wl,-)' -Wl,-Map,/home/
markus/work_ot/c_analysis/glibc/build/elf/librtld.mapT
/usr/bin/ld: /home/markus/work_ot/c_analysis/glibc/build/libc_pic.a(dl-error.os):
 in function `__GI__dl_signal_exception':
dl-error.c:(.text+0xd0): multiple definition of
`_dl_signal_exception'; /home/
markus/work_ot/c_analysis/glibc/build/elf/dl-allobjs.os:(.text+0x244c0):
first     defined here

Is there anybody who tried/did the same successfully?

thx!
markus

diff --git a/include/alloc_buffer.h b/include/alloc_buffer.h
index e69ed66c8e..29cf6ed863 100644
--- a/include/alloc_buffer.h
+++ b/include/alloc_buffer.h
@@ -203,6 +203,7 @@ alloc_buffer_alloc_bytes (struct alloc_buffer
*buf, size_t length)
 /* Internal function.  Statically assert that the type size is
    constant and valid.  */
 static __always_inline size_t
+__attribute__((__no_instrument_function__))
 __alloc_buffer_assert_size (size_t size)
 {
   if (!__builtin_constant_p (size))
@@ -221,6 +222,7 @@ __alloc_buffer_assert_size (size_t size)
 /* Internal function.  Statically assert that the type alignment is
    constant and valid.  */
 static __always_inline size_t
+__attribute__((__no_instrument_function__))
 __alloc_buffer_assert_align (size_t align)
 {
   if (!__builtin_constant_p (align))
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 95dc87519b..63282028db 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -715,6 +715,7 @@ extern void _dl_dprintf (int fd, const char *fmt, ...)
 #else
 __attribute__ ((always_inline, __format__ (__printf__, 2, 3)))
 static inline void
+__attribute__((__no_instrument_function__))
 _dl_dprintf (int fd, const char *fmt, ...)
 {
   /* Use local declaration to avoid includign <stdio.h>.  */
diff --git a/sysdeps/unix/sysv/linux/x86/hle.h
b/sysdeps/unix/sysv/linux/x86/hle.h
index 4a7b9e3bf7..7d1ff8ded3 100644
--- a/sysdeps/unix/sysv/linux/x86/hle.h
+++ b/sysdeps/unix/sysv/linux/x86/hle.h
@@ -59,8 +59,10 @@ static __force_inline void _xend(void)
   asm volatile (".byte 0x0f,0x01,0xd5" ::: "memory");
 }

-static __force_inline void _xabort(const unsigned int status)
+static __force_inline void  \
+__attribute__((__no_instrument_function__)) _xabort(const unsigned int status)
 {
+
   asm volatile (".byte 0xc6,0xf8,%P0" :: "i" (status) : "memory");
 }


More information about the Libc-help mailing list