gopalshankar / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

Asm instrumentation does not preserve flags #307

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
   0x00007fbddec82e6c <+44>:    sub    $0x80,%rsp
   0x00007fbddec82e73 <+51>:    push   %rdi
   0x00007fbddec82e74 <+52>:    lea    (%rsi),%rdi
   0x00007fbddec82e77 <+55>:    callq  0x7fbddec66380 <__sanitizer_sanitize_store4@plt>
   0x00007fbddec82e7c <+60>:    pop    %rdi
=> 0x00007fbddec82e7d <+61>:    add    $0x80,%rsp

^^^ This instruction clobbers flags.

(gdb) disassemble __sanitizer_sanitize_store4    
Dump of assembler code for function __sanitizer_sanitize_store4:
   0x00000000004a9a48 <+0>:     sub    $0x80,%rsp

^^^ This instruction clobbers flags, too.

   0x00000000004a9a4f <+7>:     push   %rax
   0x00000000004a9a50 <+8>:     push   %rcx
   0x00000000004a9a51 <+9>:     pushfq 

^^^ This pushfq is too late (and corresponding popfq is too early).

Original issue reported on code.google.com by euge...@google.com on 7 May 2014 at 9:30

GoogleCodeExporter commented 9 years ago
We could replace sub/add with lea - it does not change flags.

Original comment by euge...@google.com on 7 May 2014 at 9:33

GoogleCodeExporter commented 9 years ago
Btw, do we do "sub    $0x80,%rsp" twice??

Original comment by euge...@google.com on 7 May 2014 at 9:37