|
From: Ivo R. <iv...@iv...> - 2014-06-18 04:23:23
|
Hello, I wonder what it would take to intercept a static (local) function of an ELF object instrumented and running under valgrind. If that function was global, then it would be easy via preload mechanism. But what to do when the function is local? I cannot make this function global - that is currently beyond my control. Function is part of a shared library in ELF format which gets loaded by runtime linker (ld.so). I know the function name, library name and its SONAME. I also know the function's callers, although they are mixture of public and local (static) functions. Thanks for any pointers, I. |
|
From: Josef W. <Jos...@gm...> - 2014-06-18 14:38:10
|
Am 18.06.2014 06:23, schrieb Ivo Raisr: > Hello, > I wonder what it would take to intercept a static (local) function > of an ELF object instrumented and running under valgrind. As long as it is found in the symbol table, it should be possible to use Valgrinds redirection functionality, see http://valgrind.org/docs/manual/manual-core-adv.html Example: ========================== #include <stdio.h> #include <valgrind/valgrind.h> char* I_WRAP_SONAME_FNNAME_ZZ(NONE,fooZa)(int x) { return "bar"; } __attribute__ ((noinline)) static char* foo(int i) { return "foo"; } main() { printf("Hi %s\n", foo(42)); } =============================== No need to write a Valgrind tool: > make t cc t.c -o t > ./t Hi foo > valgrind --tool=none ./t ==11430== Nulgrind, the minimal Valgrind tool ==11430== Copyright (C) 2002-2013, and GNU GPL'd, by Nicholas Nethercote. ==11430== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info ==11430== Command: ./t ==11430== Hi bar Josef > > If that function was global, then it would be easy via preload > mechanism. But what to do when the function is local? > I cannot make this function global - that is currently beyond > my control. Function is part of a shared library in ELF format > which gets loaded by runtime linker (ld.so). > I know the function name, library name and its SONAME. > I also know the function's callers, although they are > mixture of public and local (static) functions. > > Thanks for any pointers, > I. > > ------------------------------------------------------------------------------ > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > Find What Matters Most in Your Big Data with HPCC Systems > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > http://p.sf.net/sfu/hpccsystems > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers > |
|
From: Ivo R. <iv...@iv...> - 2014-06-18 20:17:46
|
2014-06-18 16:37 GMT+02:00 Josef Weidendorfer <Jos...@gm...>: > Am 18.06.2014 06:23, schrieb Ivo Raisr: >> I wonder what it would take to intercept a static (local) function >> of an ELF object instrumented and running under valgrind. > > As long as it is found in the symbol table, it should be possible to use > Valgrinds redirection functionality, see > http://valgrind.org/docs/manual/manual-core-adv.html Thank you, Josef! This feature perfectly suits my purposes. Kind regards, I. |