[drreg] drreg_reserve_aflags failed to reserve/restore for the condition instructions on x86 platform
Created by: JerryYouxin
Description
On x86 platform, drreg_reserve_aflags
/drreg_unreserve_aflags
failed to reserve/restore the arithmetic flags for the condition instructions (e.g., cmovcc
, sbb
, e.t.c.). Similarly, drreg_aflags_are_dead
also results in the wrong estimation, where the condition instructions will read/use the arithmetic flags and DRReg still estimates the arithmetic flags are dead. This is the root cause of the failure of drreg_reserve_aflags
to properly reserve the arithmetic flags.
To Reproduce
To reproduce the bug, I write a minimal client tool and an example target program in this gist post. The minimal client tool uses drx_aflags_are_dead
to find out whether the drreg's liveness estimation is correct or not. For this minimal example, we can detect the arithmetic flag liveness estimation given by drreg and drx differs for cmovnz
condition instruction, where drreg estimates the arithmetic flags are dead (wrong estimation). This is also happens when building with -debug supports.
Expected behavior
drreg_reserve_aflags
/drreg_unreserve_aflags
should correctly reserve/restore the arithmetic flags for the condition instructions like cmovcc
, where the arithmetic flags should not be affected before and after the instrumented codes of client tools.
Versions
- The
master
branch of Dynamorio repository. - OS: Ubuntu 20.04 LTS with kernel 5.8.0-53-generic, x86_64