1 //===-- X86TargetObjectFile.cpp - X86 Object Info -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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"
18 using namespace dwarf;
20 const MCExpr *X86_64MachoTargetObjectFile::
21 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
22 MachineModuleInfo *MMI, unsigned Encoding,
23 MCStreamer &Streamer) const {
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);
30 MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
31 const MCExpr *Four = MCConstantExpr::Create(4, getContext());
32 return MCBinaryExpr::CreateAdd(Res, Four, getContext());
35 return TargetLoweringObjectFileMachO::
36 getTTypeGlobalReference(GV, Mang, MMI, Encoding, Streamer);
39 MCSymbol *X86_64MachoTargetObjectFile::
40 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
41 MachineModuleInfo *MMI) const {
42 return Mang->getSymbol(GV);
46 X86LinuxTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM) {
47 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
48 InitializeELF(TM.Options.UseInitArray);