1*25d7b4fbSAlexey Lapshin //===- WasmObject.cpp -----------------------------------------------------===//
2*25d7b4fbSAlexey Lapshin //
3*25d7b4fbSAlexey Lapshin // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*25d7b4fbSAlexey Lapshin // See https://llvm.org/LICENSE.txt for license information.
5*25d7b4fbSAlexey Lapshin // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*25d7b4fbSAlexey Lapshin //
7*25d7b4fbSAlexey Lapshin //===----------------------------------------------------------------------===//
8*25d7b4fbSAlexey Lapshin 
9*25d7b4fbSAlexey Lapshin #include "WasmObject.h"
10*25d7b4fbSAlexey Lapshin 
11*25d7b4fbSAlexey Lapshin #include "llvm/Support/LEB128.h"
12*25d7b4fbSAlexey Lapshin #include "llvm/Support/raw_ostream.h"
13*25d7b4fbSAlexey Lapshin 
14*25d7b4fbSAlexey Lapshin namespace llvm {
15*25d7b4fbSAlexey Lapshin namespace objcopy {
16*25d7b4fbSAlexey Lapshin namespace wasm {
17*25d7b4fbSAlexey Lapshin 
18*25d7b4fbSAlexey Lapshin using namespace object;
19*25d7b4fbSAlexey Lapshin using namespace llvm::wasm;
20*25d7b4fbSAlexey Lapshin 
addSectionWithOwnedContents(Section NewSection,std::unique_ptr<MemoryBuffer> && Content)21*25d7b4fbSAlexey Lapshin void Object::addSectionWithOwnedContents(
22*25d7b4fbSAlexey Lapshin     Section NewSection, std::unique_ptr<MemoryBuffer> &&Content) {
23*25d7b4fbSAlexey Lapshin   Sections.push_back(NewSection);
24*25d7b4fbSAlexey Lapshin   OwnedContents.emplace_back(std::move(Content));
25*25d7b4fbSAlexey Lapshin }
26*25d7b4fbSAlexey Lapshin 
removeSections(function_ref<bool (const Section &)> ToRemove)27*25d7b4fbSAlexey Lapshin void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
28*25d7b4fbSAlexey Lapshin   // TODO: remove reloc sections for the removed section, handle symbols, etc.
29*25d7b4fbSAlexey Lapshin   llvm::erase_if(Sections, ToRemove);
30*25d7b4fbSAlexey Lapshin }
31*25d7b4fbSAlexey Lapshin 
32*25d7b4fbSAlexey Lapshin } // end namespace wasm
33*25d7b4fbSAlexey Lapshin } // end namespace objcopy
34*25d7b4fbSAlexey Lapshin } // end namespace llvm
35