mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
You can't just blat the address into memory, you have to blat its
displacement. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9210 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0e077f7251
commit
e5f6859911
@ -143,9 +143,12 @@ bool X86TargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
|
||||
}
|
||||
|
||||
bool X86TargetMachine::replaceMachineCodeForFunction (void *Old, void *New) {
|
||||
// FIXME: This code could perhaps live in a more appropriate place.
|
||||
char *OldByte = (char *) Old;
|
||||
*OldByte++ = 0xE9; // JMP
|
||||
unsigned *OldWord = (unsigned *) OldByte;
|
||||
*OldWord = (unsigned) New;
|
||||
return false;
|
||||
*OldByte++ = 0xE9; // Emit JMP opcode.
|
||||
int32_t *OldWord = (int32_t *) OldByte;
|
||||
int32_t NewAddr = (int32_t) New;
|
||||
int32_t OldAddr = (int32_t) OldWord;
|
||||
*OldWord = NewAddr - OldAddr - 4; // Emit PC-relative addr of New code.
|
||||
return false; // success!
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user