-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[LLD][COFF] Follow up comments on pr146610 #147152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aganea
wants to merge
1
commit into
llvm:main
Choose a base branch
from
aganea:fix/address_comments_pr146610
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,59 @@ | ||
REQUIRES: x86 | ||
RUN: split-file %s %t.dir && cd %t.dir | ||
|
||
RUN: llvm-mc -filetype=obj -triple=i386-windows a.s -o a.obj | ||
|
||
RUN: llvm-mc -filetype=obj -triple=i386-windows b1.s -o b1.obj | ||
RUN: llvm-mc -filetype=obj -triple=i386-windows b2.s -o b2.obj | ||
|
||
### This is the line where our problem occurs. Here, we export the DllMain symbol which shouldn't happen normally. | ||
RUN: lld-link b1.obj b2.obj -out:b.dll -dll -implib:b.lib -entry:DllMain -export:bar -export:DllMain -safeseh:no | ||
|
||
RUN: llvm-mc -filetype=obj -triple=i386-windows c.s -o c.obj | ||
RUN: lld-link -lib c.obj -out:c.lib | ||
|
||
### Later, if b.lib is provided before other libs/objs that export DllMain statically, we previously were using the dllimported DllMain from b.lib, which is wrong. | ||
RUN: lld-link a.obj b.lib c.lib -dll -out:out.dll -entry:DllMain -safeseh:no 2>&1 | FileCheck -check-prefix=WARN %s | ||
RUN: lld-link a.obj b.lib c.lib -dll -out:out.dll -entry:DllMain -ignore:importeddllmain -safeseh:no 2>&1 | FileCheck -check-prefix=IGNORED --allow-empty %s | ||
RUN: llvm-objdump --private-headers -d out.dll | FileCheck -check-prefix=DISASM %s | ||
|
||
WARN: lld-link: warning: b.lib: skipping imported DllMain symbol [importeddllmain] | ||
IGNORED-NOT: lld-link: warning: b.lib: skipping imported DllMain symbol [importeddllmain] | ||
|
||
DISASM: The Import Tables: | ||
DISASM: DLL Name: b.dll | ||
DISASM-NOT: DllMain | ||
DISASM: bar | ||
DISASM: Disassembly of section .text: | ||
DISASM-EMPTY: | ||
DISASM-NEXT: b0 01 movb $0x1, %al | ||
DISASM-NEXT: c3 retl | ||
|
||
#--- a.s | ||
.text | ||
.globl _foo | ||
_foo: | ||
call *__imp__bar | ||
ret | ||
|
||
#--- b1.s | ||
.text | ||
.globl _bar | ||
_bar: | ||
ret | ||
|
||
#--- b2.s | ||
.intel_syntax noprefix | ||
.text | ||
.globl _DllMain | ||
_DllMain: | ||
xor al, al | ||
ret | ||
|
||
#--- c.s | ||
.intel_syntax noprefix | ||
.text | ||
.globl _DllMain | ||
_DllMain: | ||
mov al, 1 | ||
ret |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be testing two different syntaxes, we should only be testing the right one for each architecture. (Otherwise we'd be matching an unrelated symbol on x86_64 too, even if using a symbol named
_DllMain
there also would be kinda odd.) IIRC you can do e.g.mangle("DllMain")
to get the right symbol name. And the same goes for the__imp_
form too, on i386 it would be__imp__DllMain
, soTwine("__imp_") + mangle("DllMain")
or something along those lines.