Granary / granary2

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

Add compile-time option to elide `CacheMetaData::native_addresses`. #28

Open pgoodman opened 10 years ago

pgoodman commented 10 years ago

The native address (NA) mechanism is used by Granary to ensure that addresses referenced by application code are reachable from the code cache. They are primarily needed to resolve control flow that "goes native". For example, if an application instruction has a relative jump from one PC to a target PC, and instrumentation decides that the target PC should execute natively, then that target PC must be reachable from the code cache. Sometimes, this requires Granary to instantiate a NativeAddress structure and convert a direct relative jump into an indirect jump through a nearby memory location.

In order to be able to eventually reclaim NativeAddress structures (e.g. when blocks are flushed from the code cache), Granary maintains a pointer to a list of NA structures in basic block meta-data (CacheMetaData::native_addresses).

In some environments, e.g. kernel space, it is unlikely that this mechanism will ever be needed. Therefore, it would be convenient if a compile-time flag could elide these uses. This would improve the memory footprint of meta-data considerably.