[llvm-objcopy][WebAssembly] Add dump/add/remove-section support
Add support for adding, removing, and dumping wasm sections to objcopy
Differential Revision: https://reviews.llvm.org/D70970
diff --git a/llvm/tools/llvm-objcopy/wasm/Object.h b/llvm/tools/llvm-objcopy/wasm/Object.h
index 78a43be..9db91c4 100644
--- a/llvm/tools/llvm-objcopy/wasm/Object.h
+++ b/llvm/tools/llvm-objcopy/wasm/Object.h
@@ -12,6 +12,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/Wasm.h"
+#include "llvm/Support/MemoryBuffer.h"
#include <vector>
namespace llvm {
@@ -30,6 +31,13 @@
llvm::wasm::WasmObjectHeader Header;
// For now don't discriminate between kinds of sections.
std::vector<Section> Sections;
+
+ void addSectionWithOwnedContents(Section NewSection,
+ std::unique_ptr<MemoryBuffer> &&Content);
+ void removeSections(function_ref<bool(const Section &)> ToRemove);
+
+private:
+ std::vector<std::unique_ptr<MemoryBuffer>> OwnedContents;
};
} // end namespace wasm