]> git.ipfire.org Git - thirdparty/valgrind.git/commit
Clobber ecx for clang x86 leak tests
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 19 May 2022 20:40:03 +0000 (22:40 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 19 May 2022 20:40:03 +0000 (22:40 +0200)
commit98774bffd21bdeb0e4f2903b8df9083fd93c243d
tree5d9d19ee62de8be2633eefbd4ef83cdfd31cfee8
parentc10e4e864fe98b77f946bbfc6547d5e27d982590
Clobber ecx for clang x86 leak tests

The assembler for leak-cases.c on x86 with clang for f() ends with

  40198b:       c7 04 24 00 00 00 00    movl   $0x0,(%esp)
  401992:       e8 c9 fe ff ff          call   401860 <mk>
  401997:       89 04 24                mov    %eax,(%esp)
  40199a:       e8 c1 fe ff ff          call   401860 <mk>
  40199f:       a3 74 40 40 00          mov    %eax,0x404074
  4019a4:       a1 74 40 40 00          mov    0x404074,%eax
  4019a9:       8b 08                   mov    (%eax),%ecx
  4019ab:       83 c1 08                add    $0x8,%ecx
  4019ae:       89 08                   mov    %ecx,(%eax)
  4019b0:       c7 05 74 40 40 00 00    movl   $0x0,0x404074
  4019b7:       00 00 00
  4019ba:       83 c4 04                add    $0x4,%esp
  4019bd:       5d                      pop    %ebp
  4019be:       c3                      ret

If I've read that correctly, at the enc ECX contains the pointer
to allocated memory returned by mk() plus 8.

main() doesn't clobber ECX either, so this shows up in the
leak checks.

Clobbering ECX fixes the following testcases on FreeBSD 13.1 x86 with clang 13

< gdbserver_tests/mcblocklistsearch        (stderrB)
< memcheck/tests/leak-cases-full           (stderr)
< memcheck/tests/leak-cases-summary        (stderr)
< memcheck/tests/leak-cycle                (stderr)
< memcheck/tests/leak-tree                 (stderr)
< memcheck/tests/lks                       (stderr)
memcheck/tests/leak.h