Changeset 14180
- Timestamp:
- Aug 13, 2010, 3:15:10 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/source/level-0/l0-cfm-support.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/level-0/l0-cfm-support.lisp
r14155 r14180 716 716 717 717 (defun legacy-shlib-containing-address (addr name) 718 (dotimes (i (ff-call *dyld-image-count* :unsigned-fullword)) 719 (let ((header (ff-call *dyld-get-image-header* :unsigned-fullword i :address))) 720 (when (and (not (%null-ptr-p header)) 721 (or (eql (pref header :mach_header.filetype) #$MH_DYLIB) 722 (eql (pref header :mach_header.filetype) #$MH_BUNDLE))) 723 ;; make sure the image is either a bundle or a dylib 724 ;; (otherwise we will crash, likely OS bug, tested OS X 10.1.5) 725 (with-cstrs ((cname name)) 726 ;; also we must check is symbol name is defined in the 727 ;; image otherwise in certain cases there is a crash, 728 ;; another likely OS bug happens in the case where a 729 ;; bundle imports a dylib and then we call 730 ;; nslookupsymbolinimage on the bundle image 731 (when (/= 0 732 (ff-call *ns-is-symbol-name-defined-in-image* :address header 733 :address cname :unsigned)) 734 (let ((symbol (ff-call *nslookup-symbol-in-image* :address header :address cname 735 :unsigned-fullword #$NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 736 :address))) 737 (unless (%null-ptr-p symbol) 738 ;; compare the found address to the address we are looking for 739 (let ((foundaddr (ff-call *nsaddress-of-symbol* :address symbol :address))) 740 ;; (format t "Foundaddr ~s~%" foundaddr) 741 ;; (format t "Compare to addr ~s~%" addr) 742 (when (eql foundaddr addr) 743 (let* ((imgname (ff-call *dyld-get-image-name* :unsigned-fullword i :address)) 744 (libname (unless (%null-ptr-p imgname) (%get-cstring imgname))) 745 (libmodule (%int-to-ptr 0)) 746 (libheader (%int-to-ptr 0))) 747 (if (eql (pref header :mach_header.filetype) #$MH_BUNDLE) 748 (setf libmodule (ff-call *nsmodule-for-symbol* :address symbol :address)) 749 (setf libheader header)) 750 ;; make sure that this shared library is on *shared-libraries* 751 (return (shared-library-from-header-module-or-name libheader libmodule libname))))))))))))) 718 (when *ns-is-symbol-name-defined-in-image* 719 (dotimes (i (ff-call *dyld-image-count* :unsigned-fullword)) 720 (let ((header (ff-call *dyld-get-image-header* :unsigned-fullword i :address))) 721 (when (and (not (%null-ptr-p header)) 722 (or (eql (pref header :mach_header.filetype) #$MH_DYLIB) 723 (eql (pref header :mach_header.filetype) #$MH_BUNDLE))) 724 ;; make sure the image is either a bundle or a dylib 725 ;; (otherwise we will crash, likely OS bug, tested OS X 10.1.5) 726 (with-cstrs ((cname name)) 727 ;; also we must check is symbol name is defined in the 728 ;; image otherwise in certain cases there is a crash, 729 ;; another likely OS bug happens in the case where a 730 ;; bundle imports a dylib and then we call 731 ;; nslookupsymbolinimage on the bundle image 732 (when (/= 0 733 (ff-call *ns-is-symbol-name-defined-in-image* :address header 734 :address cname :unsigned)) 735 (let ((symbol (ff-call *nslookup-symbol-in-image* :address header :address cname 736 :unsigned-fullword #$NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 737 :address))) 738 (unless (%null-ptr-p symbol) 739 ;; compare the found address to the address we are looking for 740 (let ((foundaddr (ff-call *nsaddress-of-symbol* :address symbol :address))) 741 ;; (format t "Foundaddr ~s~%" foundaddr) 742 ;; (format t "Compare to addr ~s~%" addr) 743 (when (eql foundaddr addr) 744 (let* ((imgname (ff-call *dyld-get-image-name* :unsigned-fullword i :address)) 745 (libname (unless (%null-ptr-p imgname) (%get-cstring imgname))) 746 (libmodule (%int-to-ptr 0)) 747 (libheader (%int-to-ptr 0))) 748 (if (eql (pref header :mach_header.filetype) #$MH_BUNDLE) 749 (setf libmodule (ff-call *nsmodule-for-symbol* :address symbol :address)) 750 (setf libheader header)) 751 ;; make sure that this shared library is on *shared-libraries* 752 (return (shared-library-from-header-module-or-name libheader libmodule libname)))))))))))))) 752 753 753 754 (defun shlib-containing-address (address name)
Note:
See TracChangeset
for help on using the changeset viewer.
