1 //===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===//
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 "SparcTargetObjectFile.h"
11 #include "MCTargetDesc/SparcMCExpr.h"
12 #include "llvm/BinaryFormat/Dwarf.h"
13 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
14 #include "llvm/CodeGen/TargetLowering.h"
15
16 using namespace llvm;
17
Initialize(MCContext & Ctx,const TargetMachine & TM)18 void SparcELFTargetObjectFile::Initialize(MCContext &Ctx,
19 const TargetMachine &TM) {
20 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
21 InitializeELF(TM.Options.UseInitArray);
22 }
23
getTTypeGlobalReference(const GlobalValue * GV,unsigned Encoding,const TargetMachine & TM,MachineModuleInfo * MMI,MCStreamer & Streamer) const24 const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
25 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
26 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
27
28 if (Encoding & dwarf::DW_EH_PE_pcrel) {
29 MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
30
31 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM);
32
33 // Add information about the stub reference to ELFMMI so that the stub
34 // gets emitted by the asmprinter.
35 MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
36 if (!StubSym.getPointer()) {
37 MCSymbol *Sym = TM.getSymbol(GV);
38 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
39 }
40
41 MCContext &Ctx = getContext();
42 return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
43 MCSymbolRefExpr::create(SSym, Ctx), Ctx);
44 }
45
46 return TargetLoweringObjectFileELF::getTTypeGlobalReference(GV, Encoding, TM,
47 MMI, Streamer);
48 }
49