llvm.org GIT mirror llvm / ac1b5f1
MC: permit emitting a symbol value as section relative This adds an optional parameter to the EmitSymbolValue method in MCStreamer to permit emitting a symbol value as a section relative value. This is to cover the use in MCDwarf which should not really know about how to emit a section relative value for a given target. This addresses post-review comments from Eric Christopher in SVN r213275. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213463 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 5 years ago
3 changed file(s) with 14 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
571571
572572 /// EmitSymbolValue - Special case of EmitValue that avoids the client
573573 /// having to pass in a MCExpr for MCSymbols.
574 void EmitSymbolValue(const MCSymbol *Sym, unsigned Size);
574 void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
575 bool IsSectionRelative = false);
575576
576577 /// EmitGPRel64Value - Emit the expression @p Value into the output as a
577578 /// gprel64 (64-bit GP relative) value.
654654 // The 2 byte DWARF version.
655655 MCOS->EmitIntValue(context.getDwarfVersion(), 2);
656656
657 const MCAsmInfo &AsmInfo = *context.getAsmInfo();
657658 // The 4 byte offset to the debug abbrevs from the start of the .debug_abbrev,
658659 // it is at the start of that section so this is zero.
659660 if (AbbrevSectionSymbol == nullptr)
660661 MCOS->EmitIntValue(0, 4);
661 else if (context.getAsmInfo()->needsDwarfSectionOffsetDirective())
662 MCOS->EmitCOFFSecRel32(AbbrevSectionSymbol);
663662 else
664 MCOS->EmitSymbolValue(AbbrevSectionSymbol, 4);
663 MCOS->EmitSymbolValue(AbbrevSectionSymbol, 4,
664 AsmInfo.needsDwarfSectionOffsetDirective());
665665
666666 const MCAsmInfo *asmInfo = context.getAsmInfo();
667667 int AddrSize = asmInfo->getPointerSize();
147147 EmitValueImpl(Value, Size, Loc);
148148 }
149149
150 void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size) {
151 EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size);
150 void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
151 bool IsSectionRelative) {
152 assert((!IsSectionRelative || Size == 4) &&
153 "SectionRelative value requires 4-bytes");
154
155 if (!IsSectionRelative)
156 EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size);
157 else
158 EmitCOFFSecRel32(Sym);
152159 }
153160
154161 void MCStreamer::EmitGPRel64Value(const MCExpr *Value) {