Merge "Fix (GDB) debugging of code loaded from cache"
diff --git a/lib/ExecutionEngine/MCCacheReader.cpp b/lib/ExecutionEngine/MCCacheReader.cpp
index a88d4d4..c3d132e 100644
--- a/lib/ExecutionEngine/MCCacheReader.cpp
+++ b/lib/ExecutionEngine/MCCacheReader.cpp
@@ -443,6 +443,13 @@
                      mpResult->mCachedELFExecutable.size(),
                      &resolveSymbolAdapter, this);
 
+  // Point ELF section headers to location of executable code, otherwise
+  // execution through GDB stops unexpectedly as GDB translates breakpoints
+  // in JITted code incorrectly (and complains about being unable to insert
+  // breakpoint at an invalid address)
+  rsloaderUpdateSectionHeaders(mpResult->mRSExecutable,
+    (unsigned char*) mpResult->mCachedELFExecutable.begin());
+
   return true;
 }