hotspot/src/share/vm/asm/codeBuffer.cpp
changeset 14624 8f5ec8cfe196
parent 14294 130e947dfbe6
child 14626 0cf4eccf130f
--- a/hotspot/src/share/vm/asm/codeBuffer.cpp	Tue Nov 27 17:24:15 2012 -0800
+++ b/hotspot/src/share/vm/asm/codeBuffer.cpp	Tue Nov 27 17:41:38 2012 -0800
@@ -749,7 +749,18 @@
 
     // Make the new code copy use the old copy's relocations:
     dest_cs->initialize_locs_from(cs);
+  }
 
+  // Do relocation after all sections are copied.
+  // This is necessary if the code uses constants in stubs, which are
+  // relocated when the corresponding instruction in the code (e.g., a
+  // call) is relocated. Stubs are placed behind the main code
+  // section, so that section has to be copied before relocating.
+  for (int n = (int) SECT_FIRST; n < (int)SECT_LIMIT; n++) {
+    // pull code out of each section
+    const CodeSection* cs = code_section(n);
+    if (cs->is_empty()) continue;  // skip trivial section
+    CodeSection* dest_cs = dest->code_section(n);
     { // Repair the pc relative information in the code after the move
       RelocIterator iter(dest_cs);
       while (iter.next()) {