Index: /branches/x8664-call/ccl/compiler/X86/x86-disassemble.lisp
===================================================================
--- /branches/x8664-call/ccl/compiler/X86/x86-disassemble.lisp	(revision 6295)
+++ /branches/x8664-call/ccl/compiler/X86/x86-disassemble.lisp	(revision 6296)
@@ -2350,4 +2350,6 @@
   ;; If the instruction is a MOV or PUSH whose source operand
   ;; is relative to the FN register, generate a constant reference.
+  ;; If the instruction is adding a displacement to RIP, note
+  ;; the effective address as a label reference.
   (let* ((op0 (x86-di-op0 instruction))
          (op1 (x86-di-op1 instruction))
@@ -2359,4 +2361,9 @@
                              (x86::x86-reg64 13)
                              (x86::x86-reg32 6))))))
+           (is-rip (thing)
+             (if (and (typep thing 'x86::x86-register-operand)
+                      (x86-ds-mode-64 ds))
+               (let* ((entry (x86::x86-register-operand-entry thing)))
+                 (eq entry (svref x86::*x8664-register-entries* 102)))))
            (is-ra0 (thing)
              (if (typep thing 'x86::x86-register-operand)
@@ -2385,4 +2392,12 @@
                       (or (null scale) (eql 0 scale)))
                     (let* ((disp (x86::x86-memory-operand-disp thing)))
+                      (and disp (early-x86-lap-expression-value disp)))))
+             (is-rip-ea (thing)
+               (and (typep thing 'x86::x86-memory-operand)
+                    (is-rip (x86::x86-memory-operand-base thing))
+                    (null (x86::x86-memory-operand-index thing))
+                    (let* ((scale (x86::x86-memory-operand-scale thing)))
+                      (or (null scale) (eql 0 scale)))
+                    (let* ((disp (x86::x86-memory-operand-disp thing)))
                       (and disp (early-x86-lap-expression-value disp))))))
         (case flag
@@ -2391,5 +2406,5 @@
           (:lea
            (let* ((disp ))
-             (when (or (and (setq disp (is-fn-ea op0)) (> disp 0))
+             (if (or (and (setq disp (is-fn-ea op0)) (> disp 0))
                        (and (setq disp (is-ra0-ea op0)) (< disp 0) (is-fn op1)))
                (let* ((label-ea (+ entry-ea (abs disp))))
@@ -2400,5 +2415,10 @@
                             `(- (:^ ,label-ea))
                             `(:^ ,label-ea))))
-                   (push label-ea (x86-ds-pending-labels ds)))))))
+                   (push label-ea (x86-ds-pending-labels ds))))
+               (if (and (setq disp (is-rip-ea op0)) (< disp 0) (is-fn op1))
+                 (progn
+                   (setf (x86::x86-memory-operand-disp op0)
+                         (parse-x86-lap-expression `(:^ ,entry-ea)))
+                   (push entry-ea (x86-ds-pending-labels ds)))))))
           (:jump
            (let* ((disp (is-disp-only op0)))
