- Do assignment of value 0xDEADBEEF after the 4-byte alignment

- Add all GPR to clobber list as GCC function callAsmCall seems to change register r11 without saving it to stack first, which may result in SIGSEGV in VM_CallCompiled()
This commit is contained in:
Thilo Schulz 2011-05-23 00:36:27 +00:00
parent b8ef880d85
commit e08299faf4

View file

@ -1029,7 +1029,9 @@ This function is called directly by the generated code
static char* memData; static char* memData;
#endif #endif
int VM_CallCompiled( vm_t *vm, int *args ) { int VM_CallCompiled(vm_t *vm, int *args)
{
int stack[OPSTACK_SIZE + 3];
int programCounter; int programCounter;
int programStack; int programStack;
int stackOnEntry; int stackOnEntry;
@ -1037,7 +1039,6 @@ int VM_CallCompiled( vm_t *vm, int *args ) {
byte *image; byte *image;
void *entryPoint; void *entryPoint;
int *opStack; int *opStack;
int stack[OPSTACK_SIZE + 3] = { 0xDEADBEEF };
currentVM = vm; currentVM = vm;
@ -1079,6 +1080,8 @@ int VM_CallCompiled( vm_t *vm, int *args ) {
entryPoint = getentrypoint(vm); entryPoint = getentrypoint(vm);
opStack = PADP(stack, 4); opStack = PADP(stack, 4);
*opStack = 0xDEADBEEF;
__asm__ __volatile__ ( __asm__ __volatile__ (
" movq $0x0,%%rbx \r\n" \ " movq $0x0,%%rbx \r\n" \
" movl %5,%%edi \r\n" \ " movl %5,%%edi \r\n" \
@ -1092,8 +1095,9 @@ int VM_CallCompiled( vm_t *vm, int *args ) {
" movq %%rbx, %1 \r\n" \ " movq %%rbx, %1 \r\n" \
: "=g" (programStack), "=g" (opStackRet) : "=g" (programStack), "=g" (opStackRet)
: "g" (entryPoint), "g" (opStack), "g" (vm->dataBase), "g" (programStack) : "g" (entryPoint), "g" (opStack), "g" (vm->dataBase), "g" (programStack)
: "%rsi", "%rdi", "%rax", "%rbx", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r15", "%xmm0" : "%rsi", "%rdi", "%rax", "%rbx", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "%xmm0"
); );
if(opStackRet != 1 || *opStack != 0xDEADBEEF) if(opStackRet != 1 || *opStack != 0xDEADBEEF)
Com_Error(ERR_DROP, "opStack corrupted in compiled code (offset %ld)", opStackRet); Com_Error(ERR_DROP, "opStack corrupted in compiled code (offset %ld)", opStackRet);