From b355fd030890020e1fa70f66e0c9e45146bcb125 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 1 Sep 2015 06:01:53 +0000 Subject: [PATCH] Object: Fix COFF import file's symbols. If a symbol is marked as "data", the symbol should be exported with __imp_ prefix. Previously, the symbol was exported as-is. llvm-svn: 246532 --- llvm/include/llvm/Object/COFFImportFile.h | 2 +- llvm/test/Object/archive-symtab.test | 6 +++--- llvm/test/tools/llvm-readobj/file-headers.test | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/Object/COFFImportFile.h b/llvm/include/llvm/Object/COFFImportFile.h index 07e98f5cf12d..b04a44ea60d2 100644 --- a/llvm/include/llvm/Object/COFFImportFile.h +++ b/llvm/include/llvm/Object/COFFImportFile.h @@ -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(); diff --git a/llvm/test/Object/archive-symtab.test b/llvm/test/Object/archive-symtab.test index 120401bad36a..c9e89005d6c3 100644 --- a/llvm/test/Object/archive-symtab.test +++ b/llvm/test/Object/archive-symtab.test @@ -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 diff --git a/llvm/test/tools/llvm-readobj/file-headers.test b/llvm/test/tools/llvm-readobj/file-headers.test index 10fbcbcc153b..2d67089d6118 100644 --- a/llvm/test/tools/llvm-readobj/file-headers.test +++ b/llvm/test/tools/llvm-readobj/file-headers.test @@ -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