Granary / granary2

Dynamic binary translation framework for instrumenting x86-64 user space Linux programs
MIT License
39 stars 5 forks source link

`DirectEdge` re-use and tightening of that code #64

Open pgoodman opened 9 years ago

pgoodman commented 9 years ago

DirectEdge structures (and associated code) is pretty heavyweight right now. I could imagine a scenario where we have a fixed-number of pre-allocated structures and code entrypoints, where each entrypoint is specific to its structure. In such a case, the entrypoint code could really be only a few instructions--potentially even a single instruction (a CALL in kernel space)--where the return address implicitly identifies which edge structure to use. In one case, we could pre-allocate to have more than enough edge structures than there will ever be blocks, but this seems flaky. This type of setup would need proper garbage collection of edges and patching of edges.

In the kernel, patching should be done with an IPI. In user space, it's less clear how to make patching correct. One approach could be safepoints.

Anyway, I think there is a good opportunity here.

pgoodman commented 9 years ago

Could also look into the trick that DynamoRIO has for conditional branches, where there is a guaranteed Jcc; JMP pair. Here, they use the same exit stub, but detect the proper target based on the AFLAGS.