Fix (GDB) debugging of code loaded from cache

When loading code from cache, set ELF section headers to point to real
location of executable code. This fixes GDB errors about being unable to
insert breakpoints at an invalid address.

Change-Id: I81f56a50b29ba34085fcac8630a188224313b3d1
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;
 }