Index: lld/trunk/test/wasm/custom-sections.ll =================================================================== --- lld/trunk/test/wasm/custom-sections.ll +++ lld/trunk/test/wasm/custom-sections.ll @@ -16,7 +16,7 @@ ; CHECK: - Type: CUSTOM ; CHECK-NEXT: Name: green -; CHECK-NEXT: Payload: '05677265656E626172717578' +; CHECK-NEXT: Payload: '626172717578' ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: red -; CHECK-NEXT: Payload: 037265646578747261666F6F +; CHECK-NEXT: Payload: 6578747261666F6F Index: lld/trunk/wasm/InputChunks.h =================================================================== --- lld/trunk/wasm/InputChunks.h +++ lld/trunk/wasm/InputChunks.h @@ -176,20 +176,22 @@ // Represents a single Wasm Section within an input file. class InputSection : public InputChunk { public: - InputSection(const WasmSection &S, ObjFile *F); + InputSection(const WasmSection &S, ObjFile *F) + : InputChunk(F, InputChunk::Section), Section(S) { + assert(Section.Type == llvm::wasm::WASM_SEC_CUSTOM); + } StringRef getName() const override { return Section.Name; } uint32_t getComdat() const override { return UINT32_MAX; } protected: - ArrayRef data() const override { return Payload; } + ArrayRef data() const override { return Section.Content; } // Offset within the input section. This is only zero since this chunk // type represents an entire input section, not part of one. uint32_t getInputSectionOffset() const override { return 0; } const WasmSection &Section; - ArrayRef Payload; }; } // namespace wasm Index: lld/trunk/wasm/InputChunks.cpp =================================================================== --- lld/trunk/wasm/InputChunks.cpp +++ lld/trunk/wasm/InputChunks.cpp @@ -143,13 +143,3 @@ assert(!hasTableIndex()); TableIndex = Index; } - -InputSection::InputSection(const WasmSection &S, ObjFile *F) - : InputChunk(F, InputChunk::Section), Section(S) { - assert(Section.Type == llvm::wasm::WASM_SEC_CUSTOM); - // TODO check LEB errors - unsigned Count; - uint64_t NameSize = llvm::decodeULEB128(Section.Content.data(), &Count); - uint32_t PayloadOffset = Count + NameSize; - Payload = Section.Content.slice(PayloadOffset); -}