Rollback r246276 - Object: Teach llvm-ar to create symbol table for COFF short import...
authorRui Ueyama <ruiu@google.com>
Fri, 28 Aug 2015 06:03:01 +0000 (06:03 +0000)
committerRui Ueyama <ruiu@google.com>
Fri, 28 Aug 2015 06:03:01 +0000 (06:03 +0000)
This change caused a test for llvm-readobj to fail.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246277 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/SymbolicFile.cpp
test/Object/Inputs/coff-short-import-code [deleted file]
test/Object/Inputs/coff-short-import-data [deleted file]
test/Object/archive-symtab.test

index c3106319c7f3c93dbbac6ac528ef131b179b507c..854e68e40f4d663c7d2e8c85e556b15d48e8e980 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Object/COFF.h"
 #include "llvm/Object/IRObjectFile.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Object/SymbolicFile.h"
-#include "llvm/Support/COFF.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
 using namespace object;
 
-// COFF short import file is a special kind of file which contains
-// only symbol names for DLL-exported symbols. This class implements
-// SymbolicFile interface for the file.
-namespace {
-class COFFImportFile : public SymbolicFile {
-public:
-  COFFImportFile(MemoryBufferRef Source)
-      : SymbolicFile(sys::fs::file_magic::coff_import_library, Source) {}
-
-  void moveSymbolNext(DataRefImpl &Symb) const override { ++Symb.p; }
-
-  std::error_code printSymbolName(raw_ostream &OS,
-                                  DataRefImpl Symb) const override {
-    if (Symb.p == 1)
-      OS << "__imp_";
-    OS << StringRef(Data.getBufferStart() + sizeof(coff_import_header));
-    return std::error_code();
-  }
-
-  uint32_t getSymbolFlags(DataRefImpl Symb) const override {
-    return SymbolRef::SF_Global;
-  }
-
-  basic_symbol_iterator symbol_begin_impl() const override {
-    return BasicSymbolRef(DataRefImpl(), this);
-  }
-
-  basic_symbol_iterator symbol_end_impl() const override {
-    DataRefImpl Symb;
-    Symb.p = isCode() ? 2 : 1;
-    return BasicSymbolRef(Symb, this);
-  }
-
-private:
-  bool isCode() const {
-    auto *Import = reinterpret_cast<const coff_import_header *>(
-        Data.getBufferStart());
-    return Import->getType() == llvm::COFF::IMPORT_CODE;
-  }
-};
-} // anonymous namespace
-
 SymbolicFile::SymbolicFile(unsigned int Type, MemoryBufferRef Source)
     : Binary(Type, Source) {}
 
@@ -98,10 +54,9 @@ ErrorOr<std::unique_ptr<SymbolicFile>> SymbolicFile::createSymbolicFile(
   case sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub:
   case sys::fs::file_magic::macho_dsym_companion:
   case sys::fs::file_magic::macho_kext_bundle:
+  case sys::fs::file_magic::coff_import_library:
   case sys::fs::file_magic::pecoff_executable:
     return ObjectFile::createObjectFile(Object, Type);
-  case sys::fs::file_magic::coff_import_library:
-    return std::unique_ptr<SymbolicFile>(new COFFImportFile(Object));
   case sys::fs::file_magic::elf_relocatable:
   case sys::fs::file_magic::macho_object:
   case sys::fs::file_magic::coff_object: {
diff --git a/test/Object/Inputs/coff-short-import-code b/test/Object/Inputs/coff-short-import-code
deleted file mode 100644 (file)
index 4462790..0000000
Binary files a/test/Object/Inputs/coff-short-import-code and /dev/null differ
diff --git a/test/Object/Inputs/coff-short-import-data b/test/Object/Inputs/coff-short-import-data
deleted file mode 100644 (file)
index 71b635b..0000000
Binary files a/test/Object/Inputs/coff-short-import-data and /dev/null differ
index 120401bad36afb0b2d5d32fc0bd8316780c3fc43..c50833d6a77baaec8e60522eb6aff675e86deaad 100644 (file)
@@ -99,16 +99,6 @@ MACHO-NEXT: 0000000000000000 t _bar
 MACHO-NEXT: 0000000000000001 T _foo
 MACHO-NEXT: 0000000000000002 T _main
 
-RUN: rm -f %t.a
-RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/coff-short-import-data
-RUN: llvm-nm -M %t.a | FileCheck --check-prefix=COFF-SHORT-IMPORT %s
-
-COFF-SHORT-IMPORT:      Archive map
-COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
-COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code
-COFF-SHORT-IMPORT-NEXT: _bar in coff-short-import-data
-COFF-SHORT-IMPORT-NOT:  __imp__bar in coff-short-import-data
-
 Test that we pad the symbol table so that it ends in a multiple of 4 bytes:
 8 + 60 + 36 == 104
 RUN: rm -f %t.a