From 5a94cffd3f8e09b0f7bf0d280d4369df678b5106 Mon Sep 17 00:00:00 2001 From: rbb Date: Wed, 20 Mar 2002 19:45:02 +0000 Subject: Load libraries if they not MH_BUNDLE, but if they are not, it just attempts to link them as shared libs. This is required to get the JVM loaded through APR. Submitted by: Pier Fumagalli Reviewed by: Ryan Bloom git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63166 13f79535-47bb-0310-9956-ffa450edef68 --- dso/unix/dso.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'dso') diff --git a/dso/unix/dso.c b/dso/unix/dso.c index 69fd8c401..944fafe15 100644 --- a/dso/unix/dso.c +++ b/dso/unix/dso.c @@ -72,6 +72,10 @@ #include /* for strerror() on HP-UX */ #endif +#if defined(DSO_USE_DYLD) +#define DYLD_LIBRARY_HANDLE (void *)-1 +#endif + APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, apr_os_dso_handle_t osdso, apr_pool_t *pool) @@ -99,7 +103,9 @@ static apr_status_t dso_cleanup(void *thedso) #if defined(DSO_USE_SHL) shl_unload((shl_t)dso->handle); #elif defined(DSO_USE_DYLD) - NSUnLinkModule(dso->handle, FALSE); + if (dso->handle != DYLD_LIBRARY_HANDLE) { + NSUnLinkModule(dso->handle, FALSE); + } #elif defined(DSO_USE_DLFCN) if (dlclose(dso->handle) != 0) return APR_EINIT; @@ -119,18 +125,21 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, NSObjectFileImage image; NSModule os_handle = NULL; char* err_msg = NULL; - if (NSCreateObjectFileImageFromFile(path, &image) != NSObjectFileImageSuccess) { - err_msg = "cannot create object file image"; - } - else { + if (NSCreateObjectFileImageFromFile(path, &image) == NSObjectFileImageSuccess) { #ifdef NSLINKMODULE_OPTION_PRIVATE - os_handle = NSLinkModule(image, path, - NSLINKMODULE_OPTION_PRIVATE | - NSLINKMODULE_OPTION_RETURN_ON_ERROR); + os_handle = NSLinkModule(image, path, + NSLINKMODULE_OPTION_PRIVATE | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); #else - os_handle = NSLinkModule(image, path, TRUE); + os_handle = NSLinkModule(image, path, TRUE); #endif - NSDestroyObjectFileImage(image); + NSDestroyObjectFileImage(image); + } + else if (NSAddLibrary(path) == TRUE) { + os_handle = (NSModule)DYLD_LIBRARY_HANDLE; + } + else { + err_msg = "cannot create object file image or add library"; } #elif defined(DSO_USE_DLFCN) @@ -208,7 +217,12 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, char *symname2 = (char*)malloc(sizeof(char)*(strlen(symname)+2)); sprintf(symname2, "_%s", symname); #ifdef NSLINKMODULE_OPTION_PRIVATE - symbol = NSLookupSymbolInModule((NSModule)handle->handle, symname2); + if (handle->handle == DYLD_LIBRARY_HANDLE) { + symbol = NSLookupAndBindSymbol(symname2); + } + else { + symbol = NSLookupSymbolInModule((NSModule)handle->handle, symname2); + } #else symbol = NSLookupAndBindSymbol(symname2); #endif -- cgit v1.2.1