pass machinemoduleinfo down into getSymbolForDwarfGlobalReference,
[llvm/avr.git] / lib / Target / X86 / X86TargetObjectFile.cpp
blob4b4cc457aed05c4f331272933a90aaed49a6e0b1
1 //===-- llvm/Target/X86/X86TargetObjectFile.cpp - X86 Object Info ---------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #include "X86TargetObjectFile.h"
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/Support/Mangler.h"
13 #include "llvm/MC/MCExpr.h"
14 using namespace llvm;
16 const MCExpr *X8664_MachoTargetObjectFile::
17 getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
18 MachineModuleInfo *MMI,
19 bool &IsIndirect, bool &IsPCRel) const {
21 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
22 // is an indirect pc-relative reference.
23 IsIndirect = true;
24 IsPCRel = true;
26 SmallString<128> Name;
27 Mang->getNameWithPrefix(Name, GV, false);
28 Name += "@GOTPCREL";
29 const MCExpr *Res =
30 MCSymbolRefExpr::Create(Name.str(), getContext());
31 const MCExpr *Four = MCConstantExpr::Create(4, getContext());
32 return MCBinaryExpr::CreateAdd(Res, Four, getContext());