WasmObject.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===- WasmObject.h ---------------------------------------------*- C++ -*-===//
  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. #ifndef LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H
  9. #define LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H
  10. #include "llvm/ADT/ArrayRef.h"
  11. #include "llvm/ADT/StringRef.h"
  12. #include "llvm/Object/Wasm.h"
  13. #include "llvm/Support/MemoryBuffer.h"
  14. #include <vector>
  15. namespace llvm {
  16. namespace objcopy {
  17. namespace wasm {
  18. struct Section {
  19. // For now, each section is only an opaque binary blob with no distinction
  20. // between custom and known sections.
  21. uint8_t SectionType;
  22. StringRef Name;
  23. ArrayRef<uint8_t> Contents;
  24. };
  25. struct Object {
  26. llvm::wasm::WasmObjectHeader Header;
  27. // For now don't discriminate between kinds of sections.
  28. std::vector<Section> Sections;
  29. void addSectionWithOwnedContents(Section NewSection,
  30. std::unique_ptr<MemoryBuffer> &&Content);
  31. void removeSections(function_ref<bool(const Section &)> ToRemove);
  32. private:
  33. std::vector<std::unique_ptr<MemoryBuffer>> OwnedContents;
  34. };
  35. } // end namespace wasm
  36. } // end namespace objcopy
  37. } // end namespace llvm
  38. #endif // LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H