-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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
[llvm-readobj][COFF] Add support for version 2 of CHPE metadata #109545
Open
cjacek
wants to merge
1
commit into
llvm:main
Choose a base branch
from
cjacek:chpev2
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.
+78
−2
Conversation
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
@llvm/pr-subscribers-llvm-binary-utilities Author: Jacek Caban (cjacek) ChangesFull diff: https://github.com/llvm/llvm-project/pull/109545.diff 3 Files Affected:
diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h
index dc43c87c4125c3..05b3587224c296 100644
--- a/llvm/include/llvm/Object/COFF.h
+++ b/llvm/include/llvm/Object/COFF.h
@@ -747,6 +747,11 @@ struct chpe_metadata {
support::ulittle32_t ExtraRFETableSize;
support::ulittle32_t __os_arm64x_dispatch_fptr;
support::ulittle32_t AuxiliaryIATCopy;
+
+ // Added in CHPE metadata v2
+ support::ulittle32_t AuxiliaryDelayloadIAT;
+ support::ulittle32_t AuxiliaryDelayloadIATCopy;
+ support::ulittle32_t HybridImageInfoBitfield;
};
enum chpe_range_type { Arm64 = 0, Arm64EC = 1, Amd64 = 2 };
diff --git a/llvm/test/tools/llvm-readobj/COFF/arm64ec-chpe.yaml b/llvm/test/tools/llvm-readobj/COFF/arm64ec-chpe.yaml
index 2aa80df0820e90..1f5e7e10888989 100644
--- a/llvm/test/tools/llvm-readobj/COFF/arm64ec-chpe.yaml
+++ b/llvm/test/tools/llvm-readobj/COFF/arm64ec-chpe.yaml
@@ -1,5 +1,5 @@
-# RUN: yaml2obj %s -o %t
-# RUN: llvm-readobj --coff-load-config %t | FileCheck %s
+# RUN: yaml2obj --docnum=1 %s -o %t1
+# RUN: llvm-readobj --coff-load-config %t1 | FileCheck %s
# CHECK: CHPEMetadataPointer: 0x180005000
# CHECK: CHPEMetadata [
@@ -17,6 +17,7 @@
# CHECK-NEXT: 0x1000 -> 0x2000
# CHECK-NEXT: 0x1020 -> 0x2030
# CHECK-NEXT: ]
+# CHECK-NOT: AuxiliaryDelayloadIAT:
--- !COFF
OptionalHeader:
@@ -85,3 +86,67 @@ sections:
- UInt32: 0x2030
symbols: []
...
+
+# RUN: yaml2obj --docnum=2 %s -o %t2
+# RUN: llvm-readobj --coff-load-config %t2 | FileCheck --check-prefix=CHPE2 %s
+
+# CHPE2: CHPEMetadata [
+# CHPE2-NEXT: Version: 0x2
+# CHPE2: AuxiliaryDelayloadIAT: 0x1
+# CHPE2-NEXT: AuxiliaryDelayloadIATCopy: 0x2
+# CHPE2-NEXT: HybridImageInfoBitfield: 0x4
+
+--- !COFF
+OptionalHeader:
+ ImageBase: 0x180000000
+ SectionAlignment: 4096
+ FileAlignment: 512
+ DLLCharacteristics: [ ]
+ LoadConfigTable:
+ RelativeVirtualAddress: 0x4000
+ Size: 320
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ VirtualAddress: 0x1000
+ VirtualSize: 0x2050
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ VirtualAddress: 0x4000
+ VirtualSize: 328
+ StructuredData:
+ - LoadConfig:
+ CHPEMetadataPointer: 0x180005000
+ - Name: .data
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+ VirtualAddress: 0x5000
+ VirtualSize: 144
+ StructuredData:
+ - UInt32: 2 # Version
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 0
+ - UInt32: 1 # AuxiliaryDelayloadIAT
+ - UInt32: 2 # AuxiliaryDelayloadIATCopy
+ - UInt32: 4 # HybridImageInfoBitfield
+symbols: []
+...
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 65d67d29a5aa30..1666f7692ad5f0 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -930,6 +930,12 @@ void COFFDumper::printCOFFLoadConfig() {
W.printHex("ExtraRFETableSize", CHPE->ExtraRFETableSize);
W.printHex("__os_arm64x_dispatch_fptr", CHPE->__os_arm64x_dispatch_fptr);
W.printHex("AuxiliaryIATCopy", CHPE->AuxiliaryIATCopy);
+
+ if (CHPE->Version >= 2) {
+ W.printHex("AuxiliaryDelayloadIAT", CHPE->AuxiliaryDelayloadIAT);
+ W.printHex("AuxiliaryDelayloadIATCopy", CHPE->AuxiliaryDelayloadIATCopy);
+ W.printHex("HybridImageInfoBitfield", CHPE->HybridImageInfoBitfield);
+ }
}
if (Tables.SEHTableVA) {
|
The change to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.