1 //===-- 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 //===----------------------------------------------------------------------===// 9 10 #include "X86TargetObjectFile.h" 11 #include "X86TargetMachine.h" 12 #include "llvm/CodeGen/MachineModuleInfoImpls.h" 13 #include "llvm/MC/MCContext.h" 14 #include "llvm/MC/MCExpr.h" 15 #include "llvm/MC/MCSectionMachO.h" 16 #include "llvm/Target/Mangler.h" 17 #include "llvm/Support/Dwarf.h" 18 using namespace llvm; 19 using namespace dwarf; 20 21 const MCExpr *X8664_MachoTargetObjectFile:: 22 getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, 23 MachineModuleInfo *MMI, unsigned Encoding, 24 MCStreamer &Streamer) const { 25 26 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which 27 // is an indirect pc-relative reference. 28 if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) { 29 const MCSymbol *Sym = Mang->getSymbol(GV); 30 const MCExpr *Res = 31 MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext()); 32 const MCExpr *Four = MCConstantExpr::Create(4, getContext()); 33 return MCBinaryExpr::CreateAdd(Res, Four, getContext()); 34 } 35 36 return TargetLoweringObjectFileMachO:: 37 getExprForDwarfGlobalReference(GV, Mang, MMI, Encoding, Streamer); 38 } 39 40 MCSymbol *X8664_MachoTargetObjectFile:: 41 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, 42 MachineModuleInfo *MMI) const { 43 return Mang->getSymbol(GV); 44 } 45