-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Object][COFF] Fix CHPE metadata offset check #109591
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
Spotted by @efriedma-quic in #109545. |
@llvm/pr-subscribers-llvm-binary-utilities Author: Jacek Caban (cjacek) ChangesFull diff: https://github.com/llvm/llvm-project/pull/109591.diff 2 Files Affected:
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index 5fdf3baf8c02cc..3ec7a449bae798 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -763,7 +763,7 @@ Error COFFObjectFile::initLoadConfigPtr() {
if (Error E =
getRvaPtr(ChpeOff - getImageBase(), IntPtr, "CHPE metadata"))
return E;
- if (Error E = checkOffset(Data, IntPtr, sizeof(CHPEMetadata)))
+ if (Error E = checkOffset(Data, IntPtr, sizeof(*CHPEMetadata)))
return E;
CHPEMetadata = reinterpret_cast<const chpe_metadata *>(IntPtr);
diff --git a/llvm/test/tools/llvm-readobj/COFF/arm64ec-chpe.yaml b/llvm/test/tools/llvm-readobj/COFF/arm64ec-chpe.yaml
index 1f5e7e10888989..91dde600d83748 100644
--- a/llvm/test/tools/llvm-readobj/COFF/arm64ec-chpe.yaml
+++ b/llvm/test/tools/llvm-readobj/COFF/arm64ec-chpe.yaml
@@ -150,3 +150,34 @@ sections:
- UInt32: 4 # HybridImageInfoBitfield
symbols: []
...
+
+# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: not llvm-readobj --coff-load-config %t3 2>&1 | FileCheck --check-prefix=ERR-EOF %s
+# ERR-EOF: The end of the file was unexpectedly encountered
+
+--- !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: 512
+ StructuredData:
+ - LoadConfig:
+ CHPEMetadataPointer: 0x1800041AC
+symbols: []
+...
|
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
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/6292 Here is the relevant piece of the build log for the reference
|
No description provided.