From: Nicholas Nethercote Date: Sun, 28 Sep 2003 18:18:47 +0000 (+0000) Subject: Fixed the static-link check at startup -- it was broken for scripts. Refine X-Git-Tag: svn/VALGRIND_2_1_0~176 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ad476e4c65b62d7cb02bebd25d63e66d602c868c;p=thirdparty%2Fvalgrind.git Fixed the static-link check at startup -- it was broken for scripts. Refine FAQ #5 accordingly. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1854 --- diff --git a/FAQ.txt b/FAQ.txt index b4d9517d2f..e306b209e9 100644 --- a/FAQ.txt +++ b/FAQ.txt @@ -87,18 +87,28 @@ A4. Known issue with RHAS 2.1, due to funny stack permissions at Q5. I try running "valgrind my_program", but my_program runs normally, and Valgrind doesn't emit any output at all. -A5. This should no longer happen, as a check for this takes place - when Valgrind starts up. +A5. Valgrind doesn't work out-of-the-box with programs that are entirely + statically linked. It does a quick test at startup, and if it detects + that the program is statically linked, it aborts with an explanation. + + This test may fail in some obscure cases, eg. if you run a script + under Valgrind and the script interpreter is statically linked. - However, Valgrind still doesn't work with programs that are entirely - statically linked. If you still want static linking, you can ask - gcc to link certain libraries statically. Try the following options: + If you still want static linking, you can ask gcc to link certain + libraries statically. Try the following options: -Wl,-Bstatic -lmyLibrary1 -lotherLibrary -Wl,-Bdynamic Just make sure you end with -Wl,-Bdynamic so that libc is dynamically linked. + If you absolutely cannot use dynamic libraries, you can try statically + linking together all the .o files in coregrind/, all the .o files of the + skin of your choice (eg. those in memcheck/), and the .o files of your + program. You'll end up with a statically linked binary that runs + permanently under Valgrind's control. Note that we haven't tested this + procedure thoroughly. + ----------------------------------------------------------------- Q6. I try running "valgrind my_program" and get Valgrind's startup message, diff --git a/coregrind/valgrind.in b/coregrind/valgrind.in index d8edc05c3a..789bc3f703 100755 --- a/coregrind/valgrind.in +++ b/coregrind/valgrind.in @@ -113,8 +113,8 @@ fi # Ensure the program isn't statically linked. if [ $# != 0 ] ; then which_prog="`which $1`" - case `ldd "$which_prog"` in - *"not a dynamic executable"*) + case `file "$which_prog"` in + *"statically linked"*) echo "\`$which_prog' is statically linked" echo "Valgrind only works on dynamically linked executables; your" echo "program must rely on at least one shared object for Valgrind"