relax 32-bit reachability for static clients using attach
DR's API guarantees 32-bit-offset reachability from its code caches to client libraries (#774 (closed)). Normally DR can load the client .so near the -vm_base, and normally DR is the first thing in the address space (after mapping the executable) and can claim what it needs. But for statically linked clients that are stuck inside the application binary and cannot be moved, and when we are attaching later after much of the address space around the application has been occupied by heap, we cannot always find much or any space within 32-bit reach of the client.
The plan is to further generalize provided interface routines to be more flexible to make it easier to build position-independent clients, and to relax the reachability constraints either for all static clients or when a runtime option is passed in. We'll keep the 32-bit guarantee for regular clients for now.
Specific things that need addressing:
-
Clean calls: we already have DR_CLEANCALL_INDIRECT, and dr_insert_call_ex() which takes an encode_pc and does indirect if it's far away, but some API routines like dr_insert_mbr_instrumentation() never use indirect. Plus out-of-line-clean-call context switch calls are hardcoded to be direct.
-
Global variables: make things like drx_insert_counter_update() support going through a register on x86.
In some sense this unifies things with ARM and AArch64: cross-platform clients can't leverage reachability already, so long-term we may move away from this x86 guarantee.