From 9d4ce9a5d50788ac8c636881861cb1c2ab45fc52 Mon Sep 17 00:00:00 2001 From: Gurusamy Sarathy Date: Thu, 6 Jan 2000 20:11:46 +0000 Subject: add workaround for dlopen() bug on OpenBSD (relative paths that match /^lib/ won't load properly) p4raw-id: //depot/perl@4765 --- ext/DynaLoader/dl_dlopen.xs | 17 ++++++++++++++--- ext/DynaLoader/hints/openbsd.pl | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 ext/DynaLoader/hints/openbsd.pl (limited to 'ext/DynaLoader') diff --git a/ext/DynaLoader/dl_dlopen.xs b/ext/DynaLoader/dl_dlopen.xs index 9c07e60464..135f5112f2 100644 --- a/ext/DynaLoader/dl_dlopen.xs +++ b/ext/DynaLoader/dl_dlopen.xs @@ -146,9 +146,20 @@ void * dl_load_file(filename, flags=0) char * filename int flags - PREINIT: + PREINIT: int mode = RTLD_LAZY; - CODE: + CODE: +{ +#if defined(DLOPEN_WONT_DO_RELATIVE_PATHS) + char pathbuf[PATH_MAX + 2]; + if (*filename != '/' && strchr(filename, '/')) { + if (getcwd(pathbuf, PATH_MAX - strlen(filename))) { + strcat(pathbuf, "/"); + strcat(pathbuf, filename); + filename = pathbuf; + } + } +#endif #ifdef RTLD_NOW if (dl_nonlazy) mode = RTLD_NOW; @@ -167,7 +178,7 @@ dl_load_file(filename, flags=0) SaveError(aTHX_ "%s",dlerror()) ; else sv_setiv( ST(0), PTR2IV(RETVAL)); - +} void * dl_find_symbol(libhandle, symbolname) diff --git a/ext/DynaLoader/hints/openbsd.pl b/ext/DynaLoader/hints/openbsd.pl new file mode 100644 index 0000000000..aeaa92c5a5 --- /dev/null +++ b/ext/DynaLoader/hints/openbsd.pl @@ -0,0 +1,3 @@ +# XXX Configure test needed? +# Some OpenBSDs seem to have a dlopen() that won't accept relative paths +$self->{CCFLAGS} = $Config{ccflags} . ' -DDLOPEN_WONT_DO_RELATIVE_PATHS'; -- cgit v1.2.1