diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2009-03-12 18:15:39 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2009-03-12 18:15:39 +0000 |
| commit | a065200eaf71248133470caf03eefea449fff7b4 (patch) | |
| tree | aa596d8d4a5d84915e6558bf30b20b547056bc68 /lib/Target/X86/X86CodeEmitter.cpp | |
| parent | 80b8a62fda56179b00fe463ae55d712aa8abefec (diff) | |
Re-apply 66024 with fixes: 1. Fixed indirect call to immediate address assembly. 2. Fixed JIT encoding by making the address pc-relative.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66803 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86CodeEmitter.cpp')
| -rw-r--r-- | lib/Target/X86/X86CodeEmitter.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index dbcb52a481..bbe063b4f8 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -589,7 +589,13 @@ void Emitter::emitInstruction(const MachineInstr &MI, } else if (MO.isSymbol()) { emitExternalSymbolAddress(MO.getSymbolName(), X86::reloc_pcrel_word); } else if (MO.isImm()) { - emitConstant(MO.getImm(), X86InstrInfo::sizeOfImm(Desc)); + if (Opcode == X86::CALLpcrel32 || Opcode == X86::CALL64pcrel32) { + // Fix up immediate operand for pc relative calls. + intptr_t Imm = (intptr_t)MO.getImm(); + Imm = Imm - MCE.getCurrentPCValue() - 4; + emitConstant(Imm, X86InstrInfo::sizeOfImm(Desc)); + } else + emitConstant(MO.getImm(), X86InstrInfo::sizeOfImm(Desc)); } else { assert(0 && "Unknown RawFrm operand!"); } |
