[objdump][macho] Check arch before formating reloc name as arm64 addend

Before formating ARM64_RELOC_ADDEND relocation target name as a hex
number, the architecture need to be checked since other architectures
can define a different relocation type with the same integer as
ARM64_RELOC_ADDEND.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D89094
This commit is contained in:
Peng Guo 2020-10-16 13:47:46 -07:00 committed by Daniel Sanders
parent f16cecf375
commit 109113015e
1 changed files with 2 additions and 1 deletions

View File

@ -453,7 +453,8 @@ static void printRelocationTargetName(const MachOObjectFile *O,
bool isExtern = O->getPlainRelocationExternal(RE);
uint64_t Val = O->getPlainRelocationSymbolNum(RE);
if (O->getAnyRelocationType(RE) == MachO::ARM64_RELOC_ADDEND) {
if (O->getAnyRelocationType(RE) == MachO::ARM64_RELOC_ADDEND &&
(O->getArch() == Triple::aarch64 || O->getArch() == Triple::aarch64_be)) {
Fmt << format("0x%0" PRIx64, Val);
return;
}