Inline asm statements which have call instructions can be problematic.GCC doesn't know about the call instructions, so in some cases it caninsert the asm before setting up the frame pointer. This can result inbad stack traces when unwinding from the called function.

Previously we worked around this issue by listing the stack pointer asan input/output constraint for the inline asm. That works for GCC, butunfortunately it doesn't work for Clang. In fact, it causes Clang tocorrupt the stack pointer.

Introduce a new ASM_CALL() macro, which should be used for all inlinestatements which have call instructions. On GCC with frame pointers, itsets the stack pointer as an input/output constraint, like before. OnGCC without frame pointers, it does nothing, which saves a small amountof text. On Clang, it does nothing (for now).

If it's a GCC-compiled .c file, the error may be because the function uses an inline asm() statement which has a "call" instruction. An- asm() statement with a call instruction must declare the use of the- stack pointer in its output operand. For example, on x86_64:-- register void *__sp asm("rsp");- asm volatile("call func" : "+r" (__sp));-- Otherwise the stack frame may not get created before the call.+ asm() statement with a call instruction must use the ASM_CALL macro,+ which forces the frame pointer to be saved before the call.

This is a kernel entry/exit instruction like sysenter or iret. Such instructions aren't allowed in a callable function, and are most@@ -239,7 +234,7 @@ they mean, and suggestions for how to fix them. annotated with the unwind hint macros in asm/unwind_hints.h.

This is a dynamic jump or a jump to an undefined symbol. Objtool assumed it's a sibling call and detected that the frame pointer@@ -253,7 +248,7 @@ they mean, and suggestions for how to fix them. the unwind hint macros in asm/unwind_hints.h.

The instruction's frame pointer state is inconsistent, depending on which execution path was taken to reach the instruction.@@ -270,7 +265,7 @@ they mean, and suggestions for how to fix them. asm/unwind_hints.h.