The base pointer register is reserved by compiler when there is
dynamic size alloca and stack realign in a function. However the
base pointer register is not defined in X86 ABI, so user can use
this register in inline assembly. The inline assembly would
clobber base pointer register without being awared by user. This
patch to save and restore the base pointer register when compiler
detect it is clobbered. Below is the example code for such case.
extern int bar(void *p); long long foo(size_t size, char c, int id) { __attribute__((__aligned__(64))) int a; char *p = (char *)alloca(size); asm volatile ("nop"::"S"(405):); asm volatile ("movl %0, %1"::"r"(id), "m"(a):); p[2] = 8; memset(p, c, size); return bar(p); }
I'll check if the disp is set right.