-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLD][COFF] Split native and EC .CRT chunks on ARM64X #127203
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
Merged
Merged
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// REQUIRES: aarch64, x86 | ||
// RUN: split-file %s %t.dir && cd %t.dir | ||
|
||
// RUN: llvm-mc -filetype=obj -triple=aarch64-windows crt1-arm64.s -o crt1-arm64.obj | ||
// RUN: llvm-mc -filetype=obj -triple=aarch64-windows crt2-arm64.s -o crt2-arm64.obj | ||
// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows crt1-arm64ec.s -o crt1-arm64ec.obj | ||
// RUN: llvm-mc -filetype=obj -triple=x86_64-windows crt2-amd64.s -o crt2-amd64.obj | ||
|
||
// Check that .CRT chunks are correctly sorted and that EC and native chunks are split. | ||
|
||
// RUN: lld-link -out:out.dll -machine:arm64x -dll -noentry crt1-arm64.obj crt2-arm64.obj crt1-arm64ec.obj crt2-amd64.obj | ||
// RUN: llvm-readobj --hex-dump=.CRT out.dll | FileCheck %s | ||
|
||
// RUN: lld-link -out:out2.dll -machine:arm64x -dll -noentry crt1-arm64.obj crt1-arm64ec.obj crt2-arm64.obj crt2-amd64.obj | ||
// RUN: llvm-readobj --hex-dump=.CRT out2.dll | FileCheck %s | ||
|
||
// RUN: lld-link -out:out3.dll -machine:arm64x -dll -noentry crt2-amd64.obj crt1-arm64ec.obj crt2-arm64.obj crt1-arm64.obj | ||
// RUN: llvm-readobj --hex-dump=.CRT out3.dll | FileCheck %s | ||
|
||
// CHECK: 0x180002000 01000000 00000000 02000000 00000000 | ||
// CHECK-NEXT: 0x180002010 03000000 00000000 11000000 00000000 | ||
// CHECK-NEXT: 0x180002020 12000000 00000000 13000000 00000000 | ||
|
||
#--- crt1-arm64.s | ||
.section .CRT$A,"dr" | ||
.xword 1 | ||
.section .CRT$Z,"dr" | ||
.xword 3 | ||
|
||
#--- crt2-arm64.s | ||
.section .CRT$B,"dr" | ||
.xword 2 | ||
|
||
#--- crt1-arm64ec.s | ||
.section .CRT$A,"dr" | ||
.xword 0x11 | ||
.section .CRT$Z,"dr" | ||
.xword 0x13 | ||
|
||
#--- crt2-amd64.s | ||
.section .CRT$B,"dr" | ||
.quad 0x12 |
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.
Oh, tricky. I guess we'd need to do something similar for every section that contains sorted ranges of pointers like this - presumably
.ctors
too?What about sections like
.tls
? I presume that's coming up in a future patch too :-)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.
Yes, that's #127205.
Surprisingly, no,
.tls
is a bit unusual. TLS callbacks are part of the.CRT
section, so this PR already handles that.The
.tls
section would seem like a good candidate for splitting, but based on my MSVC testing, it doesn’t behave that way. It’s somewhat similar to regular data handling, where EC data is mixed with native data. Since TLS callbacks are referenced by the TLS directory entry, I expected it to use ARM64X relocations in some way (for example, by defining_tls_used
in both namespaces and swapping them in the directory entry using ARM64X relocs) but that doesn’t happen either.With ARM64X, MSVC emits only the native directory. I guess that’s sufficient because the CRT later uses
.tls
and.CRT
symbols without relying on_tls_used
at runtime. That's already how LLD behaves, though I wouldn't rule out trying to improve it at some point...