Chris Lattner | 8c6ed05 | 2009-09-16 01:46:41 +0000 | [diff] [blame^] | 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 | //===----------------------------------------------------------------------===// |
| 9 | |
| 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; |
| 15 | |
| 16 | const MCExpr *X8664_MachoTargetObjectFile:: |
| 17 | getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, |
| 18 | bool &IsIndirect, bool &IsPCRel) const { |
| 19 | |
| 20 | // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which |
| 21 | // is an indirect pc-relative reference. |
| 22 | IsIndirect = true; |
| 23 | IsPCRel = true; |
| 24 | |
| 25 | SmallString<128> Name; |
| 26 | Mang->getNameWithPrefix(Name, GV, false); |
| 27 | Name += "@GOTPCREL"; |
| 28 | const MCExpr *Res = |
| 29 | MCSymbolRefExpr::Create(Name.str(), getContext()); |
| 30 | const MCExpr *Four = MCConstantExpr::Create(4, getContext()); |
| 31 | return MCBinaryExpr::CreateAdd(Res, Four, getContext()); |
| 32 | } |
| 33 | |