-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[llvm-readobj][COFF] Add support for version 2 of CHPE metadata #109545
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
Conversation
@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 |
If I'm reading the code correctly, actually, it doesn't affect COFFObjectFile::initLoadConfigPtr... because the check there is against |
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.
LGTM
The versioning here is a little weird... I thought normally they prefer to store the size of the struct in a field instead. But if this is how it works, it's fine.
Oh, right, I messed that offset check. I will create a follow-up for that. Thanks! |
No description provided.