Index: lld/wasm/OutputSections.h =================================================================== --- lld/wasm/OutputSections.h +++ lld/wasm/OutputSections.h @@ -35,7 +35,7 @@ : Type(Type), Name(Name) {} virtual ~OutputSection() = default; - std::string getSectionName() const; + StringRef getSectionName() const; void setOffset(size_t NewOffset) { log("setOffset: " + toString(*this) + ": " + Twine(NewOffset)); Offset = NewOffset; Index: lld/wasm/OutputSections.cpp =================================================================== --- lld/wasm/OutputSections.cpp +++ lld/wasm/OutputSections.cpp @@ -58,17 +58,17 @@ // Returns a string, e.g. "FUNCTION(.text)". std::string lld::toString(const OutputSection &Sec) { if (!Sec.Name.empty()) - return Sec.getSectionName() + "(" + Sec.Name + ")"; + return (Sec.getSectionName() + "(" + Sec.Name + ")").str(); return Sec.getSectionName(); } -std::string OutputSection::getSectionName() const { +StringRef OutputSection::getSectionName() const { return sectionTypeToString(Type); } void OutputSection::createHeader(size_t BodySize) { raw_string_ostream OS(Header); - debugWrite(OS.tell(), "section type [" + Twine(getSectionName()) + "]"); + debugWrite(OS.tell(), "section type [" + getSectionName() + "]"); encodeULEB128(Type, OS); writeUleb128(OS, BodySize, "section size"); OS.flush();