[llvm] 5ea83ee - Revert "[llvm-objcopy] Initial support for wasm in llvm-objcopy"

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 13:13:36 PST 2020


Author: Derek Schuff
Date: 2020-01-29T13:12:56-08:00
New Revision: 5ea83eef4d6c70d49cd32474be3f0a1b2e81a901

URL: https://github.com/llvm/llvm-project/commit/5ea83eef4d6c70d49cd32474be3f0a1b2e81a901
DIFF: https://github.com/llvm/llvm-project/commit/5ea83eef4d6c70d49cd32474be3f0a1b2e81a901.diff

LOG: Revert "[llvm-objcopy] Initial support for wasm in llvm-objcopy"

This reverts commit a928d127a52a061733d2e42c4c9159a267f7dbd4.

It seems to cause issues with big-endian architectures.

Added: 
    

Modified: 
    llvm/include/llvm/Object/Wasm.h
    llvm/tools/llvm-objcopy/CMakeLists.txt
    llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Removed: 
    llvm/test/tools/llvm-objcopy/wasm/basic-archive-copy.test
    llvm/test/tools/llvm-objcopy/wasm/basic-copy.test
    llvm/tools/llvm-objcopy/wasm/Object.h
    llvm/tools/llvm-objcopy/wasm/Reader.cpp
    llvm/tools/llvm-objcopy/wasm/Reader.h
    llvm/tools/llvm-objcopy/wasm/WasmObjcopy.cpp
    llvm/tools/llvm-objcopy/wasm/WasmObjcopy.h
    llvm/tools/llvm-objcopy/wasm/Writer.cpp
    llvm/tools/llvm-objcopy/wasm/Writer.h


################################################################################
diff  --git a/llvm/include/llvm/Object/Wasm.h b/llvm/include/llvm/Object/Wasm.h
index b3cbb5703605..8d6b914ff9fe 100644
--- a/llvm/include/llvm/Object/Wasm.h
+++ b/llvm/include/llvm/Object/Wasm.h
@@ -152,7 +152,6 @@ class WasmObjectFile : public ObjectFile {
   uint32_t getNumImportedGlobals() const { return NumImportedGlobals; }
   uint32_t getNumImportedFunctions() const { return NumImportedFunctions; }
   uint32_t getNumImportedEvents() const { return NumImportedEvents; }
-  uint32_t getNumSections() const { return Sections.size(); }
   void moveSymbolNext(DataRefImpl &Symb) const override;
 
   uint32_t getSymbolFlags(DataRefImpl Symb) const override;

diff  --git a/llvm/test/tools/llvm-objcopy/wasm/basic-archive-copy.test b/llvm/test/tools/llvm-objcopy/wasm/basic-archive-copy.test
deleted file mode 100644
index 31ad14a0ed0c..000000000000
--- a/llvm/test/tools/llvm-objcopy/wasm/basic-archive-copy.test
+++ /dev/null
@@ -1,90 +0,0 @@
-## Test a basic copy of an archive containing a wasm object.
-
-# RUN: yaml2obj %s -o %t
-
-## Create an archive and copy it using llvm-objcopy.
-# RUN: rm -f %t.a
-# RUN: llvm-ar crs %t.a %t
-# RUN: cp %t.a %t.copy.a
-# RUN: llvm-objcopy %t.a %t2.a
-## Create another archive from an objcopy-copied object, verify that they match.
-# RUN: llvm-objcopy %t %t2
-# RUN: llvm-ar p %t2.a > %t3
-# RUN: cmp %t2 %t3
-
-## Check that the copied archive has the correct index contents.
-# RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=INDEX-TABLE %s
-# RUN: llvm-nm --print-armap %t2.a | FileCheck --check-prefix=INDEX-TABLE %s
-## Verify that llvm-objcopy has not modifed the input.
-# RUN: cmp %t.copy.a %t.a
-
-# INDEX-TABLE: Archive map
-# INDEX-TABLE-NEXT: func1 in
-
-## Do the same with an archive that has no index.
-# RUN: rm -f %t.no.index.a
-# RUN: llvm-ar crS %t.no.index.a %t
-# RUN: llvm-objcopy %t.no.index.a %t2.no.index.a
-# RUN: llvm-ar p %t2.no.index.a > %t4
-
-# RUN: llvm-nm --print-armap %t.no.index.a | FileCheck --check-prefix=NO-INDEX-TABLE %s
-# RUN: llvm-nm --print-armap %t2.no.index.a | FileCheck --check-prefix=NO-INDEX-TABLE %s
-# RUN: cmp %t2 %t4
-
-# NO-INDEX-TABLE-NOT: Archive map
-# NO-INDEX-TABLE-NOT: func1 in
-
---- !WASM
-FileHeader:
-  Version: 0x00000001
-Sections:
-  - Type: TYPE
-    Signatures:
-      - Index: 0
-        ParamTypes:
-          - I32
-        ReturnTypes:
-          - F32
-      - Index: 1
-        ParamTypes:
-          - I32
-          - I64
-        ReturnTypes:     []
-  - Type: FUNCTION
-    FunctionTypes:
-      - 0
-      - 1
-  - Type: CODE
-    Relocations:
-      - Type:   R_WASM_TABLE_INDEX_SLEB
-        Index:  0
-        Offset: 0x00000002
-      - Type:   R_WASM_FUNCTION_INDEX_LEB
-        Index:  1
-        Offset: 0x0000002
-    Functions:
-      - Index:  0
-        Locals:
-         - Type:  I32
-           Count: 3
-        Body: 010101010B
-      - Index: 1
-        Locals:
-         - Type: I32
-           Count: 1
-        Body: 010101010B
-  - Type: CUSTOM
-    Name:    linking
-    Version: 2
-    SymbolTable:
-      - Index: 0
-        Kind:  FUNCTION
-        Name:  func1
-        Flags: [  ]
-        Function: 0
-      - Index: 1
-        Kind:  FUNCTION
-        Name:  func2
-        Flags: [  ]
-        Function: 1
-...

diff  --git a/llvm/test/tools/llvm-objcopy/wasm/basic-copy.test b/llvm/test/tools/llvm-objcopy/wasm/basic-copy.test
deleted file mode 100644
index 4eb463435f4c..000000000000
--- a/llvm/test/tools/llvm-objcopy/wasm/basic-copy.test
+++ /dev/null
@@ -1,63 +0,0 @@
-## Test that the copied object has the same yaml conversion as the original.
-## The copied object is not bit-identical to the yaml2obj-generated
-## one, as yaml2obj uses 5-byte LEBs for section sizes (unlike objcopy/clang).
-# RUN: yaml2obj %s -o %t.o
-# RUN: llvm-objcopy %t.o %t2.o
-# RUN: obj2yaml %t.o > %t.yaml
-# RUN: obj2yaml %t2.o > %t2.yaml
-# RUN: 
diff  %t.yaml %t2.yaml
-
---- !WASM
-FileHeader:
-  Version: 0x00000001
-Sections:
-  - Type: TYPE
-    Signatures:
-      - Index: 0
-        ParamTypes:
-          - I32
-        ReturnTypes:
-          - F32
-      - Index: 1
-        ParamTypes:
-          - I32
-          - I64
-        ReturnTypes:     []
-  - Type: FUNCTION
-    FunctionTypes:
-      - 0
-      - 1
-  - Type: CODE
-    Relocations:
-      - Type:   R_WASM_TABLE_INDEX_SLEB
-        Index:  0
-        Offset: 0x00000002
-      - Type:   R_WASM_FUNCTION_INDEX_LEB
-        Index:  1
-        Offset: 0x0000002
-    Functions:
-      - Index:  0
-        Locals:
-         - Type:  I32
-           Count: 3
-        Body: 010101010B
-      - Index: 1
-        Locals:
-         - Type: I32
-           Count: 1
-        Body: 010101010B
-  - Type: CUSTOM
-    Name:    linking
-    Version: 2
-    SymbolTable:
-      - Index: 0
-        Kind:  FUNCTION
-        Name:  func1
-        Flags: [  ]
-        Function: 0
-      - Index: 1
-        Kind: FUNCTION
-        Name: func2
-        Flags: [  ]
-        Function: 1
-...

diff  --git a/llvm/tools/llvm-objcopy/CMakeLists.txt b/llvm/tools/llvm-objcopy/CMakeLists.txt
index b3706bc69177..6d4048f040ba 100644
--- a/llvm/tools/llvm-objcopy/CMakeLists.txt
+++ b/llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -33,9 +33,6 @@ add_llvm_tool(llvm-objcopy
   MachO/MachOWriter.cpp
   MachO/MachOLayoutBuilder.cpp
   MachO/Object.cpp
-  wasm/Reader.cpp
-  wasm/Writer.cpp
-  wasm/WasmObjcopy.cpp
   DEPENDS
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen

diff  --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index 61efc742767d..e662f35f4b08 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -8,11 +8,10 @@
 
 #include "llvm-objcopy.h"
 #include "Buffer.h"
-#include "COFF/COFFObjcopy.h"
 #include "CopyConfig.h"
 #include "ELF/ELFObjcopy.h"
+#include "COFF/COFFObjcopy.h"
 #include "MachO/MachOObjcopy.h"
-#include "wasm/WasmObjcopy.h"
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
@@ -26,7 +25,6 @@
 #include "llvm/Object/ELFTypes.h"
 #include "llvm/Object/Error.h"
 #include "llvm/Object/MachO.h"
-#include "llvm/Object/Wasm.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
@@ -174,8 +172,6 @@ static Error executeObjcopyOnBinary(CopyConfig &Config, object::Binary &In,
     return coff::executeObjcopyOnBinary(Config, *COFFBinary, Out);
   else if (auto *MachOBinary = dyn_cast<object::MachOObjectFile>(&In))
     return macho::executeObjcopyOnBinary(Config, *MachOBinary, Out);
-  else if (auto *WasmBinary = dyn_cast<object::WasmObjectFile>(&In))
-    return objcopy::wasm::executeObjcopyOnBinary(Config, *WasmBinary, Out);
   else
     return createStringError(object_error::invalid_file_type,
                              "unsupported object file format");

diff  --git a/llvm/tools/llvm-objcopy/wasm/Object.h b/llvm/tools/llvm-objcopy/wasm/Object.h
deleted file mode 100644
index 78a43be21d47..000000000000
--- a/llvm/tools/llvm-objcopy/wasm/Object.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//===- Object.h -------------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVM_OBJCOPY_WASM_OBJECT_H
-#define LLVM_TOOLS_LLVM_OBJCOPY_WASM_OBJECT_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Object/Wasm.h"
-#include <vector>
-
-namespace llvm {
-namespace objcopy {
-namespace wasm {
-
-struct Section {
-  // For now, each section is only an opaque binary blob with no distinction
-  // between custom and known sections.
-  uint8_t SectionType;
-  StringRef Name;
-  ArrayRef<uint8_t> Contents;
-};
-
-struct Object {
-  llvm::wasm::WasmObjectHeader Header;
-  // For now don't discriminate between kinds of sections.
-  std::vector<Section> Sections;
-};
-
-} // end namespace wasm
-} // end namespace objcopy
-} // end namespace llvm
-
-#endif // LLVM_TOOLS_LLVM_OBJCOPY_WASM_OBJECT_H

diff  --git a/llvm/tools/llvm-objcopy/wasm/Reader.cpp b/llvm/tools/llvm-objcopy/wasm/Reader.cpp
deleted file mode 100644
index 13fa84ad8020..000000000000
--- a/llvm/tools/llvm-objcopy/wasm/Reader.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-//===- Reader.cpp ---------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Reader.h"
-
-namespace llvm {
-namespace objcopy {
-namespace wasm {
-
-using namespace object;
-using namespace llvm::wasm;
-
-Expected<std::unique_ptr<Object>> Reader::create() const {
-  auto Obj = std::make_unique<Object>();
-  Obj->Header = WasmObj.getHeader();
-  std::vector<Section> Sections;
-  Obj->Sections.reserve(WasmObj.getNumSections());
-  for (const SectionRef &Sec : WasmObj.sections()) {
-    const WasmSection &WS = WasmObj.getWasmSection(Sec);
-    Obj->Sections.push_back(
-        {static_cast<uint8_t>(WS.Type), WS.Name, WS.Content});
-  }
-  return std::move(Obj);
-}
-
-} // end namespace wasm
-} // end namespace objcopy
-} // end namespace llvm

diff  --git a/llvm/tools/llvm-objcopy/wasm/Reader.h b/llvm/tools/llvm-objcopy/wasm/Reader.h
deleted file mode 100644
index 2dcf7dde029a..000000000000
--- a/llvm/tools/llvm-objcopy/wasm/Reader.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===- Reader.h -------------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVM_OBJCOPY_WASM_READER_H
-#define LLVM_TOOLS_LLVM_OBJCOPY_WASM_READER_H
-
-#include "Object.h"
-
-namespace llvm {
-namespace objcopy {
-namespace wasm {
-
-class Reader {
-public:
-  explicit Reader(const object::WasmObjectFile &O) : WasmObj(O) {}
-  Expected<std::unique_ptr<Object>> create() const;
-
-private:
-  const object::WasmObjectFile &WasmObj;
-};
-
-} // end namespace wasm
-} // end namespace objcopy
-} // end namespace llvm
-
-#endif // LLVM_TOOLS_LLVM_OBJCOPY_WASM_READER_H

diff  --git a/llvm/tools/llvm-objcopy/wasm/WasmObjcopy.cpp b/llvm/tools/llvm-objcopy/wasm/WasmObjcopy.cpp
deleted file mode 100644
index 41816a0b08ad..000000000000
--- a/llvm/tools/llvm-objcopy/wasm/WasmObjcopy.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//===- WasmObjcopy.cpp ----------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "WasmObjcopy.h"
-#include "Buffer.h"
-#include "CopyConfig.h"
-#include "Object.h"
-#include "Reader.h"
-#include "Writer.h"
-#include "llvm-objcopy.h"
-#include "llvm/Support/Errc.h"
-
-namespace llvm {
-namespace objcopy {
-namespace wasm {
-
-using namespace object;
-
-static Error handleArgs(const CopyConfig &Config, Object &Obj) {
-  if (!Config.AddGnuDebugLink.empty() || !Config.BuildIdLinkDir.empty() ||
-      Config.BuildIdLinkInput || Config.BuildIdLinkOutput ||
-      Config.ExtractPartition || !Config.SplitDWO.empty() ||
-      !Config.SymbolsPrefix.empty() || !Config.AllocSectionsPrefix.empty() ||
-      Config.DiscardMode != DiscardType::None || Config.NewSymbolVisibility ||
-      !Config.SymbolsToAdd.empty() || !Config.RPathToAdd.empty() ||
-      !Config.OnlySection.empty() || !Config.SymbolsToGlobalize.empty() ||
-      !Config.SymbolsToKeep.empty() || !Config.SymbolsToLocalize.empty() ||
-      !Config.SymbolsToRemove.empty() ||
-      !Config.UnneededSymbolsToRemove.empty() ||
-      !Config.SymbolsToWeaken.empty() || !Config.SymbolsToKeepGlobal.empty() ||
-      !Config.SectionsToRename.empty() || !Config.SetSectionAlignment.empty() ||
-      !Config.SetSectionFlags.empty() || !Config.SymbolsToRename.empty() ||
-      !Config.ToRemove.empty() || !Config.DumpSection.empty() ||
-      !Config.AddSection.empty()) {
-    return createStringError(
-        llvm::errc::invalid_argument,
-        "no flags are supported yet, only basic copying is allowed");
-  }
-  return Error::success();
-}
-
-Error executeObjcopyOnBinary(const CopyConfig &Config,
-                             object::WasmObjectFile &In, Buffer &Out) {
-  Reader TheReader(In);
-  Expected<std::unique_ptr<Object>> ObjOrErr = TheReader.create();
-  if (!ObjOrErr)
-    return createFileError(Config.InputFilename, ObjOrErr.takeError());
-  Object *Obj = ObjOrErr->get();
-  assert(Obj && "Unable to deserialize Wasm object");
-  if (Error E = handleArgs(Config, *Obj))
-    return createFileError(Config.InputFilename, std::move(E));
-  Writer TheWriter(*Obj, Out);
-  if (Error E = TheWriter.write())
-    return createFileError(Config.OutputFilename, std::move(E));
-  return Error::success();
-}
-
-} // end namespace wasm
-} // end namespace objcopy
-} // end namespace llvm

diff  --git a/llvm/tools/llvm-objcopy/wasm/WasmObjcopy.h b/llvm/tools/llvm-objcopy/wasm/WasmObjcopy.h
deleted file mode 100644
index 3557d5c0a50d..000000000000
--- a/llvm/tools/llvm-objcopy/wasm/WasmObjcopy.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===- WasmObjcopy.h -------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVM_OBJCOPY_WASM_WASMOBJCOPY_H
-#define LLVM_TOOLS_LLVM_OBJCOPY_WASM_WASMOBJCOPY_H
-
-namespace llvm {
-class Error;
-
-namespace object {
-class WasmObjectFile;
-} // end namespace object
-
-namespace objcopy {
-struct CopyConfig;
-class Buffer;
-
-namespace wasm {
-Error executeObjcopyOnBinary(const CopyConfig &Config,
-                             object::WasmObjectFile &In, Buffer &Out);
-
-} // end namespace wasm
-} // end namespace objcopy
-} // end namespace llvm
-
-#endif // LLVM_TOOLS_LLVM_OBJCOPY_WASM_WASMOBJCOPY_H

diff  --git a/llvm/tools/llvm-objcopy/wasm/Writer.cpp b/llvm/tools/llvm-objcopy/wasm/Writer.cpp
deleted file mode 100644
index f3ceef05ddae..000000000000
--- a/llvm/tools/llvm-objcopy/wasm/Writer.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-//===- Writer.cpp ---------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Writer.h"
-
-#include "llvm/BinaryFormat/Wasm.h"
-#include "llvm/Support/LEB128.h"
-#include "llvm/Support/raw_ostream.h"
-
-namespace llvm {
-namespace objcopy {
-namespace wasm {
-
-using namespace object;
-using namespace llvm::wasm;
-
-Writer::SectionHeader Writer::createSectionHeader(const Section &S,
-                                                  size_t &SectionSize) {
-  SectionHeader Header;
-  raw_svector_ostream OS(Header);
-  OS << S.SectionType;
-  bool HasName = S.SectionType == WASM_SEC_CUSTOM;
-  SectionSize = S.Contents.size();
-  if (HasName)
-    SectionSize += getULEB128Size(S.Name.size()) + S.Name.size();
-  // Pad the LEB value out to 5 bytes to make it a predictable size, and
-  // match the behavior of clang.
-  encodeULEB128(SectionSize, OS, 5);
-  if (HasName) {
-    encodeULEB128(S.Name.size(), OS);
-    OS << S.Name;
-  }
-  // Total section size is the content size plus 1 for the section type and
-  // 5 for the LEB-encoded size.
-  SectionSize = SectionSize + 1 + 5;
-  return Header;
-}
-
-size_t Writer::finalize() {
-  size_t ObjectSize = sizeof(WasmMagic) + sizeof(WasmVersion);
-  SectionHeaders.reserve(Obj.Sections.size());
-  // Finalize the headers of each section so we know the total size.
-  for (const Section &S : Obj.Sections) {
-    size_t SectionSize;
-    SectionHeaders.push_back(createSectionHeader(S, SectionSize));
-    ObjectSize += SectionSize;
-  }
-  return ObjectSize;
-}
-
-Error Writer::write() {
-  size_t FileSize = finalize();
-  if (Error E = Buf.allocate(FileSize))
-    return E;
-
-  // Write the header.
-  uint8_t *Ptr = Buf.getBufferStart();
-  Ptr = std::copy(Obj.Header.Magic.begin(), Obj.Header.Magic.end(), Ptr);
-  memcpy(Ptr, &Obj.Header.Version, sizeof(Obj.Header.Version));
-  Ptr += sizeof(Obj.Header.Version);
-
-  // Write each section.
-  for (size_t I = 0, S = SectionHeaders.size(); I < S; ++I) {
-    Ptr = std::copy(SectionHeaders[I].begin(), SectionHeaders[I].end(), Ptr);
-    ArrayRef<uint8_t> Contents = Obj.Sections[I].Contents;
-    Ptr = std::copy(Contents.begin(), Contents.end(), Ptr);
-  }
-  return Buf.commit();
-}
-
-} // end namespace wasm
-} // end namespace objcopy
-} // end namespace llvm

diff  --git a/llvm/tools/llvm-objcopy/wasm/Writer.h b/llvm/tools/llvm-objcopy/wasm/Writer.h
deleted file mode 100644
index da48ee730c3b..000000000000
--- a/llvm/tools/llvm-objcopy/wasm/Writer.h
+++ /dev/null
@@ -1,50 +0,0 @@
-//===- Writer.h -------------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVM_OBJCOPY_WASM_WRITER_H
-#define LLVM_TOOLS_LLVM_OBJCOPY_WASM_WRITER_H
-
-#include "Buffer.h"
-#include "Object.h"
-#include <cstdint>
-#include <vector>
-
-namespace llvm {
-namespace objcopy {
-namespace wasm {
-
-class Writer {
-public:
-  Writer(Object &Obj, Buffer &Buf) : Obj(Obj), Buf(Buf) {}
-  Error write();
-
-private:
-  using SectionHeader = SmallVector<char, 8>;
-  Object &Obj;
-  Buffer &Buf;
-  std::vector<SectionHeader> SectionHeaders;
-
-  /// Generate a wasm section section header for S.
-  /// The header consists of
-  /// * A one-byte section ID (aka the section type).
-  /// * The size of the section contents, encoded as ULEB128.
-  /// * If the section is a custom section (type 0) it also has a name, which is
-  ///   encoded as a length-prefixed string. The encoded section size *includes*
-  ///   this string.
-  /// See https://webassembly.github.io/spec/core/binary/modules.html#sections
-  /// Return the header and store the total size in SectionSize.
-  static SectionHeader createSectionHeader(const Section &S,
-                                           size_t &SectionSize);
-  size_t finalize();
-};
-
-} // end namespace wasm
-} // end namespace objcopy
-} // end namespace llvm
-
-#endif // LLVM_TOOLS_LLVM_OBJCOPY_WASM_WRITER_H


        


More information about the llvm-commits mailing list