diff --git a/porting/linux/user/include/dlfcn_ext.h b/porting/linux/user/include/dlfcn_ext.h index f9ec7f90025fbef58d49f961b56a8460adc1d223..72d5ae1ac6104e324779f3fd0cf083f7edc3f8d9 100644 --- a/porting/linux/user/include/dlfcn_ext.h +++ b/porting/linux/user/include/dlfcn_ext.h @@ -55,6 +55,25 @@ typedef struct { */ void *dlopen_ext(const char *file, int mode, const dl_extinfo *extinfo); +/** + * @brief open dso in given namespace which has own lib search paths, + * when namespace is null, it's same to dlopen_ext(). + * avoid using "default" as namespace, which is the default namespace. + * @param Dl_namespace * Carry the naming information of the namespace. + * @param char * the name of the so file you want to open. + * @param int open file mode. + * -- RTLD_LAZY. + * -- RTLD_NOW. + * -- RTLD_NOLOAD. + * -- RTLD_NODELETE. + * -- RTLD_GLOBAL. + * -- RTLD_LOCAL. + * @param dl_extinfo * indicates the dl_extinfo struct,include flag and relro_fd. + * @return success: dynamic library handleoid,failed: NULL. + * @retval none. + */ +void *dlopen_ns_ext(Dl_namespace *, const char *, int, const dl_extinfo *); + #ifdef __cplusplus } #endif diff --git a/porting/linux/user/ldso/dynlink.c b/porting/linux/user/ldso/dynlink.c index 6a4c474a7ba318f159890f8a04993789ef605fb4..9e6b0af43d0ca6a15ada66da6329db345187a856 100644 --- a/porting/linux/user/ldso/dynlink.c +++ b/porting/linux/user/ldso/dynlink.c @@ -3299,6 +3299,21 @@ void *dlopen_ns(Dl_namespace *dlns, const char *file, int mode) return dlopen_impl(file, mode, dlns->name, caller_addr, NULL); } +void *dlopen_ns_ext(Dl_namespace *dlns, const char *file, int mode, const dl_extinfo *extinfo) +{ + const void *caller_addr = __builtin_return_address(0); + musl_log_reset(); + ld_log_reset(); + LD_LOGI("dlopen_ns_ext file:%{public}s, mode:%{public}x , caller_addr:%{public}p , " + "dlns->name:%{public}s. , extinfo->flag:%{public}x", + file, + mode, + caller_addr, + dlns->name, + extinfo ? extinfo->flag : 0); + return dlopen_impl(file, mode, dlns->name, caller_addr, extinfo); +} + int dlns_create2(Dl_namespace *dlns, const char *lib_path, int flags) { if (!dlns) {