Instrumenting function calls in xine-lib breaks linking

Malte Forkel <[email protected]> Mon, 03 Sep 2012 15:11:07 +0200
Newsgroups gmane.comp.video.xine.user
Message-ID <[email protected]>
Hi,

I'm trying to trace function calls in xine-lib-1.2 by specifying the GCC
option -finstrument-functions and using a small library that implements
the __cyg_profile_func_* functions. Unfortenately, I can't manage to
link xine-lib with this compiler option.

First, I added the following configuration option to configure.ac:

AC_ARG_ENABLE([tracing],
              [AS_HELP_STRING([--enable-tracing],
              [build with instrumentation for tracing])],
              [], [enable_tracing="no"])
if test x"$enable_tracing" != x"no"; then
    #CFLAGS="-finstrument-functions $CFLAGS"
    CPPFLAGS="-DXINE_INSTRUMENT_FUNCTIONS $CPPFLAGS"
    #OBJCFLAGS="-finstrument-functions $OBJCFLAGS"
fi
AM_CONDITIONAL([TRACING_BUILD], [test x"$enable_tracing" != x"no"])

But when I specified --enable-tracing, I got a linker error:

...
  CCLD   libxine-interface.la
libtool: link: warning: `-version-info/-version-number' is ignored for
convenience libraries
  CCLD   libxine.la
/usr/bin/ld: .libs/libxine_la-xine.o: relocation R_386_GOTOFF against
protected function `_x_reset_relaxed_frame_drop_mode' can not be used
when making a shared object
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[3]: *** [libxine.la] Error 1
make[3]: Leaving directory `/tmp/buildd/xine-lib-1.2-1.2.2/src/xine-engine'
make[2]: *** [../src/xine-engine/libxine.la] Error 2
make[2]: Leaving directory `/tmp/buildd/xine-lib-1.2-1.2.2/misc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/buildd/xine-lib-1.2-1.2.2'
make: *** [build-stamp] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
E: Failed autobuilding of package

I then tried to disable the function attribute "protected" by modifying
include/xine/attribute.h (line breaks added for this message):

 /* Export protected only for libxine functions */
#if defined(XINE_LIBRARY_COMPILE) \
    && defined(SUPPORT_ATTRIBUTE_VISIBILITY_PROTECTED) \
    && !defined(XINE_INSTRUMENT_FUNCTIONS)
# define XINE_PROTECTED __attribute__((__visibility__("protected")))
#elif defined(XINE_LIBRARY_COMPILE) \
      && defined(SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT)
# define XINE_PROTECTED __attribute__((__visibility__("default")))
#else
# define XINE_PROTECTED
#endif

But this broke linking, too:

...
  CCLD   libxine.la
make[3]: Leaving directory `/tmp/buildd/xine-lib-1.2-1.2.2/src/xine-engine'
  CCLD   xine-list-1.2
xine-list.o: In function `main':
/tmp/buildd/xine-lib-1.2-1.2.2/misc/xine-list.c:109: undefined reference
to `xine_new'
/tmp/buildd/xine-lib-1.2-1.2.2/misc/xine-list.c:113: undefined reference
to `xine_get_version'
/tmp/buildd/xine-lib-1.2-1.2.2/misc/xine-list.c:120: undefined reference
to `xine_init'
/tmp/buildd/xine-lib-1.2-1.2.2/misc/xine-list.c:128: undefined reference
to `xine_get_mime_types'
/tmp/buildd/xine-lib-1.2-1.2.2/misc/xine-list.c:79: undefined reference
to `xine_get_version_string'
/tmp/buildd/xine-lib-1.2-1.2.2/misc/xine-list.c:91: undefined reference
to `xine_get_version_string'
/tmp/buildd/xine-lib-1.2-1.2.2/misc/xine-list.c:145: undefined reference
to `xine_get_file_extensions'
collect2: ld returned 1 exit status
make[2]: *** [xine-list-1.2] Error 1
make[2]: Leaving directory `/tmp/buildd/xine-lib-1.2-1.2.2/misc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/buildd/xine-lib-1.2-1.2.2'
make: *** [build-stamp] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
E: Failed autobuilding of package

Environment: Debian Squeeze, GCC 4.4.5, libc 2.11.3.

Any advice?

Thanks in advance,
Malte


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/