Skip to content

llvm-readobj reads incorrect values from AMD note property on big-endian hosts #65280

Closed
@kovdan01

Description

@kovdan01

getAMDNote function from llvm/tools/llvm-readobj/ELFDumper.cpp fails to read values from the AMD note properly on big-endian hosts. This is result of reinterpret_cast which is followed by reading integers without proper handling of different endianness.

Possible fix might include use of a special wrapper for integers which handles different endianness implicitly, like support::detail::packed_endian_specific_integral.

FAIL: LLVM :: tools/llvm-readobj/ELF/note-amd-valid-v2.test (1 of 293)
******************** TEST 'LLVM :: tools/llvm-readobj/ELF/note-amd-valid-v2.test' FAILED ********************
Exit Code: 1
                                                                                                                                                                                                                                                            
Command Output (stderr):
--
+ : 'RUN: at line 7'
+ /path/to/llvm-project/.build/aarch64_be-rel-with-deb-info/bin/yaml2obj /path/to/llvm-project/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test -o /path/to/llvm-project/.build/aarch64_be-rel-
with-deb-info/test/tools/llvm-readobj/ELF/Output/note-amd-valid-v2.test.tmp.o
+ : 'RUN: at line 8'
+ /path/to/llvm-project/.build/aarch64_be-rel-with-deb-info/bin/llvm-readobj --notes /path/to/llvm-project/.build/aarch64_be-rel-with-deb-info/test/tools/llvm-readobj/ELF/Output/note-amd-valid-v2.test.tmp.o
+ /path/to/llvm-project/.build/aarch64_be-rel-with-deb-info/bin/FileCheck /path/to/llvm-project/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test --match-full-lines --check-prefix=LLVM
/path/to/llvm-project/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test:20:14: error: LLVM-NEXT: expected string not found in input
# LLVM-NEXT: AMD HSA Code Object Version: [Major: 2, Minor: 1]
             ^
<stdin>:15:68: note: scanning from here
 Type: NT_AMD_HSA_CODE_OBJECT_VERSION (AMD HSA Code Object Version)
                                                                   ^
<stdin>:16:2: note: possible intended match here
 AMD HSA Code Object Version: [Major: 33554432, Minor: 16777216]
 ^
                                                                                                                                                                                                                                                            
Input file: <stdin>
Check file: /path/to/llvm-project/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test                                                                                                                         

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions