Object: Fix COFF import file's symbols.
authorRui Ueyama <ruiu@google.com>
Tue, 1 Sep 2015 06:01:53 +0000 (06:01 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 1 Sep 2015 06:01:53 +0000 (06:01 +0000)
If a symbol is marked as "data", the symbol should be exported
with __imp_ prefix. Previously, the symbol was exported as-is.

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

include/llvm/Object/COFFImportFile.h
test/Object/archive-symtab.test
test/tools/llvm-readobj/file-headers.test

index 07e98f5cf12d83d6b4ed746ae91d7f49e1b3fb25..b04a44ea60d2a9f952cda1279c3216dab579efea 100644 (file)
@@ -37,7 +37,7 @@ public:
 
   std::error_code printSymbolName(raw_ostream &OS,
                                   DataRefImpl Symb) const override {
-    if (Symb.p == 1)
+    if (Symb.p == 0)
       OS << "__imp_";
     OS << StringRef(Data.getBufferStart() + sizeof(coff_import_header));
     return std::error_code();
index 120401bad36afb0b2d5d32fc0bd8316780c3fc43..c9e89005d6c3400bff1670e565fc9fcce78be1c7 100644 (file)
@@ -104,10 +104,10 @@ RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/c
 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
+COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
+COFF-SHORT-IMPORT-NEXT: __imp__bar in coff-short-import-data
+COFF-SHORT-IMPORT-NOT:  _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
index 10fbcbcc153b28ca3bd8fa1787989010f75184aa..2d67089d6118d1ddff44e28d09975b70b21cc5f3 100644 (file)
@@ -333,5 +333,5 @@ COFF-UNKNOWN-NEXT: }
 COFF-IMPORTLIB:      Format: COFF-import-file
 COFF-IMPORTLIB-NEXT: Type: code
 COFF-IMPORTLIB-NEXT: Name type: noprefix
-COFF-IMPORTLIB-NEXT: Symbol: _func
 COFF-IMPORTLIB-NEXT: Symbol: __imp__func
+COFF-IMPORTLIB-NEXT: Symbol: _func