2014-01-29 12:51:35 +08:00
|
|
|
//===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SparcTargetObjectFile.h"
|
|
|
|
#include "MCTargetDesc/SparcMCExpr.h"
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/Dwarf.h"
|
2014-01-29 12:51:35 +08:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
|
2014-02-20 01:23:20 +08:00
|
|
|
#include "llvm/Target/TargetLowering.h"
|
2014-01-29 12:51:35 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2017-06-22 04:36:32 +08:00
|
|
|
void SparcELFTargetObjectFile::Initialize(MCContext &Ctx,
|
|
|
|
const TargetMachine &TM) {
|
|
|
|
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
|
|
|
|
InitializeELF(TM.Options.UseInitArray);
|
|
|
|
}
|
|
|
|
|
2014-02-09 22:50:44 +08:00
|
|
|
const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
|
2016-09-16 15:33:15 +08:00
|
|
|
const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
|
|
|
|
MachineModuleInfo *MMI, MCStreamer &Streamer) const {
|
2014-01-29 12:51:35 +08:00
|
|
|
|
|
|
|
if (Encoding & dwarf::DW_EH_PE_pcrel) {
|
|
|
|
MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
|
|
|
|
|
2016-09-16 15:33:15 +08:00
|
|
|
MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM);
|
2014-01-29 12:51:35 +08:00
|
|
|
|
|
|
|
// Add information about the stub reference to ELFMMI so that the stub
|
|
|
|
// gets emitted by the asmprinter.
|
|
|
|
MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
|
2014-04-25 13:30:21 +08:00
|
|
|
if (!StubSym.getPointer()) {
|
2016-11-23 00:17:20 +08:00
|
|
|
MCSymbol *Sym = TM.getSymbol(GV);
|
2014-01-29 12:51:35 +08:00
|
|
|
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
|
|
|
}
|
|
|
|
|
|
|
|
MCContext &Ctx = getContext();
|
2015-05-30 09:25:56 +08:00
|
|
|
return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
|
|
|
|
MCSymbolRefExpr::create(SSym, Ctx), Ctx);
|
2014-01-29 12:51:35 +08:00
|
|
|
}
|
|
|
|
|
2016-09-16 15:33:15 +08:00
|
|
|
return TargetLoweringObjectFileELF::getTTypeGlobalReference(GV, Encoding, TM,
|
|
|
|
MMI, Streamer);
|
2014-01-29 12:51:35 +08:00
|
|
|
}
|