[PATCH] D19908: [X86] Support the "ms-hotpatch" attribute.

Charles Davis via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 13:48:48 PDT 2016


cdavis5x marked an inline comment as done.

================
Comment at: docs/LangRef.rst:1463
@@ -1446,1 +1462,3 @@
+
+       ``"ms-hotpatch"`` is currently only supported on x86 and x86-64.
 
----------------
tl;dr: You'll have problems on i386, but not anywhere else.

On 32-bit x86, a function marked `ms-hotpatch` must start with the bytes `8b ff` (a `mov edi, edi` instruction). (Strictly speaking, it doesn't //have// to, but programs are abusing this to alter functionality of Windows API calls, and they use this as a sort of magic number to know if a function can be hotpatched or not, so unfortunately, it's too late to change this.) Later on, this gets replaced by a two-byte `jmp short` into the patch space (which is only guaranteed to be at least 5 bytes, though GCC--and therefore, this patch--gives you 64 bytes) which precedes this function. I believe the `mov edi, edi` must immediately be followed by a standard prologue (i.e. `push ebp; mov ebp, esp`), but I'm not sure about that. Based on all that, and on what you've said, I fear you may have problems getting XRay to play well with `ms-hotpatch`-style functions on i386. But it looks like you don't support anything other than x86-64 yet.

On any other architecture (including x64), no, it is not required (AFAICT) to be any specific instruction.


http://reviews.llvm.org/D19908





More information about the llvm-commits mailing list