<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65280>65280</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] llvm-readobj reads incorrect values from AMD note property on big-endian hosts
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kovdan01
      </td>
    </tr>
</table>

<pre>
    `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'
+ /home/kovdan01/Work/armpac/llvm-project/.build/aarch64_be-rel-with-deb-info/bin/yaml2obj /home/kovdan01/Work/armpac/llvm-project/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test -o /home/kovdan01/Work/armpac/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'
+ /home/kovdan01/Work/armpac/llvm-project/.build/aarch64_be-rel-with-deb-info/bin/llvm-readobj --notes /home/kovdan01/Work/armpac/llvm-project/.build/aarch64_be-rel-with-deb-info/test/tools/llvm-readobj/ELF/Output/note-amd-valid-v2.test.tmp.o
+ /home/kovdan01/Work/armpac/llvm-project/.build/aarch64_be-rel-with-deb-info/bin/FileCheck /home/kovdan01/Work/armpac/llvm-project/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test --match-full-lines --check-prefix=LLVM
/home/kovdan01/Work/armpac/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: /home/kovdan01/Work/armpac/llvm-project/llvm/test/tools/llvm-readobj/ELF/note-amd-valid-v2.test 
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVk1v2zgT_jX0ZSBBoizZPvig2BbaF3HyovF292ZQ4shiQpECSSXxv19Qsls3aLq77WYTCNGHST4fQ84Ms1YcFOKSpFckXU9Y7xptlg_6kTMVxZNS8-OSZNEBXb5d32iHJIug7lXlhFZQG92ClI8toYXTWlpCC_8aGGRcl_eEFpvrYt23HZqw6jqomZAWnAY_AB6Z7NGOq7gGId-uQWmH0BndoZFH0ApKcQhQccEUNNo6G8KuERaEBYO2lw50DSSLDArl0HQG3b5i1nmeT42oGj-y1lLqJ-RQHgdkoQ7ghx_QWHgSrtG9O4FCwxSXfoCugYu6RoPKwchAobUhidYkysf__9fWilIi1OIZWnFoHAhVyZ4j9Bb9Egxsh5VgEp4M6zxArc0F-EBxwET7XTwQbSdFJZw8EroCKR7Q67V912njSJKTJOfomJDjc8eqB-T7cYH9AF6Laj8gGiZJFoVwKYFk0ekaXov84zVJcri-_ryFcUV4PbSEFj5gAWt58Mik4MEjDR1aB4TOY6-fLhJCFyco-vMX7DZ3OyB09ovECJ2B17hZw6_QGQVtnoWDleboycTjt5O5K922THG47V3XD3ZYx9EYb0Zymh4EZ1-uvCKv7tNvN_6JOZBCIcwInV2MoUWjWyS0OB9QQovftXkgtGCm7Vh19qIz-h4rR2gRlr2Q3A9gpmqy6b7EwKAM_K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