Skip to content

Commit

Permalink
[COFF] Avoid loading objects for mingw autoimport, when a defined ali…
Browse files Browse the repository at this point in the history
…as exists

This avoids a spurious and confusing log message in cases where
both e.g. "alias" and "__imp_alias" exist.

Differential Revision: https://reviews.llvm.org/D65598

llvm-svn: 367673
  • Loading branch information
mstorsjo committed Aug 2, 2019
1 parent ad66e95 commit 5f0077d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lld/COFF/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ void SymbolTable::loadMinGWAutomaticImports() {
continue;
if (!sym->isUsedInRegularObj)
continue;
if (undef->getWeakAlias())
continue;

StringRef name = undef->getName();

Expand Down
Binary file added lld/test/COFF/Inputs/alias-implib.lib
Binary file not shown.
23 changes: 23 additions & 0 deletions lld/test/COFF/alias-implib.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# REQUIRES: x86

# RUN: llvm-mc -filetype=obj -triple=x86_64-mingw32 -o %t.o %s
# RUN: lld-link -lldmingw -entry:main -out:%t.exe %t.o %S/Inputs/alias-implib.lib -verbose 2>&1 | FileCheck %s

# Check that the undefined (weak) alias symbol (with an existing lazy
# __imp_alias) doesn't trigger trying to load __imp_alias for autoimport,
# when the weak alias target actually does exist.

# CHECK-NOT: Loading lazy{{.*}}for automatic import

.text
.globl main
main:
call alias
ret

# alias-implib.lib was created with "llvm-dlltool -m i386:x86-64
# -l alias-implib.lib -d alias-implib.def" with this def snippet:
# LIBRARY lib.dll
# EXPORTS
# realfunc
# alias == realfunc

0 comments on commit 5f0077d

Please sign in to comment.