diff options
Diffstat (limited to 'llvm/lib/MC')
| -rw-r--r-- | llvm/lib/MC/MCParser/WasmAsmParser.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 11 |
2 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp b/llvm/lib/MC/MCParser/WasmAsmParser.cpp index 197e9052566..1054b871052 100644 --- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp +++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp @@ -135,9 +135,10 @@ public: SectionKind Kind; }; static SectionType SectionTypes[] = { - { ".text", SectionKind::getText() }, - { ".rodata", SectionKind::getReadOnly() }, - { ".data", SectionKind::getData() }, + {".text", SectionKind::getText()}, + {".rodata", SectionKind::getReadOnly()}, + {".data", SectionKind::getData()}, + {".custom_section", SectionKind::getMetadata()}, // TODO: add more types. }; for (size_t I = 0; I < sizeof(SectionTypes) / sizeof(SectionType); I++) { diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index e82ed5898b4..0014b695b90 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -250,6 +250,7 @@ class WasmObjectWriter : public MCObjectWriter { // section. std::vector<WasmCustomSection> CustomSections; std::unique_ptr<WasmCustomSection> ProducersSection; + std::unique_ptr<WasmCustomSection> TargetFeaturesSection; // Relocations for fixing up references in the custom sections. DenseMap<const MCSectionWasm *, std::vector<WasmRelocationEntry>> CustomSectionsRelocations; @@ -291,6 +292,7 @@ private: DataLocations.clear(); CustomSections.clear(); ProducersSection.reset(); + TargetFeaturesSection.reset(); CustomSectionsRelocations.clear(); SignatureIndices.clear(); Signatures.clear(); @@ -1286,11 +1288,16 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm, Twine(SectionName)); } - // Separate out the producers section + // Separate out the producers and target features sections if (Name == "producers") { ProducersSection = llvm::make_unique<WasmCustomSection>(Name, &Section); continue; } + if (Name == "target_features") { + TargetFeaturesSection = + llvm::make_unique<WasmCustomSection>(Name, &Section); + continue; + } CustomSections.emplace_back(Name, &Section); } @@ -1593,6 +1600,8 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm, writeCustomRelocSections(); if (ProducersSection) writeCustomSection(*ProducersSection, Asm, Layout); + if (TargetFeaturesSection) + writeCustomSection(*TargetFeaturesSection, Asm, Layout); // TODO: Translate the .comment section to the output. return W.OS.tell() - StartOffset; |

