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

Peng Guo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 21:52:16 PDT 2020


pguo created this revision.
Herald added subscribers: llvm-commits, rupprecht, kristof.beyls.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: LLVM.
pguo requested review of this revision.

Before formating ARM64_RELOC_ADDEND relocation target name as 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89094

Files:
  llvm/tools/llvm-objdump/MachODump.cpp


Index: llvm/tools/llvm-objdump/MachODump.cpp
===================================================================
--- llvm/tools/llvm-objdump/MachODump.cpp
+++ llvm/tools/llvm-objdump/MachODump.cpp
@@ -451,9 +451,11 @@
 
   StringRef S;
   bool isExtern = O->getPlainRelocationExternal(RE);
+  bool isArm64 =
+      O->getArch() == Triple::aarch64 || O->getArch() == Triple::aarch64_be;
   uint64_t Val = O->getPlainRelocationSymbolNum(RE);
 
-  if (O->getAnyRelocationType(RE) == MachO::ARM64_RELOC_ADDEND) {
+  if (isArm64 && O->getAnyRelocationType(RE) == MachO::ARM64_RELOC_ADDEND) {
     Fmt << format("0x%0" PRIx64, Val);
     return;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89094.297121.patch
Type: text/x-patch
Size: 645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201009/1b2a8ebd/attachment.bin>


More information about the llvm-commits mailing list