wmkhoo / taintgrind

A taint-tracking plugin for the Valgrind memory checking tool
GNU General Public License v2.0
249 stars 42 forks source link

Handling GetI/PutI instructions #20

Closed wmkhoo closed 6 years ago

wmkhoo commented 6 years ago

According to libvex_ir.h:

The basic "Get" and "Put" operations are sufficient to model normal fixed registers on the guest. Selected areas of the guest state can be treated as a circular array of registers (type: 'IRRegArray'), which can be indexed at run-time. This is done with the "GetI" and "PutI" primitives. This is necessary to describe rotating register files, for example the x87 FPU stack, SPARC register windows, and the Itanium register files. The part of the guest state to be treated as a circular array is described in the IRRegArray 'descr' field. It holds the offset of the first element in the array, the type of each element, and the number of elements. The array index is indicated rather indirectly, in a way which makes optimisation easy: as the sum of variable part (the 'ix' field) and a constant offset (the 'bias' field). Since the indexing is circular, the actual array index to use is computed as (ix + bias) % num-of-elems-in-the-array. Here's an example. The description "(96:8xF64)[t39,-7]" describes an array of 8 F64-typed values, the guest-state-offset of the first being 96. This array is being indexed at (t39 - 7) % 8.

wmkhoo commented 6 years ago

Should be handled properly now