Skip to content

Commit eec47e0

Browse files
alx32Alex B
authored andcommitted
[llvm-objdump][macho] Fix relative method list dumping for little endian hosts (llvm#85778)
`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. Co-authored-by: Alex B <[email protected]>
1 parent c9b47cd commit eec47e0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

llvm/test/tools/llvm-objdump/MachO/AArch64/macho-relative-method-lists.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
XFAIL: system-aix
21
RUN: llvm-objdump --macho --objc-meta-data %p/Inputs/rel-method-lists-arm64_32.dylib | FileCheck %s --check-prefix=CHK32
32
RUN: llvm-otool -ov %p/Inputs/rel-method-lists-arm64_32.dylib | FileCheck %s --check-prefix=CHK32
43

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4499,11 +4499,15 @@ static void print_relative_method_list(uint32_t structSizeAndFlags,
44994499
outs() << indent << " (nameRefPtr extends past the end of the section)";
45004500
else {
45014501
if (pointerSize == 64) {
4502-
name = get_pointer_64(*reinterpret_cast<const uint64_t *>(nameRefPtr),
4503-
xoffset, left, xS, info);
4502+
uint64_t nameOff_64 = *reinterpret_cast<const uint64_t *>(nameRefPtr);
4503+
if (info->O->isLittleEndian() != sys::IsLittleEndianHost)
4504+
sys::swapByteOrder(nameOff_64);
4505+
name = get_pointer_64(nameOff_64, xoffset, left, xS, info);
45044506
} else {
4505-
name = get_pointer_32(*reinterpret_cast<const uint32_t *>(nameRefPtr),
4506-
xoffset, left, xS, info);
4507+
uint32_t nameOff_32 = *reinterpret_cast<const uint32_t *>(nameRefPtr);
4508+
if (info->O->isLittleEndian() != sys::IsLittleEndianHost)
4509+
sys::swapByteOrder(nameOff_32);
4510+
name = get_pointer_32(nameOff_32, xoffset, left, xS, info);
45074511
}
45084512
if (name != nullptr)
45094513
outs() << format(" %.*s", left, name);

0 commit comments

Comments
 (0)