Valgrind – dynamic code analysis tool – part VII – ERROR: ld.so: object ‘/dev/shm/valgrind/lib/valgrind/vgpreload_core-amd64-linux.so’ from LD_PRELOAD cannot be preloaded: ignored.

Recently encountered a ld error when starting 64-bit valgrind (3.7.0) for 64-bit binary. This is a bug in 3.7.0 and the fix will be submitted into 3.8.0. Detailed info could be found via (https://bugs.kde.org/show_bug.cgi?id=286270). As always, we could either checkout the latest SVN trunk which has already contained the fix or use ‘diff -u’ and ‘patch -p0’ to make the current code look good.

<tat09-s00c05h0:root>/dev/shm/valgrind/bin:
# ./valgrind –tool=helgrind –log-file=./helgrind.out /tmp/valgrind/dfed.elf –iomn 294921
ERROR: ld.so: object ‘/dev/shm/valgrind/lib/valgrind/vgpreload_core-amd64-linux.so’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/dev/shm/valgrind/lib/valgrind/vgpreload_helgrind-amd64-linux.so’ from LD_PRELOAD cannot be preloaded: ignored.

/home/daveti/dfed/concurrency: cat valgrind-3.7.0.daveti.linux_x86.diff
— valgrind-3.7.0/coregrind/m_libcproc.c.orig  2012-08-02 20:51:03.842835647 -0500
+++ valgrind-3.7.0/coregrind/m_libcproc.c       2012-08-03 01:00:03.721101101 -0500
@@ -240,12 +240,18 @@
    // – LD_PRELOAD is on Linux, not on Darwin, not sure about AIX
    // – DYLD_INSERT_LIBRARIES and DYLD_SHARED_REGION are Darwin-only
    for (i = 0; envp[i] != NULL; i++) {
–      if (VG_(strncmp)(envp[i], “LD_PRELOAD=”, 11) == 0)
–         ld_preload_str = VG_(arena_strdup)(VG_AR_CORE, “libcproc.erves.1”, &envp[i][11]);
–      if (VG_(strncmp)(envp[i], “LD_LIBRARY_PATH=”, 16) == 0)
–         ld_library_path_str = VG_(arena_strdup)(VG_AR_CORE, “libcproc.erves.2”, &envp[i][16]);
–      if (VG_(strncmp)(envp[i], “DYLD_INSERT_LIBRARIES=”, 22) == 0)
–         dyld_insert_libraries_str = VG_(arena_strdup)(VG_AR_CORE, “libcproc.erves.3”, &envp[i][22]);
+      if (VG_(strncmp)(envp[i], “LD_PRELOAD=”, 11) == 0) {
+         envp[i] = VG_(arena_strdup)(VG_AR_CORE, “libcproc.erves.1”, envp[i]);
+         ld_preload_str = &envp[i][11];
+      }
+      if (VG_(strncmp)(envp[i], “LD_LIBRARY_PATH=”, 16) == 0) {
+         envp[i] = VG_(arena_strdup)(VG_AR_CORE, “libcproc.erves.2”, envp[i]);
+         ld_library_path_str = &envp[i][16];
+      }
+      if (VG_(strncmp)(envp[i], “DYLD_INSERT_LIBRARIES=”, 22) == 0) {
+         envp[i] = VG_(arena_strdup)(VG_AR_CORE, “libcproc.erves.3”, envp[i]);
+         dyld_insert_libraries_str = &envp[i][22];
+      }
    }

    buf = VG_(arena_malloc)(VG_AR_CORE, “libcproc.erves.4”,
/home/daveti/dfed/concurrency:

About daveti

Interested in kernel hacking, compilers, machine learning and guitars.
This entry was posted in Static Code Analysis and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s