Enable finding bitcode in wasm objects
authorSam Clegg <sbc@chromium.org>
Wed, 15 Apr 2020 18:35:35 +0000 (11:35 -0700)
committerSam Clegg <sbc@chromium.org>
Wed, 15 Apr 2020 19:33:33 +0000 (12:33 -0700)
This commit fixes using functions in `IRObjectFile` to load bitcode from
wasm objects by recognizing the file magic for wasm and also inheriting
the default implementation of classifying sections as bitcode.

Patch By: alexcrichton

Differential Revision: https://reviews.llvm.org/D78199

llvm/include/llvm/Object/Wasm.h
llvm/lib/Object/IRObjectFile.cpp
llvm/lib/Object/WasmObjectFile.cpp

index e5b21d0..0ba8355 100644 (file)
@@ -185,7 +185,6 @@ public:
   bool isSectionData(DataRefImpl Sec) const override;
   bool isSectionBSS(DataRefImpl Sec) const override;
   bool isSectionVirtual(DataRefImpl Sec) const override;
-  bool isSectionBitcode(DataRefImpl Sec) const override;
   relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
   relocation_iterator section_rel_end(DataRefImpl Sec) const override;
 
index 636f152..931e842 100644 (file)
@@ -94,6 +94,7 @@ IRObjectFile::findBitcodeInMemBuffer(MemoryBufferRef Object) {
     return Object;
   case file_magic::elf_relocatable:
   case file_magic::macho_object:
+  case file_magic::wasm_object:
   case file_magic::coff_object: {
     Expected<std::unique_ptr<ObjectFile>> ObjFile =
         ObjectFile::createObjectFile(Object, Type);
index e9a8e08..362834c 100644 (file)
@@ -1469,8 +1469,6 @@ bool WasmObjectFile::isSectionBSS(DataRefImpl Sec) const { return false; }
 
 bool WasmObjectFile::isSectionVirtual(DataRefImpl Sec) const { return false; }
 
-bool WasmObjectFile::isSectionBitcode(DataRefImpl Sec) const { return false; }
-
 relocation_iterator WasmObjectFile::section_rel_begin(DataRefImpl Ref) const {
   DataRefImpl RelocRef;
   RelocRef.d.a = Ref.d.a;