[llvm] [ELFDumper] Always read AMD Code Object notes as little-endian (PR #70775)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 31 00:10:07 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-binary-utilities
Author: Pierre van Houtryve (Pierre-vh)
<details>
<summary>Changes</summary>
Avoids issues on big-endian hosts.
Note that we use aligned types because primitive integers are also aligned. If we don't use aligned types, `HSAILProperties` ends up being 11 bytes instead of 12 (1 byte padding at the end of the struct added by the compiler).
Technically only the first type needs to be aligned, but I just used aligned types everywhere to be consistent.
Fixes #<!-- -->65280
---
Full diff: https://github.com/llvm/llvm-project/pull/70775.diff
1 Files Affected:
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+11-11)
``````````diff
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 658c651add3b922..34e31e05cd8527f 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5451,8 +5451,8 @@ static AMDNote getAMDNote(uint32_t NoteType, ArrayRef<uint8_t> Desc) {
return {"", ""};
case ELF::NT_AMD_HSA_CODE_OBJECT_VERSION: {
struct CodeObjectVersion {
- uint32_t MajorVersion;
- uint32_t MinorVersion;
+ support::aligned_ulittle32_t MajorVersion;
+ support::aligned_ulittle32_t MinorVersion;
};
if (Desc.size() != sizeof(CodeObjectVersion))
return {"AMD HSA Code Object Version",
@@ -5466,8 +5466,8 @@ static AMDNote getAMDNote(uint32_t NoteType, ArrayRef<uint8_t> Desc) {
}
case ELF::NT_AMD_HSA_HSAIL: {
struct HSAILProperties {
- uint32_t HSAILMajorVersion;
- uint32_t HSAILMinorVersion;
+ support::aligned_ulittle32_t HSAILMajorVersion;
+ support::aligned_ulittle32_t HSAILMinorVersion;
uint8_t Profile;
uint8_t MachineModel;
uint8_t DefaultFloatRound;
@@ -5487,11 +5487,11 @@ static AMDNote getAMDNote(uint32_t NoteType, ArrayRef<uint8_t> Desc) {
}
case ELF::NT_AMD_HSA_ISA_VERSION: {
struct IsaVersion {
- uint16_t VendorNameSize;
- uint16_t ArchitectureNameSize;
- uint32_t Major;
- uint32_t Minor;
- uint32_t Stepping;
+ support::aligned_ulittle16_t VendorNameSize;
+ support::aligned_ulittle16_t ArchitectureNameSize;
+ support::aligned_ulittle32_t Major;
+ support::aligned_ulittle32_t Minor;
+ support::aligned_ulittle32_t Stepping;
};
if (Desc.size() < sizeof(IsaVersion))
return {"AMD HSA ISA Version", "Invalid AMD HSA ISA Version"};
@@ -5527,8 +5527,8 @@ static AMDNote getAMDNote(uint32_t NoteType, ArrayRef<uint8_t> Desc) {
}
case ELF::NT_AMD_PAL_METADATA: {
struct PALMetadata {
- uint32_t Key;
- uint32_t Value;
+ support::aligned_ulittle32_t Key;
+ support::aligned_ulittle32_t Value;
};
if (Desc.size() % sizeof(PALMetadata) != 0)
return {"AMD PAL Metadata", "Invalid AMD PAL Metadata"};
``````````
</details>
https://github.com/llvm/llvm-project/pull/70775
More information about the llvm-commits
mailing list