12
12
#include " llvm/BinaryFormat/ELF.h"
13
13
#include " llvm/MC/MCContext.h"
14
14
#include " llvm/MC/MCSectionELF.h"
15
+ #include " llvm/MC/MCValue.h"
15
16
16
17
using namespace llvm ;
17
18
@@ -25,13 +26,24 @@ void RISCVELFTargetObjectFile::Initialize(MCContext &Ctx,
25
26
TargetLoweringObjectFileELF::Initialize (Ctx, TM);
26
27
27
28
PLTRelativeVariantKind = MCSymbolRefExpr::VK_PLT;
29
+ SupportIndirectSymViaGOTPCRel = true ;
28
30
29
31
SmallDataSection = getContext ().getELFSection (
30
32
" .sdata" , ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
31
33
SmallBSSSection = getContext ().getELFSection (" .sbss" , ELF::SHT_NOBITS,
32
34
ELF::SHF_WRITE | ELF::SHF_ALLOC);
33
35
}
34
36
37
+ const MCExpr *RISCVELFTargetObjectFile::getIndirectSymViaGOTPCRel (
38
+ const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV,
39
+ int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const {
40
+ int64_t FinalOffset = Offset + MV.getConstant ();
41
+ const MCExpr *Res =
42
+ MCSymbolRefExpr::create (Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext ());
43
+ const MCExpr *Off = MCConstantExpr::create (FinalOffset, getContext ());
44
+ return MCBinaryExpr::createAdd (Res, Off, getContext ());
45
+ }
46
+
35
47
// A address must be loaded from a small section if its size is less than the
36
48
// small section size threshold. Data in this section could be addressed by
37
49
// using gp_rel operator.
0 commit comments