[quake3-commits] r1998 - trunk/code/qcommon
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun May 22 20:36:27 EDT 2011
Author: thilo
Date: 2011-05-22 20:36:27 -0400 (Sun, 22 May 2011)
New Revision: 1998
Modified:
trunk/code/qcommon/vm_x86_64.c
Log:
- 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()
Modified: trunk/code/qcommon/vm_x86_64.c
===================================================================
--- trunk/code/qcommon/vm_x86_64.c 2011-05-19 03:47:35 UTC (rev 1997)
+++ trunk/code/qcommon/vm_x86_64.c 2011-05-23 00:36:27 UTC (rev 1998)
@@ -1029,7 +1029,9 @@
static char* memData;
#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 programStack;
int stackOnEntry;
@@ -1037,7 +1039,6 @@
byte *image;
void *entryPoint;
int *opStack;
- int stack[OPSTACK_SIZE + 3] = { 0xDEADBEEF };
currentVM = vm;
@@ -1079,6 +1080,8 @@
entryPoint = getentrypoint(vm);
opStack = PADP(stack, 4);
+ *opStack = 0xDEADBEEF;
+
__asm__ __volatile__ (
" movq $0x0,%%rbx \r\n" \
" movl %5,%%edi \r\n" \
@@ -1092,8 +1095,9 @@
" movq %%rbx, %1 \r\n" \
: "=g" (programStack), "=g" (opStackRet)
: "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)
Com_Error(ERR_DROP, "opStack corrupted in compiled code (offset %ld)", opStackRet);
More information about the quake3-commits
mailing list