1 | //===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "SparcTargetObjectFile.h" |
10 | #include "MCTargetDesc/SparcMCAsmInfo.h" |
11 | #include "llvm/BinaryFormat/Dwarf.h" |
12 | #include "llvm/BinaryFormat/ELF.h" |
13 | #include "llvm/CodeGen/MachineModuleInfoImpls.h" |
14 | #include "llvm/CodeGen/TargetLowering.h" |
15 | #include "llvm/Target/TargetMachine.h" |
16 | |
17 | using namespace llvm; |
18 | |
19 | void SparcELFTargetObjectFile::Initialize(MCContext &Ctx, |
20 | const TargetMachine &TM) { |
21 | TargetLoweringObjectFileELF::Initialize(Ctx, TM); |
22 | } |
23 | |
24 | 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, Suffix: ".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(Sym: 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 MCSpecifierExpr::create(Sym: SSym, S: ELF::R_SPARC_DISP32, Ctx); |
43 | } |
44 | |
45 | return TargetLoweringObjectFileELF::getTTypeGlobalReference(GV, Encoding, TM, |
46 | MMI, Streamer); |
47 | } |
48 | |