-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[llvm-ar][Object][COFF] Add support for EC symbols to llvm-ar. #85230
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,19 @@ | ||
;; Test that ECSYMBOLS section is created when ARM64EC bitcode is used. | ||
|
||
; RUN: llvm-as %s -o %t.bc | ||
; RUN: rm -f %t.a | ||
; RUN: llvm-ar cr %t.a %t.bc | ||
; RUN: llvm-nm --print-armap %t.a | FileCheck %s | ||
|
||
; CHECK-NOT: Archive map | ||
; CHECK: Archive EC map | ||
; CHECK-NEXT: a in ecsymbols.ll.tmp.bc | ||
; CHECK-NEXT: b in ecsymbols.ll.tmp.bc | ||
; CHECK-NEXT: c in ecsymbols.ll.tmp.bc | ||
; CHECK-EMPTY: | ||
|
||
target triple = "arm64ec-unknown-windows-msvc" | ||
|
||
define void @b() { ret void } | ||
define void @c() { ret void } | ||
define void @a() { ret void } |
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,84 @@ | ||
## Test that ECSYMBOLS section is created when ARM64EC is used. | ||
|
||
# RUN: yaml2obj %s -o %t.arm64ec.obj -DMACHINE=IMAGE_FILE_MACHINE_ARM64EC | ||
# RUN: yaml2obj %s -o %t.arm64.obj -DMACHINE=IMAGE_FILE_MACHINE_ARM64 | ||
# RUN: yaml2obj %s -o %t.amd64.obj -DMACHINE=IMAGE_FILE_MACHINE_AMD64 | ||
|
||
## Create ARM64EC archive. | ||
# RUN: rm -f %t*.a | ||
# RUN: llvm-ar cr %t1.a %t.arm64ec.obj | ||
# RUN: llvm-nm --print-armap %t1.a | FileCheck --check-prefixes=NOMAP,ECMAP %s | ||
|
||
## Add ARM64 object to the archive. | ||
# RUN: llvm-ar r %t1.a %t.arm64.obj | ||
# RUN: llvm-nm --print-armap %t1.a | FileCheck --check-prefixes=MAP,ECMAP %s | ||
|
||
## Create ARM64 archive. | ||
# RUN: llvm-ar cr %t2.a %t.arm64.obj | ||
# RUN: llvm-nm --print-armap %t2.a | FileCheck --check-prefixes=MAP,NOECMAP %s | ||
|
||
## Add ARM64EC object to the archive. | ||
# RUN: llvm-ar r %t2.a %t.arm64ec.obj | ||
# RUN: llvm-nm --print-armap %t2.a | FileCheck --check-prefixes=MAP,ECMAP %s | ||
|
||
## Create mixed archive with ARM64 and ARM64EC members. | ||
# RUN: llvm-ar cr %t3.a %t.arm64ec.obj %t.arm64.obj | ||
# RUN: llvm-nm --print-armap %t3.a | FileCheck --check-prefixes=MAP,ECMAP %s | ||
|
||
## Create mixed archive with ARM64 and AMD64 members. | ||
# RUN: llvm-ar cr %t4.a %t.amd64.obj %t.arm64.obj | ||
# RUN: llvm-nm --print-armap %t4.a | FileCheck --check-prefixes=MAP,AMDECMAP %s | ||
|
||
## Create an archive with no symbol table. | ||
# RUN: llvm-ar crS %t5.a %t.amd64.obj %t.arm64.obj | ||
# RUN: llvm-nm --print-armap %t5.a | FileCheck --check-prefixes=NOMAP,NOECMAP %s | ||
|
||
# MAP: Archive map | ||
# MAP-NEXT: a in ecsymbols.yaml.tmp.arm64.obj | ||
# MAP-NEXT: b in ecsymbols.yaml.tmp.arm64.obj | ||
# MAP-NEXT: c in ecsymbols.yaml.tmp.arm64.obj | ||
# MAP-EMPTY: | ||
# NOMAP-NOT: Archive map | ||
|
||
# ECMAP: Archive EC map | ||
# ECMAP-NEXT: a in ecsymbols.yaml.tmp.arm64ec.obj | ||
# ECMAP-NEXT: b in ecsymbols.yaml.tmp.arm64ec.obj | ||
# ECMAP-NEXT: c in ecsymbols.yaml.tmp.arm64ec.obj | ||
# ECMAP-EMPTY: | ||
# NOECMAP-NOT: Archive EC map | ||
|
||
# AMDECMAP: Archive EC map | ||
# AMDECMAP-NEXT: a in ecsymbols.yaml.tmp.amd64.obj | ||
# AMDECMAP-NEXT: b in ecsymbols.yaml.tmp.amd64.obj | ||
# AMDECMAP-NEXT: c in ecsymbols.yaml.tmp.amd64.obj | ||
# AMDECMAP-EMPTY: | ||
|
||
--- !COFF | ||
header: | ||
Machine: [[MACHINE]] | ||
Characteristics: [ ] | ||
sections: | ||
- Name: .text | ||
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] | ||
Alignment: 4 | ||
SectionData: '' | ||
symbols: | ||
- Name: b | ||
Value: 0 | ||
SectionNumber: 1 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_FUNCTION | ||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL | ||
- Name: c | ||
Value: 0 | ||
SectionNumber: 1 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_FUNCTION | ||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL | ||
- Name: a | ||
Value: 0 | ||
SectionNumber: 1 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_FUNCTION | ||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL | ||
... |
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,27 @@ | ||
Create import libraries with empty exports and make sure that archive symbols | ||
are properly populated. | ||
|
||
RUN: split-file %s %t.dir && cd %t.dir | ||
|
||
RUN: llvm-lib -machine:arm64 -out:arm64.lib -def:test.def | ||
RUN: llvm-nm --print-armap arm64.lib | FileCheck --check-prefixes=CHECK,NOECMAP %s | ||
|
||
RUN: llvm-lib -machine:arm64ec -out:arm64ec.lib -def:test.def | ||
RUN: llvm-nm --print-armap arm64ec.lib | FileCheck --check-prefixes=CHECK,ECMAP %s | ||
|
||
CHECK: Archive map | ||
CHECK-NEXT: __IMPORT_DESCRIPTOR_test in test.dll | ||
CHECK-NEXT: __NULL_IMPORT_DESCRIPTOR in test.dll | ||
CHECK-NEXT: test_NULL_THUNK_DATA in test.dll | ||
CHECK-EMPTY: | ||
|
||
ECMAP: Archive EC map | ||
ECMAP-NEXT: __IMPORT_DESCRIPTOR_test in test.dll | ||
ECMAP-NEXT: __NULL_IMPORT_DESCRIPTOR in test.dll | ||
ECMAP-NEXT: test_NULL_THUNK_DATA in test.dll | ||
|
||
NOECMAP-NOT: Archive EC map | ||
|
||
#--- test.def | ||
LIBRARY test.dll | ||
EXPORTS |
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.
If I'm following correctly, this unconditionally emits an EC map for arm64 targets, even if there aren't any non-native object files? But that isn't consistent with the tests, so I think I must be missing something.
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 don't actually emit EC symbol map if there are no EC symbols, so I wrote it under assumption that it should be fine. Thinking about it again, with #84834, this patch causes copied import descriptor to populate and emit EC map. I will fix it, thanks.