[llvm] cdd10ca - [JITLink][MachO] Tidy up debugging output for relocation parsing.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 19 19:46:04 PDT 2020
Author: Lang Hames
Date: 2020-07-19T19:45:50-07:00
New Revision: cdd10ca2806385aa539317c03239f042cd876b93
URL: https://github.com/llvm/llvm-project/commit/cdd10ca2806385aa539317c03239f042cd876b93
DIFF: https://github.com/llvm/llvm-project/commit/cdd10ca2806385aa539317c03239f042cd876b93.diff
LOG: [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.).
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
index 28adf9b3fb71..226955fbceb4 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
@@ -182,6 +182,8 @@ class MachOLinkGraphBuilder_arm64 : public MachOLinkGraphBuilder {
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 @@ class MachOLinkGraphBuilder_arm64 : public MachOLinkGraphBuilder {
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 @@ class MachOLinkGraphBuilder_arm64 : public MachOLinkGraphBuilder {
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 @@ class MachOLinkGraphBuilder_arm64 : public MachOLinkGraphBuilder {
}
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 54d725eac144..134b01f0f656 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
@@ -184,6 +184,8 @@ class MachOLinkGraphBuilder_x86_64 : public MachOLinkGraphBuilder {
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 @@ class MachOLinkGraphBuilder_x86_64 : public MachOLinkGraphBuilder {
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 @@ class MachOLinkGraphBuilder_x86_64 : public MachOLinkGraphBuilder {
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 @@ class MachOLinkGraphBuilder_x86_64 : public MachOLinkGraphBuilder {
}
LLVM_DEBUG({
+ dbgs() << " ";
Edge GE(*Kind, FixupAddress - BlockToFix->getAddress(), *TargetSymbol,
Addend);
printEdge(dbgs(), *BlockToFix, GE,
More information about the llvm-commits
mailing list