[llvm] [llvm-objdump][macho] Fix relative method list dumping for little endian hosts (PR #85778)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 19 04:57:14 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-binary-utilities
Author: None (alx32)
<details>
<summary>Changes</summary>
`macho-relative-method-lists.test` is failing on little endian platforms, when matching 'name'.
```
CHK32-NEXT: name 0x144 (0x{{[0-9a-f]*}}) instance_method_00
next:10'0 X error: no match found
18: name 0x144 (0x7ac)
```
This seems like the obvious fix.
---
Full diff: https://github.com/llvm/llvm-project/pull/85778.diff
2 Files Affected:
- (modified) llvm/test/tools/llvm-objdump/MachO/AArch64/macho-relative-method-lists.test (-1)
- (modified) llvm/tools/llvm-objdump/MachODump.cpp (+8-4)
``````````diff
diff --git a/llvm/test/tools/llvm-objdump/MachO/AArch64/macho-relative-method-lists.test b/llvm/test/tools/llvm-objdump/MachO/AArch64/macho-relative-method-lists.test
index 8e1a9b67970416..b1b96a41a32939 100644
--- a/llvm/test/tools/llvm-objdump/MachO/AArch64/macho-relative-method-lists.test
+++ b/llvm/test/tools/llvm-objdump/MachO/AArch64/macho-relative-method-lists.test
@@ -1,4 +1,3 @@
-XFAIL: system-aix
RUN: llvm-objdump --macho --objc-meta-data %p/Inputs/rel-method-lists-arm64_32.dylib | FileCheck %s --check-prefix=CHK32
RUN: llvm-otool -ov %p/Inputs/rel-method-lists-arm64_32.dylib | FileCheck %s --check-prefix=CHK32
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 1b0e5ba279d06b..5e0d69a68d69b4 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -4499,11 +4499,15 @@ static void print_relative_method_list(uint32_t structSizeAndFlags,
outs() << indent << " (nameRefPtr extends past the end of the section)";
else {
if (pointerSize == 64) {
- name = get_pointer_64(*reinterpret_cast<const uint64_t *>(nameRefPtr),
- xoffset, left, xS, info);
+ uint64_t nameOff_64 = *reinterpret_cast<const uint64_t *>(nameRefPtr);
+ if (info->O->isLittleEndian() != sys::IsLittleEndianHost)
+ sys::swapByteOrder(nameOff_64);
+ name = get_pointer_64(nameOff_64, xoffset, left, xS, info);
} else {
- name = get_pointer_32(*reinterpret_cast<const uint32_t *>(nameRefPtr),
- xoffset, left, xS, info);
+ uint32_t nameOff_32 = *reinterpret_cast<const uint32_t *>(nameRefPtr);
+ if (info->O->isLittleEndian() != sys::IsLittleEndianHost)
+ sys::swapByteOrder(nameOff_32);
+ name = get_pointer_32(nameOff_32, xoffset, left, xS, info);
}
if (name != nullptr)
outs() << format(" %.*s", left, name);
``````````
</details>
https://github.com/llvm/llvm-project/pull/85778
More information about the llvm-commits
mailing list