[llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri Oct 17 16:48:01 PDT 2003
Changes in directory llvm/lib/Target/X86:
X86TargetMachine.cpp updated: 1.31 -> 1.32
---
Log message:
You can't just blat the address into memory, you have to blat its
displacement.
---
Diffs of the changes: (+7 -4)
Index: llvm/lib/Target/X86/X86TargetMachine.cpp
diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.31 llvm/lib/Target/X86/X86TargetMachine.cpp:1.32
--- llvm/lib/Target/X86/X86TargetMachine.cpp:1.31 Fri Oct 17 13:27:46 2003
+++ llvm/lib/Target/X86/X86TargetMachine.cpp Fri Oct 17 16:47:25 2003
@@ -143,9 +143,12 @@
}
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!
}
More information about the llvm-commits
mailing list