-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-dlltool] Fix renamed imports without a separate regular import …
…entry Normally, when doing renamed imports, we do this by providing a weak alias, towards another regular import, for the symbol we want to actually import. In a def file, this looks like this: regularfunc renamedfunc == regularfunc However, if we want to link against a function in a DLL, where we (intentionally) don't provide a regular import for that symbol with the name in its DLL, doing the renamed import with a weak alias doesn't work, as there's no symbol that the weak alias can point towards. We can't make up such an import either, as we may intentionally not want to provide a regular import for that name. This situation can either be resolved by using the "long" import library format (as e.g. produced by GNU dlltool), or by using the new short import library name type "export as". This patch implements it by using the "export as" name type. When producing a renamed import, defer emitting it until all regular imports have been produced. If the renamed import refers to a symbol that does exist as a regular import entry, produce a weak alias, just as before. (This implementation also avoids needing to know whether the symbol that the alias points towards actually is prefixed or not, too.) If the renamed import points at a symbol that isn't otherwise available (or is available as a renamed symbol itself), generate an "export as" import entry. This name type is new, and is normally used in ARM64EC import libraries, but can also be used for other architectures.
- Loading branch information
Showing
7 changed files
with
96 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
; RUN: llvm-dlltool -k -m i386 --input-def %s --output-lib %t.a | ||
; RUN: llvm-readobj %t.a | FileCheck %s | ||
; RUN: llvm-nm %t.a | FileCheck %s -check-prefix=CHECK-NM | ||
|
||
LIBRARY test.dll | ||
EXPORTS | ||
|
||
symbolname == actualimport | ||
|
||
dataname DATA == actualdata | ||
|
||
_wcstok == wcstok | ||
wcstok == wcstok_s | ||
|
||
; CHECK-NM-NOT: actualimport | ||
; CHECK-NM-NOT: actualdata | ||
|
||
; CHECK: Type: code | ||
; CHECK-NEXT: Name type: export as | ||
; CHECK-NEXT: Export name: actualimport | ||
; CHECK-NEXT: Symbol: __imp__symbolname | ||
; CHECK-NEXT: Symbol: _symbolname | ||
|
||
; CHECK: Type: data | ||
; CHECK-NEXT: Name type: export as | ||
; CHECK-NEXT: Export name: actualdata | ||
; CHECK-NEXT: Symbol: __imp__dataname | ||
|
||
; CHECK: Type: code | ||
; CHECK-NEXT: Name type: export as | ||
; CHECK-NEXT: Export name: wcstok | ||
; CHECK-NEXT: Symbol: __imp___wcstok | ||
; CHECK-NEXT: Symbol: __wcstok | ||
|
||
; CHECK: Type: code | ||
; CHECK-NEXT: Name type: export as | ||
; CHECK-NEXT: Export name: wcstok_s | ||
; CHECK-NEXT: Symbol: __imp__wcstok | ||
; CHECK-NEXT: Symbol: _wcstok |