Skip to content

Commit 3eb9382

Browse files
committed
Merge 81888 from mainline.
Change the marker byte for stubs from 0xcd to 0xce (another form of interrupt instruction, which shouldn't arise any other way). 0xcd is also used by JITMemoryManager to initialize the buffer to garbage, which means it could appear following a noreturn call even when that is not a stub, confusing X86CompilationCallback2. PR 4929. llvm-svn: 81981
1 parent aea386f commit 3eb9382

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Target/X86/X86JITInfo.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ X86CompilationCallback2(intptr_t *StackPtr, intptr_t RetAddr) {
338338
"Could not find return address on the stack!");
339339

340340
// It's a stub if there is an interrupt marker after the call.
341-
bool isStub = ((unsigned char*)RetAddr)[0] == 0xCD;
341+
bool isStub = ((unsigned char*)RetAddr)[0] == 0xCE;
342342

343343
// The call instruction should have pushed the return value onto the stack...
344344
#if defined (X86_64_JIT)
@@ -377,7 +377,7 @@ X86CompilationCallback2(intptr_t *StackPtr, intptr_t RetAddr) {
377377
// If this is a stub, rewrite the call into an unconditional branch
378378
// instruction so that two return addresses are not pushed onto the stack
379379
// when the requested function finally gets called. This also makes the
380-
// 0xCD byte (interrupt) dead, so the marker doesn't effect anything.
380+
// 0xCE byte (interrupt) dead, so the marker doesn't effect anything.
381381
#if defined (X86_64_JIT)
382382
// If the target address is within 32-bit range of the stub, use a
383383
// PC-relative branch instead of loading the actual address. (This is
@@ -486,7 +486,10 @@ void *X86JITInfo::emitFunctionStub(const Function* F, void *Fn,
486486
JCE.emitWordLE((intptr_t)Fn-JCE.getCurrentPCValue()-4);
487487
#endif
488488

489-
JCE.emitByte(0xCD); // Interrupt - Just a marker identifying the stub!
489+
// This used to use 0xCD, but that value is used by JITMemoryManager to
490+
// initialize the buffer with garbage, which means it may follow a
491+
// noreturn function call, confusing X86CompilationCallback2. PR 4929.
492+
JCE.emitByte(0xCE); // Interrupt - Just a marker identifying the stub!
490493
return JCE.finishGVStub(F);
491494
}
492495

0 commit comments

Comments
 (0)