Adds new labels delimiting clean call sequences. Converts into a translation record flag when storing translations.
Uses the new labels and flag to precisely identify clean call mangling, replacing the previous scheme which incorrectly thought mangled tool pc-relative was a clean call, resulting in incorrect translations and crashes.
To enable using labels after emitting, stops using instr_t.note to hold encoding offsets for pc-releative operands. Adds a new field instr_t.offset which is used for this purpose. This leaves note values in place across encodings, which is needed for new clean call marking labels and also simplifies rseq handling code.
This is a compatibility break and as such we increase the version and OLDEST_COMPATIBLE_VERSION to 990.
Since we only reserved 16 labels for DR, and we're already breaking compatilibity, we go ahead and reduce DR_NOTE_FIRST_RESERVED to give DR more reserved labels.
Adds a test case to api.detach_state by adding a client (by converting it to use static DR) which inserts a pc-relative load. This reproduces the crash on detach, and is fixed with this fix. The added instrumentation caused periodic detach failures which were solved by setting the translation and adding a restore-state event: i#4232 covers trying to improve the situation.
Changing the test to use static DR resulted in some change in some Linux kernel lazy AVX state restores on sigreturn causing the AVX values set on detach to be ignored. We solve this by writing the real xstate_bv into the signal frame when setting the xstate context.
Issue: #5786 (closed), #4232 Fixes #5786 (closed)