Changeset 16522


Ignore:
Timestamp:
Sep 1, 2015, 3:03:29 AM (4 years ago)
Author:
gb
Message:

infer alignment in more cases.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/X86/x86-disassemble.lisp

    r16520 r16522  
    2222  (require "X86-ASM")
    2323  (require "X86-LAP"))
     24
     25(defparameter *tra-tag* (target-arch-case (:x8664 4) (:x8632 5)))
    2426
    2527(defstruct (x86-disassembled-instruction (:include dll-node)
     
    226228        (unless instruction
    227229          (error "Bug: no instruction at address #x~x" address))
    228         (return (or (x86-di-labeled instruction)
    229                     (setf (x86-di-labeled instruction) t)))))))
     230        (return (and
     231                 (or (x86-di-labeled instruction)
     232                    (setf (x86-di-labeled instruction) t))
     233                 instruction))))))
    230234
    231235
     
    24692473                            `(- (:^ ,label-ea))
    24702474                            `(:^ ,label-ea))))
    2471                    (push label-ea (x86-ds-pending-labels ds))
     2475                   (push (cons label-ea (if (eq flag :lea) *tra-tag*)) (x86-ds-pending-labels ds))
    24722476                   (when (or (eq flag :single) (eq flag :double))
    24732477                     (let* ((block (make-x86-dis-block :start-address label-ea
     
    24932497                     
    24942498                   
    2495                (if (and (setq disp (is-rip-ea op0)) (< disp 0) (is-fn op1))
     2499               (when (and (setq disp (is-rip-ea op0)) (< disp 0) (is-fn op1))
    24962500                 (setf (x86-di-mnemonic instruction) "recover-fn-from-rip"
    24972501                       (x86-di-op0 instruction) nil
     
    25422546                     (append-dll-node instruction instructions)
    25432547                     (setq labeled nil)
    2544                      (push target (x86-ds-pending-labels ds))
     2548                     (push (cons target *tra-tag*) (x86-ds-pending-labels ds))
    25452549                     (incf jtab 4)))
    25462550                 (insert-x86-block block (x86-ds-blocks ds)))
     
    26982702              (or stop (eq (x86-dis-flags dp) :jump))))))
    26992703
    2700 (defun x86-disassemble-new-block (ds addr)
     2704(defun x86-disassemble-new-block (ds addr &optional align)
    27012705  (setf (x86-ds-code-pointer ds) addr)
    27022706  (let* ((limit (do-dll-nodes (b (x86-ds-blocks ds) (x86-ds-code-limit ds))
     
    27082712    (loop
    27092713      (multiple-value-bind (instruction stop)
    2710           (x86-disassemble-instruction ds labeled)
    2711         (setq labeled nil)
     2714          (x86-disassemble-instruction ds (or align labeled))
     2715        (setq labeled nil align nil)
    27122716        (append-dll-node instruction instructions)
    27132717        (if stop (return))
     
    28942898            (when op2
    28952899              (write-x86-lap-operand t op2 ds)))))
    2896       (format t ")~vt;~8<[~D]~>" (+ comment-start-offset tab-stop) (+ pc #+x8664-target 15 #-x8664-target 7)))
     2900      (format t ")~vt;~8<[~D]~>" (+ comment-start-offset tab-stop) (+ pc (x86-ds-entry-point ds))))
    28972901    (when *disassemble-verbose*
    28982902      (let* ((istart (x86-di-start instruction))
     
    29182922(defun x86-print-disassembled-instruction (ds instruction seq function)
    29192923  (let* ((addr (x86-di-address instruction))
     2924         (labeled (x86-di-labeled instruction))
     2925         (align (if (typep labeled 'fixnum) labeled))
    29202926         (entry (x86-ds-entry-point ds))
    29212927         (pc (- addr entry)))
     
    29292935                       "#<no source text>")))
    29302936          (format t "~&~%;;; ~A" text))))
    2931     (when (x86-di-labeled instruction)
     2937    (when labeled
     2938      (when align (format t "~&~%~4t(:align ~d)" align))
    29322939      (format t "~&L~d~%" pc)
    29332940      (setq seq 0))
     
    29732980    (do* ()
    29742981         ((null (x86-ds-pending-labels ds)))
    2975       (let* ((lab (pop (x86-ds-pending-labels ds))))
    2976         (or (x86-dis-find-label lab blocks)
    2977             (x86-disassemble-new-block ds lab))))
     2982      (let* ((lab (pop (x86-ds-pending-labels ds)))
     2983             (align nil))
     2984        (when (consp lab)
     2985          (setq align (cdr lab) lab (car lab)))
     2986        (or (let* ((i (x86-dis-find-label lab blocks)))
     2987              (when (and i align) (setf (x86-di-labeled i) align))
     2988              i)
     2989            (x86-disassemble-new-block  ds lab align))))
    29782990    (when (and header-function
    29792991               blocks
Note: See TracChangeset for help on using the changeset viewer.