mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-13 08:46:22 +00:00
[Object][COFF] Avoid underscore prefix for forwarding exports (#135433)
Fixes #132411.
This commit is contained in:
parent
4dd80b73b0
commit
2b270df2e7
16
lld/test/COFF/export-alias.test
Normal file
16
lld/test/COFF/export-alias.test
Normal file
@ -0,0 +1,16 @@
|
||||
; REQUIRES: x86
|
||||
|
||||
; RUN: echo > %t.s
|
||||
; RUN: llvm-mc -filetype=obj -triple=i686-windows %t.s -o %t.obj
|
||||
; RUN: lld-link -machine:x86 -dll -noentry -safeseh:no -out:%t.dll -def:%s %t.obj
|
||||
; RUN: llvm-readobj --coff-exports %t.dll | FileCheck %s
|
||||
|
||||
; CHECK: Export {
|
||||
; CHECK-NEXT: Ordinal: 1
|
||||
; CHECK-NEXT: Name: func
|
||||
; CHECK-NEXT: ForwardedTo: other.dll.func
|
||||
; CHECK-NEXT: }
|
||||
|
||||
LIBRARY test.dll
|
||||
EXPORTS
|
||||
func = other.dll.func
|
@ -238,7 +238,10 @@ private:
|
||||
}
|
||||
|
||||
if (AddUnderscores) {
|
||||
if (!isDecorated(E.Name, MingwDef))
|
||||
// Don't add underscore if the name is already mangled or if it's a
|
||||
// forward target.
|
||||
if (!isDecorated(E.Name, MingwDef) &&
|
||||
(E.ExtName.empty() || !StringRef(E.Name).contains(".")))
|
||||
E.Name = (std::string("_").append(E.Name));
|
||||
if (!E.ExtName.empty() && !isDecorated(E.ExtName, MingwDef))
|
||||
E.ExtName = (std::string("_").append(E.ExtName));
|
||||
|
23
llvm/test/tools/llvm-lib/underscore.test
Normal file
23
llvm/test/tools/llvm-lib/underscore.test
Normal file
@ -0,0 +1,23 @@
|
||||
; RUN: llvm-lib -machine:x86 -out:%t.lib -def:%s
|
||||
; RUN: llvm-readobj %t.lib | FileCheck %s
|
||||
|
||||
; CHECK: File: test.dll
|
||||
; CHECK-NEXT: Format: COFF-import-file-i386
|
||||
; CHECK-NEXT: Type: code
|
||||
; CHECK-NEXT: Name type: noprefix
|
||||
; CHECK-NEXT: Export name: func
|
||||
; CHECK-NEXT: Symbol: __imp__func
|
||||
; CHECK-NEXT: Symbol: _func
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: File: test.dll
|
||||
; CHECK-NEXT: Format: COFF-import-file-i386
|
||||
; CHECK-NEXT: Type: code
|
||||
; CHECK-NEXT: Name type: noprefix
|
||||
; CHECK-NEXT: Export name: test.func
|
||||
; CHECK-NEXT: Symbol: __imp__test.func
|
||||
; CHECK-NEXT: Symbol: _test.func
|
||||
|
||||
LIBRARY test.dll
|
||||
EXPORTS
|
||||
func
|
||||
test.func
|
Loading…
x
Reference in New Issue
Block a user