1 //===- Reader.cpp ---------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "Reader.h" 10 11 namespace llvm { 12 namespace objcopy { 13 namespace wasm { 14 15 using namespace object; 16 using namespace llvm::wasm; 17 create() const18Expected<std::unique_ptr<Object>> Reader::create() const { 19 auto Obj = std::make_unique<Object>(); 20 Obj->Header = WasmObj.getHeader(); 21 std::vector<Section> Sections; 22 Obj->Sections.reserve(WasmObj.getNumSections()); 23 for (const SectionRef &Sec : WasmObj.sections()) { 24 const WasmSection &WS = WasmObj.getWasmSection(Sec); 25 Obj->Sections.push_back( 26 {static_cast<uint8_t>(WS.Type), WS.Name, WS.Content}); 27 } 28 return std::move(Obj); 29 } 30 31 } // end namespace wasm 32 } // end namespace objcopy 33 } // end namespace llvm 34