diff options
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 32 | ||||
-rw-r--r-- | llvm/lib/MC/MCWasmStreamer.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 17 |
4 files changed, 32 insertions, 29 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index e7bd045c757..5c25e902bbe 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -486,17 +486,17 @@ MCSectionCOFF *MCContext::getAssociativeCOFFSection(MCSectionCOFF *Sec, "", 0, UniqueID); } -MCSectionWasm *MCContext::getWasmSection(const Twine &Section, unsigned Type, +MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind K, const Twine &Group, unsigned UniqueID, const char *BeginSymName) { MCSymbolWasm *GroupSym = nullptr; if (!Group.isTriviallyEmpty() && !Group.str().empty()) GroupSym = cast<MCSymbolWasm>(getOrCreateSymbol(Group)); - return getWasmSection(Section, Type, GroupSym, UniqueID, BeginSymName); + return getWasmSection(Section, K, GroupSym, UniqueID, BeginSymName); } -MCSectionWasm *MCContext::getWasmSection(const Twine &Section, unsigned Type, +MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind, const MCSymbolWasm *GroupSym, unsigned UniqueID, const char *BeginSymName) { @@ -512,14 +512,12 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, unsigned Type, StringRef CachedName = Entry.first.SectionName; - SectionKind Kind = SectionKind::getText(); - MCSymbol *Begin = nullptr; if (BeginSymName) Begin = createTempSymbol(BeginSymName, false); MCSectionWasm *Result = new (WasmAllocator.Allocate()) - MCSectionWasm(CachedName, Type, Kind, GroupSym, UniqueID, Begin); + MCSectionWasm(CachedName, Kind, GroupSym, UniqueID, Begin); Entry.second = Result; return Result; } diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index e162e954687..d8077df1469 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -824,24 +824,24 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) { void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) { // TODO: Set the section types and flags. - TextSection = Ctx->getWasmSection(".text", wasm::WASM_SEC_CODE); - DataSection = Ctx->getWasmSection(".data", wasm::WASM_SEC_DATA); + TextSection = Ctx->getWasmSection(".text", SectionKind::getText()); + DataSection = Ctx->getWasmSection(".data", SectionKind::getData()); // TODO: Set the section types and flags. - DwarfLineSection = Ctx->getWasmSection(".debug_line", wasm::WASM_SEC_DATA); - DwarfStrSection = Ctx->getWasmSection(".debug_str", wasm::WASM_SEC_DATA); - DwarfLocSection = Ctx->getWasmSection(".debug_loc", wasm::WASM_SEC_DATA); - DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", wasm::WASM_SEC_DATA, "section_abbrev"); - DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", wasm::WASM_SEC_DATA); - DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", wasm::WASM_SEC_DATA, "debug_range"); - DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", wasm::WASM_SEC_DATA, "debug_macinfo"); - DwarfAddrSection = Ctx->getWasmSection(".debug_addr", wasm::WASM_SEC_DATA); - DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", wasm::WASM_SEC_DATA); - DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", wasm::WASM_SEC_DATA); - DwarfInfoSection = Ctx->getWasmSection(".debug_info", wasm::WASM_SEC_DATA, "section_info"); - DwarfFrameSection = Ctx->getWasmSection(".debug_frame", wasm::WASM_SEC_DATA); - DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", wasm::WASM_SEC_DATA); - DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", wasm::WASM_SEC_DATA); + DwarfLineSection = Ctx->getWasmSection(".debug_line", SectionKind::getMetadata()); + DwarfStrSection = Ctx->getWasmSection(".debug_str", SectionKind::getMetadata()); + DwarfLocSection = Ctx->getWasmSection(".debug_loc", SectionKind::getMetadata()); + DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata(), "section_abbrev"); + DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", SectionKind::getMetadata()); + DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata(), "debug_range"); + DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata(), "debug_macinfo"); + DwarfAddrSection = Ctx->getWasmSection(".debug_addr", SectionKind::getMetadata()); + DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata()); + DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata()); + DwarfInfoSection = Ctx->getWasmSection(".debug_info", SectionKind::getMetadata(), "section_info"); + DwarfFrameSection = Ctx->getWasmSection(".debug_frame", SectionKind::getMetadata()); + DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata()); + DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata()); // TODO: Define more sections. } diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp index 5399f4ae58e..287b7cf7b23 100644 --- a/llvm/lib/MC/MCWasmStreamer.cpp +++ b/llvm/lib/MC/MCWasmStreamer.cpp @@ -157,7 +157,7 @@ void MCWasmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value, void MCWasmStreamer::EmitIdent(StringRef IdentString) { MCSection *Comment = getAssembler().getContext().getWasmSection( - ".comment", wasm::WASM_SEC_DATA); + ".comment", SectionKind::getMetadata()); PushSection(); SwitchSection(Comment); if (!SeenIdent) { diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 55e7c93c87e..44f2ba6ed7d 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -437,10 +437,13 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm, WasmRelocationEntry Rec(FixupOffset, SymA, C, Type, &FixupSection); DEBUG(dbgs() << "WasmReloc: " << Rec << "\n"); - if (FixupSection.hasInstructions()) - CodeRelocations.push_back(Rec); - else + if (FixupSection.isWasmData()) DataRelocations.push_back(Rec); + else if (FixupSection.getKind().isText()) + CodeRelocations.push_back(Rec); + else if (!FixupSection.getKind().isMetadata()) + // TODO(sbc): Add support for debug sections. + llvm_unreachable("unexpected section type"); } // Write X as an (unsigned) LEB value at offset Offset in Stream, padded @@ -1060,7 +1063,8 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm, // In the special .global_variables section, we've encoded global // variables used by the function. Translate them into the Globals // list. - MCSectionWasm *GlobalVars = Ctx.getWasmSection(".global_variables", wasm::WASM_SEC_DATA); + MCSectionWasm *GlobalVars = + Ctx.getWasmSection(".global_variables", SectionKind::getMetadata()); if (!GlobalVars->getFragmentList().empty()) { if (GlobalVars->getFragmentList().size() != 1) report_fatal_error("only one .global_variables fragment supported"); @@ -1116,7 +1120,8 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm, // In the special .stack_pointer section, we've encoded the stack pointer // index. - MCSectionWasm *StackPtr = Ctx.getWasmSection(".stack_pointer", wasm::WASM_SEC_DATA); + MCSectionWasm *StackPtr = + Ctx.getWasmSection(".stack_pointer", SectionKind::getMetadata()); if (!StackPtr->getFragmentList().empty()) { if (StackPtr->getFragmentList().size() != 1) report_fatal_error("only one .stack_pointer fragment supported"); @@ -1135,7 +1140,7 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm, for (MCSection &Sec : Asm) { auto &Section = static_cast<MCSectionWasm &>(Sec); - if (Section.getType() != wasm::WASM_SEC_DATA) + if (!Section.isWasmData()) continue; DataSize = alignTo(DataSize, Section.getAlignment()); |