diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-07-19 21:01:58 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-07-19 21:01:58 +0000 |
commit | 00426d9c1928927c5825076f1ff7ce5b67c20b85 (patch) | |
tree | dd4be24fbb696ea692793a74c43d7edcade7e108 /llvm/lib/MC | |
parent | 5ecadda6429f403b92db937be4ae895fbbcad793 (diff) | |
download | bcm5719-llvm-00426d9c1928927c5825076f1ff7ce5b67c20b85.tar.gz bcm5719-llvm-00426d9c1928927c5825076f1ff7ce5b67c20b85.zip |
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.
llvm-svn: 213463
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCDwarf.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/MC/MCStreamer.cpp | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index ae276868198..968cbc96a95 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -655,14 +655,14 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS, // The 2 byte DWARF version. MCOS->EmitIntValue(context.getDwarfVersion(), 2); + const MCAsmInfo &AsmInfo = *context.getAsmInfo(); // The 4 byte offset to the debug abbrevs from the start of the .debug_abbrev, // it is at the start of that section so this is zero. if (AbbrevSectionSymbol == nullptr) MCOS->EmitIntValue(0, 4); - else if (context.getAsmInfo()->needsDwarfSectionOffsetDirective()) - MCOS->EmitCOFFSecRel32(AbbrevSectionSymbol); else - MCOS->EmitSymbolValue(AbbrevSectionSymbol, 4); + MCOS->EmitSymbolValue(AbbrevSectionSymbol, 4, + AsmInfo.needsDwarfSectionOffsetDirective()); const MCAsmInfo *asmInfo = context.getAsmInfo(); int AddrSize = asmInfo->getPointerSize(); diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index f3564027bf3..46e80cc0c0d 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -148,8 +148,15 @@ void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, EmitValueImpl(Value, Size, Loc); } -void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size) { - EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size); +void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, + bool IsSectionRelative) { + assert((!IsSectionRelative || Size == 4) && + "SectionRelative value requires 4-bytes"); + + if (!IsSectionRelative) + EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size); + else + EmitCOFFSecRel32(Sym); } void MCStreamer::EmitGPRel64Value(const MCExpr *Value) { |