1998-03-08  Ulrich Drepper  <drepper@cygnus.com>

	* elf/rtld.c (process_envvars): Also recognize LD_LIBRARY_PATH,
	LD_PRELOAD, and LD_VERBOSE.
	(dl_main): Use global variables set by process_envvars instead of
	calling getenv.
	* elf/dl-load.c (_dl_init_paths): Don't call getenv to get
	LD_LIBRARY_PATH value, this comes with the parameter.
This commit is contained in:
Ulrich Drepper 1998-03-08 23:58:37 +00:00
parent 97a51d8a0c
commit 120b4c4986
3 changed files with 46 additions and 13 deletions

View File

@ -1,3 +1,12 @@
1998-03-08 Ulrich Drepper <drepper@cygnus.com>
* elf/rtld.c (process_envvars): Also recognize LD_LIBRARY_PATH,
LD_PRELOAD, and LD_VERBOSE.
(dl_main): Use global variables set by process_envvars instead of
calling getenv.
* elf/dl-load.c (_dl_init_paths): Don't call getenv to get
LD_LIBRARY_PATH value, this comes with the parameter.
1998-03-08 22:55 Ulrich Drepper <drepper@cygnus.com> 1998-03-08 22:55 Ulrich Drepper <drepper@cygnus.com>
* elf/rtld.c (dl_main): Delay initialization of path structure if * elf/rtld.c (dl_main): Delay initialization of path structure if

View File

@ -333,11 +333,6 @@ _dl_init_paths (const char *llp)
/* Number of elements in the library path. */ /* Number of elements in the library path. */
size_t nllp; size_t nllp;
/* If the user has not specified a library path consider the environment
variable. */
if (llp == NULL)
llp = getenv ("LD_LIBRARY_PATH");
/* First determine how many elements the LD_LIBRARY_PATH contents has. */ /* First determine how many elements the LD_LIBRARY_PATH contents has. */
if (llp != NULL && *llp != '\0') if (llp != NULL && *llp != '\0')
{ {

View File

@ -261,7 +261,11 @@ match_version (const char *string, struct link_map *map)
return 0; return 0;
} }
unsigned int _dl_skip_args; /* Nonzero if we were run directly. */ static unsigned int _dl_skip_args; /* Nonzero if we were run directly. */
static const char *library_path; /* The library search path. */
static const char *preloadlist; /* The list preloaded objects. */
static int version_info; /* Nonzero if information about
versions has to be printed. */
static void static void
dl_main (const ElfW(Phdr) *phdr, dl_main (const ElfW(Phdr) *phdr,
@ -274,7 +278,6 @@ dl_main (const ElfW(Phdr) *phdr,
enum mode mode; enum mode mode;
struct link_map **preloads; struct link_map **preloads;
unsigned int npreloads; unsigned int npreloads;
const char *preloadlist;
size_t file_size; size_t file_size;
char *file; char *file;
int has_interp = 0; int has_interp = 0;
@ -303,9 +306,6 @@ dl_main (const ElfW(Phdr) *phdr,
ourselves). This is an easy way to test a new ld.so before ourselves). This is an easy way to test a new ld.so before
installing it. */ installing it. */
/* Overwrites LD_LIBRARY_PATH if given. */
const char *library_path = NULL;
/* Note the place where the dynamic linker actually came from. */ /* Note the place where the dynamic linker actually came from. */
_dl_rtld_map.l_name = _dl_argv[0]; _dl_rtld_map.l_name = _dl_argv[0];
@ -472,7 +472,7 @@ of this helper program; chances are you did not intend to run this program.\n",
if (*user_entry != (ElfW(Addr)) &ENTRY_POINT) if (*user_entry != (ElfW(Addr)) &ENTRY_POINT)
/* Initialize the data structures for the search paths for shared /* Initialize the data structures for the search paths for shared
objects. */ objects. */
_dl_init_paths (NULL); _dl_init_paths (library_path);
/* Put the link_map for ourselves on the chain so it can be found by /* Put the link_map for ourselves on the chain so it can be found by
name. Note that at this point the global chain of link maps contains name. Note that at this point the global chain of link maps contains
@ -491,7 +491,6 @@ of this helper program; chances are you did not intend to run this program.\n",
preloads = NULL; preloads = NULL;
npreloads = 0; npreloads = 0;
preloadlist = getenv ("LD_PRELOAD");
if (preloadlist) if (preloadlist)
{ {
/* The LD_PRELOAD environment variable gives list of libraries /* The LD_PRELOAD environment variable gives list of libraries
@ -732,7 +731,7 @@ of this helper program; chances are you did not intend to run this program.\n",
} }
#define VERNEEDTAG (DT_NUM + DT_PROCNUM + DT_VERSIONTAGIDX (DT_VERNEED)) #define VERNEEDTAG (DT_NUM + DT_PROCNUM + DT_VERSIONTAGIDX (DT_VERNEED))
if (*(getenv ("LD_VERBOSE") ?: "") != '\0') if (version_info)
{ {
/* Print more information. This means here, print information /* Print more information. This means here, print information
about the versions needed. */ about the versions needed. */
@ -1006,6 +1005,26 @@ process_envvars (enum mode *modep, int *lazyp)
if (result < 0) if (result < 0)
continue; continue;
/* The library search path. */
result = strncmp (&envline[3], "LIBRARY_PATH=", 13);
if (result == 0)
{
library_path = &envline[16];
continue;
}
if (result < 0)
continue;
/* List of objects to be preloaded. */
result = strncmp (&envline[3], "PRELOAD=", 8);
if (result == 0)
{
preloadlist = &envline[11];
continue;
}
if (result < 0)
continue;
/* Which shared object shall be profiled. */ /* Which shared object shall be profiled. */
result = strncmp (&envline[3], "PROFILE=", 8); result = strncmp (&envline[3], "PROFILE=", 8);
if (result == 0) if (result == 0)
@ -1051,6 +1070,16 @@ process_envvars (enum mode *modep, int *lazyp)
if (result < 0) if (result < 0)
continue; continue;
/* Print information about versions. */
result = strncmp (&envline[3], "VERBOSE=", 8);
if (result == 0)
{
version_info = envline[11] != '\0';
continue;
}
if (result < 0)
continue;
/* Warning level, verbose or not. */ /* Warning level, verbose or not. */
result = strncmp (&envline[3], "WARN=", 5); result = strncmp (&envline[3], "WARN=", 5);
if (result == 0) if (result == 0)