Loading llvm/include/llvm/Object/Wasm.h +2 −2 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ protected: private: const uint8_t *getPtr(size_t Offset) const; Error parseUserSection(wasm::WasmSection &Sec, const uint8_t *Ptr, Error parseCustomSection(wasm::WasmSection &Sec, const uint8_t *Ptr, size_t Length); wasm::WasmObjectHeader Header; Loading llvm/include/llvm/Support/Wasm.h +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ struct WasmSection { }; enum : unsigned { WASM_SEC_USER = 0, // User-defined section WASM_SEC_CUSTOM = 0, // Custom / User-defined section WASM_SEC_TYPE = 1, // Function signature declarations WASM_SEC_IMPORT = 2, // Import declarations WASM_SEC_FUNCTION = 3, // Function declarations Loading llvm/lib/Object/WasmObjectFile.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -83,15 +83,16 @@ WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err) while (Ptr < Eof) { if ((Err = readSection(Sec, Ptr, getPtr(0)))) return; if (Sec.Type == wasm::WASM_SEC_USER) { if ((Err = parseUserSection(Sec, Sec.Content.data(), Sec.Content.size()))) if (Sec.Type == wasm::WASM_SEC_CUSTOM) { if ((Err = parseCustomSection(Sec, Sec.Content.data(), Sec.Content.size()))) return; } Sections.push_back(Sec); } } Error WasmObjectFile::parseUserSection(wasm::WasmSection &Sec, Error WasmObjectFile::parseCustomSection(wasm::WasmSection &Sec, const uint8_t *Ptr, size_t Length) { Sec.Name = readString(Ptr); return Error::success(); Loading Loading @@ -186,7 +187,7 @@ std::error_code WasmObjectFile::getSectionName(DataRefImpl Sec, ECase(ELEM); ECase(CODE); ECase(DATA); case wasm::WASM_SEC_USER: case wasm::WASM_SEC_CUSTOM: Res = S.Name; break; default: Loading llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm 0 → 100644 +165 B File added.No diff preview for this file type. View file llvm/test/tools/llvm-readobj/file-headers.test +11 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,12 @@ RUN: llvm-readobj -h %p/Inputs/magic.coff-importlib \ RUN: | FileCheck %s -check-prefix COFF-IMPORTLIB RUN: llvm-readobj -h %p/Inputs/trivial.obj.elf-lanai \ RUN: | FileCheck %s -check-prefix ELF-LANAI # trivial.obj.wasm was generated using wast2wasm which is part of the wabt # project (https://github.com/WebAssembly/wabt) using the following command: # $ wast2wasm --debug-names ./test/roundtrip/generate-some-names.txt -o \ # trivial.obj.wasm RUN: llvm-readobj -h %p/Inputs/trivial.obj.wasm \ RUN: | FileCheck %s -check-prefix WASM COFF-ARM: File: {{(.*[/\\])?}}trivial.obj.coff-arm COFF-ARM-NEXT: Format: COFF-ARM Loading Loading @@ -367,3 +373,8 @@ ELF-LANAI-NEXT: SectionHeaderEntrySize: 40 ELF-LANAI-NEXT: SectionHeaderCount: 8 ELF-LANAI-NEXT: StringTableSectionIndex: 1 ELF-LANAI-NEXT: } WASM: Format: WASM WASM-NEXT: Arch: wasm32 WASM-NEXT: AddressSize: 32bit WASM-NEXT: Version: 0xD Loading
llvm/include/llvm/Object/Wasm.h +2 −2 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ protected: private: const uint8_t *getPtr(size_t Offset) const; Error parseUserSection(wasm::WasmSection &Sec, const uint8_t *Ptr, Error parseCustomSection(wasm::WasmSection &Sec, const uint8_t *Ptr, size_t Length); wasm::WasmObjectHeader Header; Loading
llvm/include/llvm/Support/Wasm.h +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ struct WasmSection { }; enum : unsigned { WASM_SEC_USER = 0, // User-defined section WASM_SEC_CUSTOM = 0, // Custom / User-defined section WASM_SEC_TYPE = 1, // Function signature declarations WASM_SEC_IMPORT = 2, // Import declarations WASM_SEC_FUNCTION = 3, // Function declarations Loading
llvm/lib/Object/WasmObjectFile.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -83,15 +83,16 @@ WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err) while (Ptr < Eof) { if ((Err = readSection(Sec, Ptr, getPtr(0)))) return; if (Sec.Type == wasm::WASM_SEC_USER) { if ((Err = parseUserSection(Sec, Sec.Content.data(), Sec.Content.size()))) if (Sec.Type == wasm::WASM_SEC_CUSTOM) { if ((Err = parseCustomSection(Sec, Sec.Content.data(), Sec.Content.size()))) return; } Sections.push_back(Sec); } } Error WasmObjectFile::parseUserSection(wasm::WasmSection &Sec, Error WasmObjectFile::parseCustomSection(wasm::WasmSection &Sec, const uint8_t *Ptr, size_t Length) { Sec.Name = readString(Ptr); return Error::success(); Loading Loading @@ -186,7 +187,7 @@ std::error_code WasmObjectFile::getSectionName(DataRefImpl Sec, ECase(ELEM); ECase(CODE); ECase(DATA); case wasm::WASM_SEC_USER: case wasm::WASM_SEC_CUSTOM: Res = S.Name; break; default: Loading
llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm 0 → 100644 +165 B File added.No diff preview for this file type. View file
llvm/test/tools/llvm-readobj/file-headers.test +11 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,12 @@ RUN: llvm-readobj -h %p/Inputs/magic.coff-importlib \ RUN: | FileCheck %s -check-prefix COFF-IMPORTLIB RUN: llvm-readobj -h %p/Inputs/trivial.obj.elf-lanai \ RUN: | FileCheck %s -check-prefix ELF-LANAI # trivial.obj.wasm was generated using wast2wasm which is part of the wabt # project (https://github.com/WebAssembly/wabt) using the following command: # $ wast2wasm --debug-names ./test/roundtrip/generate-some-names.txt -o \ # trivial.obj.wasm RUN: llvm-readobj -h %p/Inputs/trivial.obj.wasm \ RUN: | FileCheck %s -check-prefix WASM COFF-ARM: File: {{(.*[/\\])?}}trivial.obj.coff-arm COFF-ARM-NEXT: Format: COFF-ARM Loading Loading @@ -367,3 +373,8 @@ ELF-LANAI-NEXT: SectionHeaderEntrySize: 40 ELF-LANAI-NEXT: SectionHeaderCount: 8 ELF-LANAI-NEXT: StringTableSectionIndex: 1 ELF-LANAI-NEXT: } WASM: Format: WASM WASM-NEXT: Arch: wasm32 WASM-NEXT: AddressSize: 32bit WASM-NEXT: Version: 0xD