DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.57k stars 552 forks source link

i#6668: Replace drwrap retaddr sentinel on all architectures, not just x86 #6670

Closed ivankyluk closed 4 months ago

ivankyluk commented 4 months ago

Expand drwrap's return address sentinel replacement from just x86 (as was added in PR #6395) to cover all architectures.

When -record_replace_retaddr is used in ARM (as well as x86) platforms, the return address in the stack is replaced by the sentinel. For a tailcall, the current implementation uses the address in the stack, the sentinel, as the return address. The change is to check if the return address in the stack is the sentinel or not. If it is, replace it with the return address of the outer level.

The problem can be reproduced by

./build/bin64/drrun -t drcachesim -offline -record_replace_retaddr -record_function 'tailcall_with_retaddr|1&foo|1' -- ../build_suite/build_debug-internal-64/suite/tests/bin/common.getretaddr

on an ARM machine.

This change expends PR #6395 to cover ARM.

Issues: #6394, #6668 Fixes: #6668