+1998-03-05 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf/rtld.c: Speed up processing of environment variables. Do
+ only one run on the environment by avoiding to call getenv.
+ * sysdeps/generic/dl-sysdep.c (_dl_next_ld_env_entry): New
+ function. Used by patch above.
+
+1998-03-05 10:25 Ulrich Drepper <drepper@cygnus.com>
+
+ * nss/getXXbyYY_r.c: Don't try to contact nscd every time when it
+ failed. Only do this every NSS_NSCD_RETRY times.
+ * nss/nsswitch.c: Define __nss_nscd_not_available, used by above
+ change.
+ * nscd/nscd_getgr_r.c (__nscd_getgr_r): Return 2 if contacting the
+ daemon failed.
+ * nscd/nscd_getpw_r.c (__nscd_getpw_r): Likewise.
+
+1998-03-05 Ulrich Drepper <drepper@cygnus.com>
+
+ * nss/nsswitch.c (nss_lookup_function): Don't modify errno if NSS
+ module cannot be found. Reported by Andreas Jaeger.
+
+1998-03-05 11:40 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ * nscd/nscd_getgr_r.c: Change char to int to avoid compiler warning
+ on platforms which default to unsigned chars.
+ * nscd/nscd_getpw_r.c: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/sysdep.h: Undefine L before
+ defining it.
+
+1998-03-05 Andreas Jaeger <aj@arthur.rhein-neckar.de>
+
+ * elf/Makefile (install-bin): Change = to += for sprof to install
+ ldd also.
+
1998-03-04 16:12 H.J. Lu <hjl@gnu.org>
* libio/strops.c (_IO_str_seekoff): Handle MODE == 0.
* The localedata addon is now part of glibc.
* An implementation of profiling shared libraries was added by Ulrich Drepper.
+
+* Thorsten Kukuk provided an implementation for a caching daemon for NSS
+ (nscd).
+
+* Tim Waugh provided an implementation of the POSIX.2 wordexp function family.
\f
Version 2.0.5
`make dvi' will produce a DVI file of the printed manual.
`make info' will produce Info files that you can read on line using C-h i
in Emacs or the `info' program.
- Please send comments on the manual to bug-glibc-manual@prep.ai.mit.edu.
+ Please send comments on the manual to bug-glibc-manual@gnu.org.
* The library now supports SVR4 on i386s (i386-unknown-sysv4).
The GNU C Library is completely documented by the Texinfo manual found
in the `manual/' subdirectory. The manual is still being updated and
-contains some known errors and omissions; we regret that we do not have
-the resources to work on the manual as much as we would like. Please
-send comments on the manual to <bug-glibc-manual@prep.ai.mit.edu>, and
+contains some known errors and omissions; we regret that we do not
+have the resources to work on the manual as much as we would like.
+Please send comments on the manual to <bug-glibc-manual@gnu.org>, and
not to the library bug-reporting address.
The file NOTES contains a description of the feature-test macros used
endif
others = sprof
-install-bin = sprof
+install-bin += sprof
ifeq (yes,$(has-ldconfig))
others-static += ldconfig
static void print_missing_version (int errcode, const char *objname,
const char *errsting);
+
+/* This is a list of all the modes the dynamic loader can be in. */
+enum mode { normal, list, verify, trace };
+
+/* Process all environments variables the dynamic linker must recognize.
+ Since all of them start with `LD_' we are a bit smarter while finding
+ all the entries. */
+static void process_envvars (enum mode *modep, int *lazyp);
+
int _dl_argc;
char **_dl_argv;
const char *_dl_rpath;
return _dl_sysdep_start (arg, &dl_main);
}
-
/* Now life is peachy; we can do all normal operations.
On to the real work. */
const ElfW(Phdr) *ph;
struct link_map *main_map;
int lazy;
- enum { normal, list, verify, trace } mode;
+ enum mode mode;
struct link_map **preloads;
unsigned int npreloads;
const char *preloadlist;
char *file;
int has_interp = 0;
- /* Test whether we want to see the content of the auxiliary array passed
- up from the kernel. */
- if (getenv ("LD_SHOW_AUXV") != NULL)
- _dl_show_auxv ();
-
- mode = getenv ("LD_TRACE_LOADED_OBJECTS") != NULL ? trace : normal;
- _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1;
-
- /* LAZY is determined by the environment variable LD_WARN and
- LD_BIND_NOW if we trace the binary. */
- if (mode == trace)
- lazy = (_dl_verbose
- ? (*(getenv ("LD_BIND_NOW") ?: "") == '\0' ? 1 : 0) : -1);
- else
- lazy = !__libc_enable_secure && *(getenv ("LD_BIND_NOW") ?: "") == '\0';
-
- /* See whether we want to use profiling. */
- _dl_profile = getenv ("LD_PROFILE");
- if (_dl_profile != NULL)
- if (_dl_profile[0] == '\0')
- /* An empty string is of not much help. Disable profiling. */
- _dl_profile = NULL;
- else
- {
- /* OK, we have the name of a shared object we want to
- profile. It's up to the user to provide a good name, it
- must match the file name or soname of one of the loaded
- objects. Now let's see where we are supposed to place the
- result. */
- _dl_profile_output = getenv ("LD_PROFILE_OUTPUT");
-
- if (_dl_profile_output == NULL || _dl_profile_output[0] == '\0')
- /* This is the default place. */
- _dl_profile_output = "/var/tmp";
- }
+ /* Process the environment variable which control the behaviour. */
+ process_envvars (&mode, &lazy);
/* Set up a flag which tells we are just starting. */
_dl_starting_up = 1;
_dl_sysdep_error (_dl_argv[0] ?: "<program name unknown>", ": ",
objname, ": ", errstring, "\n", NULL);
}
+\f
+/* Process all environments variables the dynamic linker must recognize.
+ Since all of them start with `LD_' we are a bit smarter while finding
+ all the entries. */
+static void
+process_envvars (enum mode *modep, int *lazyp)
+{
+ char **runp = NULL;
+ char *envline;
+ enum mode mode = normal;
+ int bind_now = 0;
+
+ /* This is the default place for profiling data file. */
+ _dl_profile_output = "/var/tmp";
+
+ while ((envline = _dl_next_ld_env_entry (&runp)) != NULL)
+ {
+ int result;
+
+ /* Do we bind early? */
+ result = strncmp (&envline[3], "BIND_NOW=", 9);
+ if (result == 0)
+ {
+ bind_now = 1;
+ continue;
+ }
+ if (result < 0)
+ continue;
+
+ /* Which shared object shall be profiled. */
+ result = strncmp (&envline[3], "PROFILE=", 8);
+ if (result == 0)
+ {
+ _dl_profile = &envline[11];
+ if (*_dl_profile == '\0')
+ _dl_profile = NULL;
+ continue;
+ }
+ if (result < 0)
+ continue;
+
+ /* Where to place the profiling data file. */
+ result = strncmp (&envline[3], "PROFILE_OUTPUT=", 15);
+ if (result == 0)
+ {
+ _dl_profile_output = &envline[18];
+ if (*_dl_profile_output == '\0')
+ _dl_profile_output = "/var/tmp";
+ continue;
+ }
+ if (result < 0)
+ continue;
+
+ /* Test whether we want to see the content of the auxiliary
+ array passed up from the kernel. */
+ result = strncmp (&envline[3], "SHOW_AUXV=", 10);
+ if (result == 0)
+ {
+ _dl_show_auxv ();
+ continue;
+ }
+ if (result < 0)
+ continue;
+
+ /* The mode of the dynamic linker can be set. */
+ result = strncmp (&envline[3], "TRACE_LOADED_OBJECTS=", 21);
+ if (result == 0)
+ {
+ mode = trace;
+ continue;
+ }
+ if (result < 0)
+ continue;
+
+ /* Warning level, verbose or not. */
+ result = strncmp (&envline[3], "WARN=", 5);
+ if (result == 0)
+ {
+ _dl_verbose = envline[8] != '\0';
+ continue;
+ }
+ }
+
+ /* LAZY is determined by the environment variable LD_WARN and
+ LD_BIND_NOW if we trace the binary. */
+ if (mode == trace)
+ *lazyp = _dl_verbose ? !bind_now : -1;
+ else
+ *lazyp = !__libc_enable_secure && !bind_now;
+
+ *modep = mode;
+}
function's behavior disagrees with the manual, then either the library
or the manual has a bug, so report the disagreement. If you find any
errors or omissions in this manual, please report them to the Internet
-address @email{bug-glibc-manual@@prep.ai.mit.edu}.
+address @email{bug-glibc-manual@@gnu.org}.
@node Source Layout
@appendixsec Adding New Functions
size_t buflen)
{
char *p = buffer;
- char plen;
+ int plen;
plen = snprintf (buffer, buflen, "%d", gid);
if (plen == -1)
ssize_t nbytes;
if (sock == -1)
- return 1;
+ /* Returning two signals that contacting the daemon failed. */
+ return 2;
req.version = NSCD_VERSION;
req.type = type;
size_t buflen)
{
char *p = buffer;
- char plen;
+ int plen;
plen = snprintf (buffer, buflen, "%d", uid);
if (plen == -1)
ssize_t nbytes;
if (sock == -1)
- return 1;
+ /* Returning two signals that contacting the daemon failed. */
+ return 2;
req.version = NSCD_VERSION;
req.type = type;
/* The lookup function for the first entry of this service. */
extern int DB_LOOKUP_FCT (service_user **nip, const char *name, void **fctp);
+/* Nonzero if the NSCD is not available. This variable will be increased
+ whenever we try to use the NSCD but see it is not avilable. So we
+ can recheck the presence every once in a while. */
+extern int __nss_nscd_not_available;
+/* Interval in which we transfer retry to contact the NSCD. */
+#define NSS_NSCD_RETRY 100
int
#endif
#ifdef USE_NSCD
- nscd_status = NSCD_NAME (ADD_VARIABLES, resbuf, buffer, buflen H_ERRNO_VAR);
- if (nscd_status < 1)
+ if (__nss_nscd_not_available && ++__nss_nscd_not_available > NSS_NSCD_RETRY)
+ __nss_nscd_not_available = 0;
+
+ if (!__nss_nscd_not_available)
{
- *result = nscd_status == 0 ? resbuf : NULL;
- return nscd_status;
+ nscd_status = NSCD_NAME (ADD_VARIABLES, resbuf, buffer, buflen
+ H_ERRNO_VAR);
+ if (nscd_status < 1)
+ {
+ *result = nscd_status == 0 ? resbuf : NULL;
+ return nscd_status;
+ }
+ if (nscd_status == 2)
+ /* This return value indicates that contacting the server failed. */
+ __nss_nscd_not_available = 1;
}
#endif
status = (*fct) (ADD_VARIABLES, resbuf, buffer, buflen,
__errno_location () H_ERRNO_VAR);
- /* The the status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
+ /* The status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
provided buffer is too small. In this case we should give
the user the possibility to enlarge the buffer and we should
not simply go on with the next service (even if the TRYAGAIN
__libc_lock_define_initialized (static, lock)
+/* Nonzero if no NSCD is available. */
+int __nss_nscd_not_available;
+
#if !defined DO_STATIC_NSS || defined PIC
/* String with revision number of the shared object files. */
static const char *const __nss_shlib_revision = LIBNSS_FILES_SO + 15;
/* Load the shared library. */
size_t shlen = (7 + strlen (ni->library->name) + 3
+ strlen (__nss_shlib_revision) + 1);
-
+ int saved_errno = errno;
struct do_open_args args;
args.shlib_name = __alloca (shlen);
args.ni = ni;
__nss_shlib_revision);
if (nss_dlerror_run (do_open, &args) != 0)
- /* Failed to load the library. */
- ni->library->lib_handle = (void *) -1l;
+ {
+ /* Failed to load the library. */
+ ni->library->lib_handle = (void *) -1l;
+ __set_errno (saved_errno);
+ }
}
if (ni->library->lib_handle == (void *) -1l)
break;
}
}
+
+/* Walk through the environment of the process and return all entries
+ starting with `LD_'. */
+char *
+_dl_next_ld_env_entry (char ***position)
+{
+ char **current = *position;
+ char *result = NULL;
+
+ if (current == NULL)
+ /* We start over. */
+ current = _environ;
+
+ while (result == NULL && *current != NULL)
+ {
+ if ((*current)[0] == 'L' && (*current)[1] == 'D' && (*current)[2] == '_')
+ result = *current;
+
+ ++current;
+ }
+
+ /* Save current position for next visit. */
+ *position = current;
+
+ return result;
+}
-/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1997, 1998 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
END (name)
/* Local labels stripped out by the linker. */
+#undef L
#define L(x) .L##x
#endif /* ASSEMBLER */