Teach fasload about cc_return objects.
authorChris Hanson <org/chris-hanson/cph>
Tue, 17 Sep 2019 06:13:44 +0000 (23:13 -0700)
committerChris Hanson <org/chris-hanson/cph>
Tue, 17 Sep 2019 06:13:44 +0000 (23:13 -0700)
Otherwise fasload gets SIGSEGV when the memory addresses are different.

src/microcode/fasl.c
src/microcode/fasl.h
src/microcode/fasload.c

index 32f2055fe042e2567e9e852c2bf8ae38bf73e49f..2a794e9041487816b3843aedfc9b706bfee1ed3c 100644 (file)
@@ -317,6 +317,17 @@ fasl_cc_address (SCHEME_OBJECT o, fasl_header_t * h)
   return (0);
 }
 
+insn_t *
+fasl_cc_return (SCHEME_OBJECT o, fasl_header_t * h)
+{
+  if ((FASLHDR_MEMORY_BASE (h)) != 0)
+    return (((insn_t *) (FASLHDR_MEMORY_BASE (h))) + (OBJECT_DATUM (o)));
+  if ((FASLHDR_ARCH (h)) == CURRENT_FASL_ARCH)
+    return (CC_RETURN_ADDRESS (o));
+  abort ();
+  return (0);
+}
+
 SCHEME_OBJECT
 fasl_raw_address_to_object (unsigned int type,
                            SCHEME_OBJECT * address,
index 3580d927e6e3e4f256d53ee756c2959c908c7148..2e923b8311b5808a3a33c0bb053fa3ff5556bc41 100644 (file)
@@ -203,6 +203,7 @@ extern bool read_fasl_header (fasl_header_t *, fasl_file_handle_t);
 extern bool read_from_fasl_file (void *, size_t, fasl_file_handle_t);
 extern SCHEME_OBJECT * fasl_object_address (SCHEME_OBJECT, fasl_header_t *);
 extern insn_t * fasl_cc_address (SCHEME_OBJECT, fasl_header_t *);
+extern insn_t * fasl_cc_return (SCHEME_OBJECT, fasl_header_t *);
 extern SCHEME_OBJECT fasl_raw_address_to_object
   (unsigned int, SCHEME_OBJECT *, fasl_header_t *);
 extern SCHEME_OBJECT fasl_raw_address_to_cc_entry (insn_t *, fasl_header_t *);
index 632b1ff28dcdea94c7cf18cc866770486869779e..2754f56381422d19292b0e135cfa7dcae3de11f1 100644 (file)
@@ -78,6 +78,7 @@ static gc_handler_t handle_primitive;
 static gc_tuple_handler_t fasload_tuple;
 static gc_vector_handler_t fasload_vector;
 static gc_object_handler_t fasload_cc_entry;
+static gc_object_handler_t fasload_cc_return;
 static gc_raw_address_to_object_t fasload_raw_address_to_object;
 static gc_raw_address_to_cc_entry_t fasload_raw_address_to_cc_entry;
 static void * relocate_address (void *);
@@ -490,6 +491,7 @@ relocate_block_table (void)
       (GCT_TUPLE (&table)) = fasload_tuple;
       (GCT_VECTOR (&table)) = fasload_vector;
       (GCT_CC_ENTRY (&table)) = fasload_cc_entry;
+      (GCT_CC_RETURN (&table)) = fasload_cc_return;
       (GCT_RAW_ADDRESS_TO_OBJECT (&table)) = fasload_raw_address_to_object;
       (GCT_RAW_ADDRESS_TO_CC_ENTRY (&table)) = fasload_raw_address_to_cc_entry;
 
@@ -517,6 +519,7 @@ DEFINE_GC_HANDLER (handle_primitive)
 
 #define OLD_ADDRESS(object) (fasl_object_address ((object), (fh)))
 #define OLD_CC_ADDRESS(object) (fasl_cc_address ((object), (fh)))
+#define OLD_CC_RETURN(object) (fasl_cc_return ((object), (fh)))
 
 static SCHEME_OBJECT
 fasload_raw_address_to_object (unsigned int type, SCHEME_OBJECT * address)
@@ -559,6 +562,18 @@ DEFINE_GC_OBJECT_HANDLER (fasload_cc_entry)
 #endif
 }
 
+static
+DEFINE_GC_OBJECT_HANDLER (fasload_cc_return)
+{
+#ifdef CC_SUPPORT_P
+  return
+    (CC_RETURN_NEW_ADDRESS (object,
+                           (relocate_address (OLD_CC_RETURN (object)))));
+#else
+  return (object);
+#endif
+}
+
 /* Relocate an address as read in from the file.  The address is
    examined to see what region of memory it belongs in.  */