[dwarfdump][AMDGPU] Support EF_AMDGPU_MACH_NONE
authorScott Linder <Scott.Linder@amd.com>
Wed, 19 Apr 2023 15:02:08 +0000 (15:02 +0000)
committerScott Linder <Scott.Linder@amd.com>
Wed, 19 Apr 2023 15:02:11 +0000 (15:02 +0000)
commit974f973d26a688f830fc7204a452b63f2f6cf868
tree3d29715f87443f926cdf4e0a4e6e07e45349ced2
parent4bb64daf34aa3463786f531b5b42d13ab5f47869
[dwarfdump][AMDGPU] Support EF_AMDGPU_MACH_NONE

A quirk of the AMDGPU backend is EF_AMDGPU_MACH_NONE, which is not
specific to the r600 or amdgcn architecture, but can be combined with
either.

AMDGPU ELF code objects with this mach value cannot be mapped back to a
Triple architecture, as it could be either r600 or amdgcn. For
llvm-dwarfdump this means the normal method of inspecting
ObjectFile::getArch to determine how to handle relocations is
insufficient.

This patch adds an extra check for ELF code objects which would
otherwise be categorized as UnknownArch, making it possible to use
llvm-dwarfdump with them. For completeness it also adds support for
known r600 machines.

This also adds specific tests for llvm-dwarfdump for amdgcn and r600,
both with known and unknown mach values.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D144301
llvm/lib/Object/RelocationResolver.cpp
llvm/test/tools/llvm-dwarfdump/AMDGPU/amdgpu-relocs.yaml [new file with mode: 0644]
llvm/test/tools/llvm-dwarfdump/AMDGPU/lit.local.cfg [new file with mode: 0644]