]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/lib/Target/X86/X86TargetObjectFile.cpp
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / lib / Target / X86 / X86TargetObjectFile.cpp
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 "llvm/MC/MCContext.h"
12 #include "llvm/MC/MCExpr.h"
13 #include "llvm/MC/MCSectionELF.h"
14 #include "llvm/Support/Dwarf.h"
15 #include "llvm/Target/Mangler.h"
16
17 using namespace llvm;
18 using namespace dwarf;
19
20 const MCExpr *X86_64MachoTargetObjectFile::
21 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
22                         MachineModuleInfo *MMI, unsigned Encoding,
23                         MCStreamer &Streamer) const {
24
25   // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
26   // is an indirect pc-relative reference.
27   if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
28     const MCSymbol *Sym = Mang->getSymbol(GV);
29     const MCExpr *Res =
30       MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
31     const MCExpr *Four = MCConstantExpr::Create(4, getContext());
32     return MCBinaryExpr::CreateAdd(Res, Four, getContext());
33   }
34
35   return TargetLoweringObjectFileMachO::
36     getTTypeGlobalReference(GV, Mang, MMI, Encoding, Streamer);
37 }
38
39 MCSymbol *X86_64MachoTargetObjectFile::
40 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
41                         MachineModuleInfo *MMI) const {
42   return Mang->getSymbol(GV);
43 }
44
45 void
46 X86LinuxTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM) {
47   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
48   InitializeELF(TM.Options.UseInitArray);
49 }