]> granicus.if.org Git - llvm/commitdiff
COFF Import: expose both symbols
authorSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 28 Apr 2017 04:29:43 +0000 (04:29 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 28 Apr 2017 04:29:43 +0000 (04:29 +0000)
COFF Import libraries which use the obsolete CONSTANT export are
supposed to get two symbols, one with the `_imp_` prefix and one
without.  Ensure that we expose both for iteration.  This is necessary
to fix the librarian with COFF CONSTANT exports.

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

include/llvm/Object/COFFImportFile.h
test/tools/llvm-readobj/Inputs/const-import.lib [new file with mode: 0644]
test/tools/llvm-readobj/coff-const-import.test [new file with mode: 0644]

index 4192fe7e5c90a593522c61298b1f91227fe219b8..78d9d679acd31614cb7e612229ed27ba78959eec 100644 (file)
@@ -53,7 +53,7 @@ public:
 
   basic_symbol_iterator symbol_end() const override {
     DataRefImpl Symb;
-    Symb.p = isCode() ? 2 : 1;
+    Symb.p = isData() ? 1 : 2;
     return BasicSymbolRef(Symb, this);
   }
 
@@ -63,8 +63,8 @@ public:
   }
 
 private:
-  bool isCode() const {
-    return getCOFFImportHeader()->getType() == COFF::IMPORT_CODE;
+  bool isData() const {
+    return getCOFFImportHeader()->getType() == COFF::IMPORT_DATA;
   }
 };
 
diff --git a/test/tools/llvm-readobj/Inputs/const-import.lib b/test/tools/llvm-readobj/Inputs/const-import.lib
new file mode 100644 (file)
index 0000000..88a2ac3
Binary files /dev/null and b/test/tools/llvm-readobj/Inputs/const-import.lib differ
diff --git a/test/tools/llvm-readobj/coff-const-import.test b/test/tools/llvm-readobj/coff-const-import.test
new file mode 100644 (file)
index 0000000..3c3c482
--- /dev/null
@@ -0,0 +1,7 @@
+RUN: llvm-readobj -coff-exports %S/Inputs/const-import.lib | FileCheck %s
+
+CHECK: Type: const
+CHECK: Name type: noprefix
+CHECK: Symbol: __imp____CFConstantStringClassReference
+CHECK: Symbol: ___CFConstantStringClassReference
+