X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-load.lisp;h=f30b8f109d0bb2f33623a39e3a3775eb6f587b27;hb=7c5138fcbdb302abc563a2060493f2f0304ae902;hp=56a139eda2f9317d71788abc6a5d4abcbf32bc8e;hpb=b7a8f5313a83dea33ce60551a4fb987b415c2cc6;p=sbcl.git diff --git a/src/code/target-load.lisp b/src/code/target-load.lisp index 56a139e..f30b8f1 100644 --- a/src/code/target-load.lisp +++ b/src/code/target-load.lisp @@ -42,6 +42,16 @@ ;;;; LOAD itself +(define-condition fasl-header-missing (invalid-fasl) + ((fhsss :reader invalid-fasl-fhsss :initarg :fhsss)) + (:report + (lambda (condition stream) + (format stream "~@" + (invalid-fasl-stream condition) + (invalid-fasl-expected condition) + (invalid-fasl-fhsss condition))))) + ;;; a helper function for LOAD: Load the stuff in a file when we have ;;; the name. (defun internal-load (pathname truename if-does-not-exist verbose print @@ -70,20 +80,28 @@ :element-type '(unsigned-byte 8)) (load-as-fasl stream verbose print))) (t - (let ((first-line (with-open-file (stream truename :direction :input) - (read-line stream nil))) - (fhsss *fasl-header-string-start-string*)) + (let* ((fhsss *fasl-header-string-start-string*) + (first-line (make-array (length fhsss) + :element-type '(unsigned-byte 8))) + (read-length + (with-open-file (stream truename + :direction :input + :element-type '(unsigned-byte 8)) + (read-sequence first-line stream)))) (cond - ((and first-line - (>= (length (the simple-string first-line)) - (length fhsss)) - (string= first-line fhsss :end1 (length fhsss))) + ((and (= read-length (length fhsss)) + (do ((i 0 (1+ i))) + ((= i read-length) t) + (when (/= (char-code (aref fhsss i)) (aref first-line i)) + (return)))) (internal-load pathname truename if-does-not-exist verbose print :binary)) (t (when (string= (pathname-type truename) *fasl-file-type*) - (error "File has a fasl file type, but no fasl file header:~% ~S" - (namestring truename))) + (error 'fasl-header-missing + :stream (namestring truename) + :fhsss first-line + :expected fhsss)) (internal-load pathname truename if-does-not-exist verbose print :source)))))))) @@ -114,7 +132,7 @@ (> (file-write-date src-tn) (file-write-date obj-tn))) (restart-case (error "The object file ~A is~@ - older than the presumed source:~% ~A." + older than the presumed source:~% ~A." (namestring obj-tn) (namestring src-tn)) ;; FIXME: In CMU CL one of these was a CONTINUE case. @@ -153,7 +171,7 @@ #!+sb-doc "Load the file given by FILESPEC into the Lisp environment, returning T on success." - + (declare (ignore external-format)) (let ((*load-depth* (1+ *load-depth*)) ;; KLUDGE: I can't find in the ANSI spec where it says that ;; DECLAIM/PROCLAIM of optimization policy should have file @@ -249,7 +267,7 @@ tto) (format t " loading to the dynamic space~%")) - (let ((code (%primitive sb!c:allocate-dynamic-code-object + (let ((code (%primitive sb!c:allocate-code-object box-num code-length)) (index (+ sb!vm:code-trace-table-offset-slot box-num))) @@ -271,26 +289,10 @@ ;;;; linkage fixups -;;; how we learn about assembler routines and foreign symbols at startup +;;; how we learn about assembler routines at startup (defvar *!initial-assembler-routines*) -(defvar *!initial-foreign-symbols*) + (defun !loader-cold-init () + (/show0 "/!loader-cold-init") (dolist (routine *!initial-assembler-routines*) - (setf (gethash (car routine) *assembler-routines*) (cdr routine))) - (dolist (symbol *!initial-foreign-symbols*) - (setf (gethash (car symbol) *static-foreign-symbols*) (cdr symbol)))) - -(declaim (ftype (function (string) (unsigned-byte #.sb!vm:n-machine-word-bits)) - foreign-symbol-address-as-integer)) - - -;;; SB!SYS:GET-DYNAMIC-FOREIGN-SYMBOL-ADDRESS is in foreign.lisp, on -;;; platforms that have dynamic loading -(defun foreign-symbol-address-as-integer (foreign-symbol) - (or (find-foreign-symbol-in-table foreign-symbol *static-foreign-symbols*) - (sb!sys:get-dynamic-foreign-symbol-address foreign-symbol) - (error "unknown foreign symbol: ~S" foreign-symbol))) - -(defun foreign-symbol-address (symbol) - (int-sap (foreign-symbol-address-as-integer - (sb!vm:extern-alien-name symbol)))) + (setf (gethash (car routine) *assembler-routines*) (cdr routine))))