From 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Jul 2007 18:26:36 +0000 Subject: 2.5-18.1 --- dlfcn/dlmopen.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'dlfcn/dlmopen.c') diff --git a/dlfcn/dlmopen.c b/dlfcn/dlmopen.c index 5fd6543..0c69154 100644 --- a/dlfcn/dlmopen.c +++ b/dlfcn/dlmopen.c @@ -1,5 +1,5 @@ /* Load a shared object at run time. - Copyright (C) 1995,96,97,98,99,2000,2003,2004 Free Software Foundation, Inc. + Copyright (C) 1995-2000,2003,2004,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,6 +21,7 @@ #include #include #include +#include #include #if !defined SHARED && defined IS_IN_libdl @@ -54,15 +55,24 @@ dlmopen_doit (void *a) /* Non-shared code has no support for multiple namespaces. */ if (args->nsid != LM_ID_BASE) + { # ifdef SHARED - /* If trying to open the link map for the main executable the namespace - must be the main one. */ - if (args->file == NULL) + /* If trying to open the link map for the main executable the namespace + must be the main one. */ + if (args->file == NULL) # endif - GLRO(dl_signal_error) (EINVAL, NULL, NULL, N_("invalid namespace")); - - args->new = _dl_open (args->file ?: "", args->mode | __RTLD_DLOPEN, - args->caller, args->nsid); + GLRO(dl_signal_error) (EINVAL, NULL, NULL, N_("invalid namespace")); + + /* It makes no sense to use RTLD_GLOBAL when loading a DSO into + a namespace other than the base namespace. */ + if (__builtin_expect (args->mode & RTLD_GLOBAL, 0)) + GLRO(dl_signal_error) (EINVAL, NULL, NULL, N_("invalid mode")); + } + + args->new = GLRO(dl_open) (args->file ?: "", args->mode | __RTLD_DLOPEN, + args->caller, + args->nsid, __dlfcn_argc, __dlfcn_argv, + __environ); } -- cgit v1.1