diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-23 07:20:12 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-23 07:20:12 +0000 |
commit | 3c7cab1402304648b57d86d8e74d409fe7bd7112 (patch) | |
tree | 99f1921919d51e844016c7cafb7ea6591036e06f /llvm/lib/Target/X86/X86MCCodeEmitter.cpp | |
parent | ce87a7e45c520a27f964ac845eaaf7fab2146c15 (diff) | |
download | bcm5719-llvm-3c7cab1402304648b57d86d8e74d409fe7bd7112.tar.gz bcm5719-llvm-3c7cab1402304648b57d86d8e74d409fe7bd7112.zip |
Produce a relocation for pcrel absolute values. Based on a patch by David Meyer.
llvm-svn: 120006
Diffstat (limited to 'llvm/lib/Target/X86/X86MCCodeEmitter.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86MCCodeEmitter.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/llvm/lib/Target/X86/X86MCCodeEmitter.cpp b/llvm/lib/Target/X86/X86MCCodeEmitter.cpp index fea37f85a74..586216d774b 100644 --- a/llvm/lib/Target/X86/X86MCCodeEmitter.cpp +++ b/llvm/lib/Target/X86/X86MCCodeEmitter.cpp @@ -218,18 +218,22 @@ void X86MCCodeEmitter:: EmitImmediate(const MCOperand &DispOp, unsigned Size, MCFixupKind FixupKind, unsigned &CurByte, raw_ostream &OS, SmallVectorImpl<MCFixup> &Fixups, int ImmOffset) const { - // If this is a simple integer displacement that doesn't require a relocation, - // emit it now. + const MCExpr *Expr = NULL; if (DispOp.isImm()) { - // FIXME: is this right for pc-rel encoding?? Probably need to emit this as - // a fixup if so. - EmitConstant(DispOp.getImm()+ImmOffset, Size, CurByte, OS); - return; + // If this is a simple integer displacement that doesn't require a relocation, + // emit it now. + if (FixupKind != MCFixupKind(X86::reloc_pcrel_1byte) && + FixupKind != MCFixupKind(X86::reloc_pcrel_2byte) && + FixupKind != MCFixupKind(X86::reloc_pcrel_4byte)) { + EmitConstant(DispOp.getImm()+ImmOffset, Size, CurByte, OS); + return; + } + Expr = MCConstantExpr::Create(DispOp.getImm(), Ctx); + } else { + Expr = DispOp.getExpr(); } // If we have an immoffset, add it to the expression. - const MCExpr *Expr = DispOp.getExpr(); - if (FixupKind == FK_Data_4 && StartsWithGlobalOffsetTable(Expr)) { assert(ImmOffset == 0); |