Skip to content

Commit

Permalink
Object: Fix COFF import file's symbols.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rui314 committed Sep 1, 2015
1 parent 06fdb30 commit 5c1fa7f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/llvm/Object/COFFImportFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class COFFImportFile : public SymbolicFile {

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();
Expand Down
6 changes: 3 additions & 3 deletions test/Object/archive-symtab.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/tools/llvm-readobj/file-headers.test
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5c1fa7f

Please sign in to comment.