- (define-alien-routine dlopen system-area-pointer
- (file c-string) (mode int))
-
- (define-alien-routine dlsym system-area-pointer
- (lib system-area-pointer) (name c-string))
-
- (define-alien-routine dlerror c-string)
-
-;;; Ensure that we've opened our own binary so we can dynamically resolve
-;;; symbols in the C runtime.
-;;;
-;;; Old comment: This used to happen only in
-;;; GET-DYNAMIC-FOREIGN-SYMBOL-ADDRESS, and only if no libraries were
-;;; dlopen()ed already, but that didn't work if something was
-;;; dlopen()ed before any problem global vars were used. So now we do
-;;; this in any function that can add to the *HANDLES-FROM-DLOPEN*, as
-;;; well as in GET-DYNAMIC-FOREIGN-SYMBOL-ADDRESS.
-;;;
-;;; FIXME: It would work just as well to do it once at startup, actually.
-;;; Then at least we know it's done. -dan 2001.05.10
- (defun ensure-runtime-symbol-table-opened ()
- (unless *handles-from-dlopen*
- ;; Prevent recursive call if dlopen() isn't defined.
- (setf *handles-from-dlopen* (int-sap 0))
- (setf *handles-from-dlopen* (list (dlopen nil rtld-lazy)))
- (when (zerop (sb-sys:sap-int (first *handles-from-dlopen*)))
- (error "can't open our own binary's symbol table: ~S" (dlerror)))))