Hi,
I've now managed to make a proper patch. I've used 'v2' for more clarity. I'll send the files used to test them in a subsequent mails. As for the tests, I've done them in Guix system, once installed valgrind works fine: > $ make check > valgrind -v --leak-check=full ./main > ==20324== Memcheck, a memory error detector > ==20324== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. > ==20324== Using Valgrind-3.18.1-42b08ed5bd-20211015 and LibVEX; rerun with -h > for copyright info > ==20324== Command: ./main > ==20324== > --20324-- Valgrind options: > --20324-- -v > --20324-- --leak-check=full > --20324-- Contents of /proc/version: > --20324-- Linux version 5.16.20-gnu (guix@guix) (gcc (GCC) 10.3.0, GNU ld > (GNU Binutils) 2.37) #1 SMP PREEMPT 1 > --20324-- > --20324-- Arch and hwcaps: X86, LittleEndian, x86-mmxext-sse1-sse2-sse3 > --20324-- Page sizes: currently 4096, max supported 4096 > --20324-- Valgrind library directory: > /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind > --20324-- Reading syms from > /gnu/store/0iapawfss4xnxls622g23qpk4mwb9ihp-glibc-2.33/lib/ld-2.33.so > --20324-- Considering > /gnu/store/wznq4d1i3znqjhcribfr2m9ljyyrsdyd-glibc-2.33-debug/lib/debug/gnu/store/0iapawfss4xnxls622g23qpk4mwb9ihp-glibc-2.33/lib/ld-2.33.so.debug > .. > --20324-- .. CRC is valid > --20324-- Reading syms from /home/gnutoo/work/projects/guix/valgrind-test/main > --20324-- Reading syms from > /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/memcheck-x86-linux > --20324-- object doesn't have a symbol table > --20324-- object doesn't have a dynamic symbol table > --20324-- Scheduler: using generic scheduler lock implementation. > --20324-- Reading suppressions file: > /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/default.supp > ==20324== embedded gdbserver: reading from > /tmp/vgdb-pipe-from-vgdb-to-20324-by-gnutoo-on-??? > ==20324== embedded gdbserver: writing to > /tmp/vgdb-pipe-to-vgdb-from-20324-by-gnutoo-on-??? > ==20324== embedded gdbserver: shared mem > /tmp/vgdb-pipe-shared-mem-vgdb-20324-by-gnutoo-on-??? > ==20324== > ==20324== TO CONTROL THIS PROCESS USING vgdb (which you probably > ==20324== don't want to do, unless you know exactly what you're doing, > ==20324== or are doing some strange experiment): > ==20324== > /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/../../bin/vgdb > --pid=20324 ...command... > ==20324== > ==20324== TO DEBUG THIS PROCESS USING GDB: start GDB like this > ==20324== /path/to/gdb ./main > ==20324== and then give GDB the following command > ==20324== target remote | > /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/../../bin/vgdb > --pid=20324 > ==20324== --pid is optional if only one valgrind process is running > ==20324== > --20324-- REDIR: 0x4021570 (ld-linux.so.2:strlen) redirected to 0x580a1f4a > (???) > --20324-- REDIR: 0x40212d0 (ld-linux.so.2:index) redirected to 0x580a1f25 > (???) > --20324-- Reading syms from > /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/vgpreload_core-x86-linux.so > --20324-- object doesn't have a symbol table > --20324-- Reading syms from > /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/vgpreload_memcheck-x86-linux.so > --20324-- object doesn't have a symbol table > ==20324== WARNING: new redirection conflicts with existing -- ignoring it > --20324-- old: 0x04021570 (strlen ) R-> (0000.0) 0x580a1f4a > ??? > --20324-- new: 0x04021570 (strlen ) R-> (2007.0) 0x04043ca0 > strlen > --20324-- Reading syms from > /gnu/store/r7n4snily34ld9nm4crzc0z65jr2y26c-gcc-10.3.0-lib/lib/libgcc_s.so.1 > --20324-- object doesn't have a symbol table > --20324-- Reading syms from > /gnu/store/0iapawfss4xnxls622g23qpk4mwb9ihp-glibc-2.33/lib/libc-2.33.so > --20324-- Considering > /gnu/store/wznq4d1i3znqjhcribfr2m9ljyyrsdyd-glibc-2.33-debug/lib/debug/gnu/store/0iapawfss4xnxls622g23qpk4mwb9ihp-glibc-2.33/lib/libc-2.33.so.debug > .. > --20324-- .. CRC is valid > ==20324== WARNING: new redirection conflicts with existing -- ignoring it > --20324-- old: 0x040f08c0 (memalign ) R-> (1011.0) 0x04043084 > memalign > --20324-- new: 0x040f08c0 (memalign ) R-> (1017.0) 0x0404303d > aligned_alloc > ==20324== WARNING: new redirection conflicts with existing -- ignoring it > --20324-- old: 0x040f08c0 (memalign ) R-> (1011.0) 0x04043084 > memalign > --20324-- new: 0x040f08c0 (memalign ) R-> (1017.0) 0x04042ff6 > aligned_alloc > ==20324== WARNING: new redirection conflicts with existing -- ignoring it > --20324-- old: 0x040f08c0 (memalign ) R-> (1011.0) 0x04043084 > memalign > --20324-- new: 0x040f08c0 (memalign ) R-> (1017.0) 0x0404303d > aligned_alloc > ==20324== WARNING: new redirection conflicts with existing -- ignoring it > --20324-- old: 0x040f08c0 (memalign ) R-> (1011.0) 0x04043084 > memalign > --20324-- new: 0x040f08c0 (memalign ) R-> (1017.0) 0x04042ff6 > aligned_alloc > --20324-- REDIR: 0x40f49e0 (libc.so.6:strncasecmp) redirected to 0x40351e6 > (_vgnU_ifunc_wrapper) > --20324-- REDIR: 0x40fa870 (libc.so.6:memrchr) redirected to 0x40351e6 > (_vgnU_ifunc_wrapper) > --20324-- REDIR: 0x410df30 (libc.so.6:wcslen) redirected to 0x40351e6 > (_vgnU_ifunc_wrapper) > --20324-- REDIR: 0x410d5c0 (libc.so.6:__GI_strrchr) redirected to 0x4043730 > (__GI_strrchr) > --20324-- REDIR: 0x410da60 (libc.so.6:__GI_strlen) redirected to 0x4043c20 > (__GI_strlen) > --20324-- REDIR: 0x40efb60 (libc.so.6:malloc) redirected to 0x403e5ae (malloc) > Hello world > --20324-- REDIR: 0x40f0190 (libc.so.6:free) redirected to 0x40409fc (free) > ==20324== > ==20324== HEAP SUMMARY: > ==20324== in use at exit: 0 bytes in 0 blocks > ==20324== total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated > ==20324== > ==20324== All heap blocks were freed -- no leaks are possible > ==20324== > ==20324== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 5 from 5) > --20324-- > --20324-- used_suppression: 5 dl-hack3-cond-1 > /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/default.supp:1232 > ==20324== > ==20324== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 5 from 5) In addition it also works fine with either valgrind/interactive or valgrind-3.18 as dependency, when it is used in the tests of a package. I've used the 'make && ./pre-inst-env guix build -f libsamsung-ipc.scm' command for that (with a libsamsung-ipc.scm that is slightly modified since last time). Denis.