mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
save return address in powerpc.cpp's MyAssembler::saveFrame
We've been getting away with not doing this so far since our Java calling convention matches the native calling convention concerning where the return address is saved, so when our thunk calls native code it gets saved for us automatically. However, there was still the danger that a thread would interrupt another thread after the stack pointer was saved to the thread field but before the native code was called and try to get a stack trace, at which point it would try to find the return address relative to that stack pointer and find garbage instead. This commit ensures that we save the return address before saving the stack pointer to avoid such a situation.
This commit is contained in:
parent
a4914daae4
commit
e7a48c0fa2
@ -2142,6 +2142,12 @@ class MyAssembler: public Assembler {
|
||||
}
|
||||
|
||||
virtual void saveFrame(unsigned stackOffset, unsigned) {
|
||||
Register returnAddress(0);
|
||||
emit(&c, mflr(returnAddress.low));
|
||||
|
||||
Memory returnAddressDst(StackRegister, 8);
|
||||
moveRM(&c, BytesPerWord, &returnAddress, BytesPerWord, &returnAddressDst);
|
||||
|
||||
Register stack(StackRegister);
|
||||
Memory stackDst(ThreadRegister, stackOffset);
|
||||
moveRM(&c, BytesPerWord, &stack, BytesPerWord, &stackDst);
|
||||
|
Loading…
Reference in New Issue
Block a user