bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gprof questions


From: Robert E. Brown
Subject: gprof questions
Date: Fri, 27 Jul 2001 13:26:57 -0400

On Linux I am trying to profile an application that is normally linked
dynamically.  I am using gcc 2.95.2 and glibc 2.1.3.  My version of ld comes
from binutils 2.10 with some patches applied for better rpath support.


I am having the following problems:

1. At compile time the application is linked with commercial shared objects.
   Do I need to acquire archive (.a) versions of these libraries or can I
   somehow build a profiled application using only the (.so) shared objects.

2. In order to get profiling information for libc functions, I've found it
   necessary to compile as follows:

     gcc -Wl,-Bstatic -pg foo.c -o foo -lc_p

   The need to specify -Bstatic does not seem to be documented in the manual
   for gprof.  Without it, however, my test programs segfaults.

   When my application is built normally without profiling, it uses dlopen
   to dynamically loads dlls as it runs.  To build a statically linked
   version with profiling, I created a C file that pulls from archive (.a)
   files all the libraries that would normally be dynamically loaded at run
   time.  However, because the application is written to dynamically load
   libraries it wants to map strings to function addresses so that it can
   call them.  I originally tried to do implement this need using dlsym:

     char *function_name;

     handle = dlopen((char *) 0, RTLD_NOW);
     function_address = dlsym(handle, function_name);

   Unfortunately, dlsym generates a segfault unless I include the -rdynamic
   switch when linking my profiled application.  This conflicts with the
   need mentioned above to link with -Bstatic.  Are there any workarounds or
   alternatives?

Thanks very much for your assistance.

                        bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]