summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/wasm/OutputSections.cpp14
-rw-r--r--lld/wasm/OutputSections.h2
2 files changed, 8 insertions, 8 deletions
diff --git a/lld/wasm/OutputSections.cpp b/lld/wasm/OutputSections.cpp
index c1ae8160fb8..915f0aa3b3e 100644
--- a/lld/wasm/OutputSections.cpp
+++ b/lld/wasm/OutputSections.cpp
@@ -55,20 +55,20 @@ static StringRef sectionTypeToString(uint32_t SectionType) {
}
}
-std::string lld::toString(const OutputSection &Section) {
- std::string rtn = Section.getSectionName();
- if (!Section.Name.empty())
- rtn += "(" + Section.Name + ")";
- return rtn;
+// Returns a string, e.g. "FUNCTION(.text)".
+std::string lld::toString(const OutputSection &Sec) {
+ if (!Sec.Name.empty())
+ 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();
diff --git a/lld/wasm/OutputSections.h b/lld/wasm/OutputSections.h
index f6344657b71..2ecee951757 100644
--- a/lld/wasm/OutputSections.h
+++ b/lld/wasm/OutputSections.h
@@ -35,7 +35,7 @@ public:
: 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;
OpenPOWER on IntegriCloud