blob: 0c416483663f2fd82609de67033cad28e689f9bb [file] [log] [blame]
Derek Schuffb2c44de2020-02-11 15:13:40 -08001//===- Object.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 "Object.h"
10
11#include "llvm/Support/LEB128.h"
12#include "llvm/Support/raw_ostream.h"
13
14namespace llvm {
15namespace objcopy {
16namespace wasm {
17
18using namespace object;
19using namespace llvm::wasm;
20
21void Object::addSectionWithOwnedContents(
22 Section NewSection, std::unique_ptr<MemoryBuffer> &&Content) {
23 Sections.push_back(NewSection);
24 OwnedContents.emplace_back(std::move(Content));
25}
26
27void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
28 // TODO: remove reloc sections for the removed section, handle symbols, etc.
29 Sections.erase(
30 std::remove_if(std::begin(Sections), std::end(Sections), ToRemove),
31 std::end(Sections));
32}
33
34} // end namespace wasm
35} // end namespace objcopy
36} // end namespace llvm