Index: /branches/ia32/xdump/xfasload.lisp
===================================================================
--- /branches/ia32/xdump/xfasload.lisp	(revision 8063)
+++ /branches/ia32/xdump/xfasload.lisp	(revision 8064)
@@ -1659,4 +1659,34 @@
     (setq *xload-loading-file-source-file* path)))
 
+;;; Use the offsets in the self-reference table to replace the :self
+;;; in (movl ($ :self) (% fn)) wih the function's actual address.
+;;; (x8632 only)
+(defun xload-fixup-self-references (addr)
+  (let* ((imm-word-count (xload-u16-at-address
+			  (+ addr *xload-target-misc-data-offset*))))
+    (do* ((i (- imm-word-count 2) (1- i))
+	  (offset (xload-%fullword-ref addr i) (xload-%fullword-ref addr i)))
+	 ((zerop offset))
+      (setf (xload-u8-at-address (+ *xload-target-misc-header-offset*
+				    addr
+				    offset
+				    0))
+				 (ldb (byte 8 0) addr)
+	    (xload-u8-at-address (+ *xload-target-misc-header-offset*
+				    addr
+				    offset
+				    1))
+				 (ldb (byte 8 8) addr)
+	    (xload-u8-at-address (+ *xload-target-misc-header-offset*
+				    addr
+				    offset
+				    2))
+				 (ldb (byte 8 16) addr)
+	    (xload-u8-at-address (+ *xload-target-misc-header-offset*
+				    addr
+				    offset
+				    3))
+				 (ldb (byte 8 24) addr)))))
+      
 (defxloadfaslop $fasl-clfun (s)
   (let* ((size-in-elements (%fasl-read-count s))
@@ -1675,4 +1705,6 @@
         (%fasl-read-n-bytes s v (+ o *xload-target-misc-data-offset*)
                             (ash size-of-code *xload-target-fixnumshift*))
+	(target-arch-case
+	 (:x8632 (xload-fixup-self-references vector)))
         (do* ((numconst (- size-in-elements size-of-code))
               (i 0 (1+ i))
