[DynInst_API:] A question about dynInst's static instrumentation ability


Date: Sat, 22 Aug 2015 23:37:27 -0400
From: Shuai Wang <wangshuai901@xxxxxxxxx>
Subject: [DynInst_API:] A question about dynInst's static instrumentation ability
Dear list,


I basically want to instrument an ELF binary, adding some instrumentation code to the beginning of every basic block. I use DynInst version 8.2.1 on 64-bit Linux platform. I am instrumenting some unstripped binaries now but I want to move forward to stripped binaries later.

I found some very confusing situation in the instrumented output, could anyone educate me on that..? Sorry if it is really a stupid question.. Let me elaborate it here:

1. I insert one instruction to the beginning of every basic block.

2. After instrumentation, I use objdump to check the output, I are assured that basic blocks' begining instruction(s) have been substituted with a "jmp" instruction to the patched section, something like this:
     Âjmpq  700280 <main_dyninst>

3. I use gdb to go with the execution flow on the instrumented output, and I observed that when execution flow hits the first jmpq instruction (at the beginning of main function actually), it is redirected to the patched section.

4. I observed the execution at patched section, including both instrumentation code, also the replaced instructions at the instrumentation point of the original binary. However, to my surprise, the execution flow isn't redirected back to the original code section, and it just execute all the instructions at the patched sections. And as a result, even I instrumented every basic block, but only instrumentation code at the first basic block was indeed executed during runtime.


I suppose for a static instrumentation, after execution of instrumentation code and replaced instructions at the patched section, the execution flow is then redirected back by a jmpÂinstruction to the original code section. Am I missed anything here..? Or do I have to configure some options in my code for this type of functionality..?Â

Sorry for my disorganizedÂdescription, am I clear? If so, could anyone give me some help..? I really appreciate that!

Sincerely,
Shuai


[← Prev in Thread] Current Thread [Next in Thread→]