[RuntimeDyld] Fix a bug in debugging output: all sections should be dumped
authorLang Hames <lhames@gmail.com>
Thu, 10 Sep 2015 20:44:36 +0000 (20:44 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 10 Sep 2015 20:44:36 +0000 (20:44 +0000)
before any relocations have been applied, and again after all relocations have
been applied.

Previously each section was dumped before and after relocations targetting it
were applied, but this only shows the impact of relocations that point to other
symbols in the same section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247335 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

index 42a0205331b031974d08cba4ceee4bed9f61602d..a2557cbb05534c6be5573d4e9ea2fe4ebf3b7bd6 100644 (file)
@@ -82,6 +82,12 @@ static void dumpSectionMemory(const SectionEntry &S, StringRef State) {
 void RuntimeDyldImpl::resolveRelocations() {
   MutexGuard locked(lock);
 
+  // Print out the sections prior to relocation.
+  DEBUG(
+    for (int i = 0, e = Sections.size(); i != e; ++i)
+      dumpSectionMemory(Sections[i], "before relocations");
+  );
+
   // First, resolve relocations associated with external symbols.
   resolveExternalSymbols();
 
@@ -94,11 +100,16 @@ void RuntimeDyldImpl::resolveRelocations() {
     uint64_t Addr = Sections[i].LoadAddress;
     DEBUG(dbgs() << "Resolving relocations Section #" << i << "\t"
                  << format("%p", (uintptr_t)Addr) << "\n");
-    DEBUG(dumpSectionMemory(Sections[i], "before relocations"));
     resolveRelocationList(Relocations[i], Addr);
-    DEBUG(dumpSectionMemory(Sections[i], "after relocations"));
     Relocations.erase(i);
   }
+
+  // Print out sections after relocation.
+  DEBUG(
+    for (int i = 0, e = Sections.size(); i != e; ++i)
+      dumpSectionMemory(Sections[i], "after relocations");
+  );
+
 }
 
 void RuntimeDyldImpl::mapSectionAddress(const void *LocalAddress,