Index: lld/ELF/InputFiles.cpp =================================================================== --- lld/ELF/InputFiles.cpp +++ lld/ELF/InputFiles.cpp @@ -15,6 +15,7 @@ #include "SyntheticSections.h" #include "lld/Common/ErrorHandler.h" #include "lld/Common/Memory.h" +#include "lld/Common/Strings.h" #include "llvm/ADT/STLExtras.h" #include "llvm/CodeGen/Analysis.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" Index: lld/ELF/Strings.h =================================================================== --- lld/ELF/Strings.h +++ lld/ELF/Strings.h @@ -65,10 +65,6 @@ private: std::vector Patterns; }; - -inline ArrayRef toArrayRef(StringRef S) { - return {(const uint8_t *)S.data(), S.size()}; -} } // namespace elf } // namespace lld Index: lld/include/lld/Common/Strings.h =================================================================== --- lld/include/lld/Common/Strings.h +++ lld/include/lld/Common/Strings.h @@ -10,6 +10,7 @@ #ifndef LLD_STRINGS_H #define LLD_STRINGS_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include @@ -18,6 +19,10 @@ // Returns a demangled C++ symbol name. If Name is not a mangled // name, it returns Optional::None. llvm::Optional demangleItanium(llvm::StringRef Name); + +inline llvm::ArrayRef toArrayRef(llvm::StringRef S) { + return {reinterpret_cast(S.data()), S.size()}; +} } #endif Index: lld/wasm/Writer.cpp =================================================================== --- lld/wasm/Writer.cpp +++ lld/wasm/Writer.cpp @@ -17,6 +17,7 @@ #include "WriterUtils.h" #include "lld/Common/ErrorHandler.h" #include "lld/Common/Memory.h" +#include "lld/Common/Strings.h" #include "lld/Common/Threads.h" #include "llvm/ADT/DenseSet.h" #include "llvm/BinaryFormat/Wasm.h" @@ -877,7 +878,6 @@ // First write the body bytes to a string. std::string FunctionBody; - const WasmSignature *Signature = WasmSym::CallCtors->getFunctionType(); { raw_string_ostream OS(FunctionBody); writeUleb128(OS, 0, "num locals"); @@ -893,11 +893,11 @@ writeUleb128(OS, FunctionBody.size(), "function size"); OS.flush(); CtorFunctionBody += FunctionBody; - ArrayRef BodyArray( - reinterpret_cast(CtorFunctionBody.data()), - CtorFunctionBody.size()); - SyntheticFunction *F = make(*Signature, BodyArray, - WasmSym::CallCtors->getName()); + + const WasmSignature *Sig = WasmSym::CallCtors->getFunctionType(); + SyntheticFunction *F = make( + *Sig, toArrayRef(CtorFunctionBody), WasmSym::CallCtors->getName()); + F->setOutputIndex(FunctionIndex); F->Live = true; WasmSym::CallCtors->Function = F;