From cdd10ca2806385aa539317c03239f042cd876b93 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sun, 19 Jul 2020 19:33:49 -0700 Subject: [PATCH] [JITLink][MachO] Tidy up debugging output for relocation parsing. Identify relocations by (section name, offset) pairs, rather than plain vmaddrs. This makes it easier to cross-reference debugging output for relocations with output from standard object inspection tools (otool, readelf, objdump, etc.). --- llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp | 14 +++++++++----- llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp | 13 +++++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp index 28adf9b..226955f 100644 --- a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp @@ -182,6 +182,8 @@ private: using namespace support; auto &Obj = getObject(); + LLVM_DEBUG(dbgs() << "Processing relocations:\n"); + for (auto &S : Obj.sections()) { JITTargetAddress SectionAddress = S.getAddress(); @@ -200,8 +202,8 @@ private: getSectionByIndex(Obj.getSectionIndex(S.getRawDataRefImpl())); if (!NSec.GraphSection) { LLVM_DEBUG({ - dbgs() << "Skipping relocations for MachO section " << NSec.SegName - << "/" << NSec.SectName + dbgs() << " Skipping relocations for MachO section " + << NSec.SegName << "/" << NSec.SectName << " which has no associated graph section\n"; }); continue; @@ -222,9 +224,10 @@ private: JITTargetAddress FixupAddress = SectionAddress + (uint32_t)RI.r_address; LLVM_DEBUG({ - dbgs() << "Processing " << getMachOARM64RelocationKindName(*Kind) - << " relocation at " << format("0x%016" PRIx64, FixupAddress) - << "\n"; + auto &NSec = + getSectionByIndex(Obj.getSectionIndex(S.getRawDataRefImpl())); + dbgs() << " " << NSec.SectName << " + " + << formatv("{0:x8}", RI.r_address) << ":\n"; }); // Find the block that the fixup points to. @@ -378,6 +381,7 @@ private: } LLVM_DEBUG({ + dbgs() << " "; Edge GE(*Kind, FixupAddress - BlockToFix->getAddress(), *TargetSymbol, Addend); printEdge(dbgs(), *BlockToFix, GE, diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp index 54d725e..134b01f 100644 --- a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp @@ -184,6 +184,8 @@ private: using namespace support; auto &Obj = getObject(); + LLVM_DEBUG(dbgs() << "Processing relocations:\n"); + for (auto &S : Obj.sections()) { JITTargetAddress SectionAddress = S.getAddress(); @@ -202,8 +204,8 @@ private: getSectionByIndex(Obj.getSectionIndex(S.getRawDataRefImpl())); if (!NSec.GraphSection) { LLVM_DEBUG({ - dbgs() << "Skipping relocations for MachO section " << NSec.SegName - << "/" << NSec.SectName + dbgs() << " Skipping relocations for MachO section " + << NSec.SegName << "/" << NSec.SectName << " which has no associated graph section\n"; }); continue; @@ -225,8 +227,10 @@ private: JITTargetAddress FixupAddress = SectionAddress + (uint32_t)RI.r_address; LLVM_DEBUG({ - dbgs() << "Processing relocation at " - << format("0x%016" PRIx64, FixupAddress) << "\n"; + auto &NSec = + getSectionByIndex(Obj.getSectionIndex(S.getRawDataRefImpl())); + dbgs() << " " << NSec.SectName << " + " + << formatv("{0:x8}", RI.r_address) << ":\n"; }); // Find the block that the fixup points to. @@ -341,6 +345,7 @@ private: } LLVM_DEBUG({ + dbgs() << " "; Edge GE(*Kind, FixupAddress - BlockToFix->getAddress(), *TargetSymbol, Addend); printEdge(dbgs(), *BlockToFix, GE, -- 2.7.4