aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-08-29 00:31:18 +0000
committerUlrich Drepper <drepper@redhat.com>1996-08-29 00:31:18 +0000
commit14bab8de31e04b990c2ce83d844f634ec57a6cc6 (patch)
treef6a25bd165f8997c08e58f6f2de69e9d34e0fda0 /elf
parentb236e99d90748f6caf77994e96dc5aaa48ce2993 (diff)
downloadglibc-14bab8de31e04b990c2ce83d844f634ec57a6cc6.tar
glibc-14bab8de31e04b990c2ce83d844f634ec57a6cc6.tar.gz
glibc-14bab8de31e04b990c2ce83d844f634ec57a6cc6.tar.bz2
glibc-14bab8de31e04b990c2ce83d844f634ec57a6cc6.zip
update from main archive 960828glibc-1.93cvs/libc-960829cvs/libc-1-93
Thu Aug 29 00:28:08 1996 Ulrich Drepper <drepper@cygnus.com> * stdio-common/printf_fp.c (__printf_fp): Use default value `.` if `decimal' char is 0. * C-numeric.c (not_available): New constant. (_nl_C_LC_NUMERIC): Use `not_available' for grouping value. * nss/nsswitch.conf: Example configuration file. * nss/db-Makefile: Example Makefile for generation of databases for nss_db. * nss/Makefile (distribute): Add nsswitch.conf and db-Makefile. 1996-08-28 Paul Eggert <eggert@twinsun.com> * C-messages.c (_nl_C_LC_MESSAGES): Set yesexpr to "^[yY]" and noexpr to "^[nN]"; this conforms to POSIX.2. * C-time.c (_nl_C_LC_TIME): Change %d to %e in d_t_format, to conform to POSIX.2. 1996-08-28 Paul Eggert <eggert@twinsun.com> * C-monetary.c (not_available): New constant. (_nl_C_LC_MONETARY): Set mon_decimal_point to "", and set mon_grouping, int_frac_digits, frac_digits, p_cs_precedes, p_sep_by_space, n_cs_precedes, n_sep_by_space, p_sign_posn, and n_sign_posn to CHAR_MAX, as required by the POSIX Standard. Wed Aug 28 23:12:28 1996 Ulrich Drepper <drepper@cygnus.com> * nss/nss_db/db-XXX.c: Correct function names. They must be `_nss_db_*' instead of `_nss_files_*'. (lookup): `parse_line' returns 1 if succesful. * nss/nss_files/files-service.c (servbyname): Key for database must also contain protocol names. (servbypt): Likewise. Test must also check for protocol. Add `proto' argument. Tue Aug 27 09:56:13 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * MakeTAGS ($P/subdirs.pot): Prefix all file names, not only the first one. Fri Aug 16 16:11:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> * nss/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r): Treat EPFNOSUPPORT and EAFNOSUPPORT as implying NSS_STATUS_UNAVAIL just like ECONNREFUSED already does. (_nss_dns_gethostbyaddr_r): Likewise. * nss/nss_dns/dns-network.c (_nss_dns_getnetbyname_r): Likewise. (_nss_dns_getnetbyaddr_r): Likewise. * sysdeps/mach/hurd/socket.c (socket): For message transmission and RPC errors that indicate that the socket server is not really present and able to do its job, turn the error into EPFNOSUPPORT. * sysdeps/generic/sbrk.c (__sbrk): Get kernel brk address always only if in static libc or if statically linked program uses libc.so.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-error.c9
-rw-r--r--elf/dl-load.c7
-rw-r--r--elf/dlerror.c2
-rw-r--r--elf/link.h5
-rw-r--r--elf/rtld.c115
5 files changed, 110 insertions, 28 deletions
diff --git a/elf/dl-error.c b/elf/dl-error.c
index 2eaa7e03d1..40ded4f1d2 100644
--- a/elf/dl-error.c
+++ b/elf/dl-error.c
@@ -20,13 +20,15 @@ Cambridge, MA 02139, USA. */
#include <stddef.h>
#include <link.h>
#include <setjmp.h>
+#include <stdlib.h>
#include <string.h>
/* This structure communicates state between _dl_catch_error and
_dl_signal_error. */
struct catch
{
- const char *errstring, *objname; /* Error detail filled in here. */
+ char *errstring; /* Error detail filled in here. */
+ const char *objname;
jmp_buf env; /* longjmp here on error. */
};
@@ -69,7 +71,7 @@ _dl_signal_error (int errcode,
}
int
-_dl_catch_error (const char **errstring,
+_dl_catch_error (char **errstring,
const char **objname,
void (*operate) (void))
{
@@ -82,7 +84,8 @@ _dl_catch_error (const char **errstring,
catch = &c;
(*operate) ();
catch = NULL;
- *errstring = *objname = NULL;
+ *errstring = NULL;
+ *objname = NULL;
return 0;
}
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 6fd6a6cbe0..b56303fa4a 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -481,6 +481,7 @@ _dl_map_object (struct link_map *loader, const char *name, int type)
{
int fd;
char *realname;
+ char *name_copy;
struct link_map *l;
/* Look for this name among those already loaded. */
@@ -572,8 +573,8 @@ _dl_map_object (struct link_map *loader, const char *name, int type)
if (fd != -1)
{
- name = local_strdup (name);
- if (name == NULL)
+ name_copy = local_strdup (name);
+ if (name_copy == NULL)
{
__close (fd);
fd = -1;
@@ -583,5 +584,5 @@ _dl_map_object (struct link_map *loader, const char *name, int type)
if (fd == -1)
_dl_signal_error (errno, name, "cannot open shared object file");
- return _dl_map_object_from_fd (name, fd, realname, loader, type);
+ return _dl_map_object_from_fd (name_copy, fd, realname, loader, type);
}
diff --git a/elf/dlerror.c b/elf/dlerror.c
index 663207d708..9b78e47a57 100644
--- a/elf/dlerror.c
+++ b/elf/dlerror.c
@@ -24,7 +24,7 @@ Cambridge, MA 02139, USA. */
#include <stdlib.h>
static int last_errcode;
-static const char *last_errstring;
+static char *last_errstring;
static const char *last_object_name;
char *
diff --git a/elf/link.h b/elf/link.h
index a9637000e5..a6281726c3 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -178,8 +178,9 @@ extern void _dl_signal_error (int errcode,
/* Call OPERATE, catching errors from `dl_signal_error'. If there is no
error, *ERRSTRING is set to null. If there is an error, *ERRSTRING and
*OBJECT are set to the strings passed to _dl_signal_error, and the error
- code passed is the return value. */
-extern int _dl_catch_error (const char **errstring,
+ code passed is the return value. ERRSTRING if nonzero points to a
+ malloc'ed string which the caller has to free after use. */
+extern int _dl_catch_error (char **errstring,
const char **object,
void (*operate) (void));
diff --git a/elf/rtld.c b/elf/rtld.c
index 8b754920f8..0736218536 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -38,6 +38,12 @@ extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
ElfW(Addr) *user_entry));
extern void _dl_sysdep_start_cleanup (void);
+/* System-dependent function to read a file's whole contents
+ in the most convenient manner available. */
+extern void *_dl_sysdep_read_whole_file (const char *filename,
+ size_t *filesize_ptr,
+ int mmap_prot);
+
int _dl_argc;
char **_dl_argv;
const char *_dl_rpath;
@@ -138,6 +144,8 @@ dl_main (const ElfW(Phdr) *phdr,
enum { normal, list, verify, trace } mode;
struct link_map **preloads;
unsigned int npreloads;
+ size_t file_size;
+ char *file;
mode = getenv ("LD_TRACE_LOADED_OBJECTS") != NULL ? trace : normal;
@@ -296,8 +304,77 @@ of this helper program; chances are you did not intend to run this program.\n",
l->l_next = &_dl_rtld_map;
_dl_rtld_map.l_prev = l;
+ /* We have two ways to specify objects to preload: via environment
+ variable and via the file /etc/ld.so.preload. The later can also
+ be used when security is enabled. */
preloads = NULL;
npreloads = 0;
+
+ /* Read the contents of the file. */
+ file = _dl_sysdep_read_whole_file ("/etc/ld.so.preload", &file_size,
+ PROT_READ | PROT_WRITE);
+ if (file)
+ {
+ /* Parse the file. It contains names of libraries to be loaded,
+ separated by white spaces or `:'. It may also contain
+ comments introduced by `#'. */
+ char *problem;
+ char *runp;
+ size_t rest;
+
+ /* Eliminate comments. */
+ runp = file;
+ rest = file_size;
+ while (rest > 0)
+ {
+ char *comment = memchr (runp, '#', rest);
+ if (comment == NULL)
+ break;
+
+ rest -= comment - runp;
+ do
+ *comment = ' ';
+ while (--rest > 0 && *++comment != '\n');
+ }
+
+ /* We have one problematic case: if we have a name at the end of
+ the file without a trailing terminating characters, we cannot
+ place the \0. Handle the case separately. */
+ if (file[file_size - 1] != ' ' && file[file_size] != '\t'
+ && file[file_size] != '\n')
+ {
+ problem = &file[file_size];
+ while (problem > file && problem[-1] != ' ' && problem[-1] != '\t'
+ && problem[-1] != '\n')
+ --problem;
+
+ if (problem > file)
+ problem[-1] = '\0';
+ }
+ else
+ problem = NULL;
+
+ if (file != problem)
+ {
+ char *p;
+ runp = file;
+ while ((p = strsep (&runp, ": \t\n")) != NULL)
+ {
+ (void) _dl_map_object (NULL, p, lt_library);
+ ++npreloads;
+ }
+ }
+
+ if (problem != NULL)
+ {
+ char *p = strndupa (problem, file_size - (problem - file));
+ (void) _dl_map_object (NULL, p, lt_library);
+ }
+
+ /* We don't need the file anymore. */
+ __munmap (file, file_size);
+ }
+
if (! __libc_enable_secure)
{
const char *preloadlist = getenv ("LD_PRELOAD");
@@ -313,25 +390,25 @@ of this helper program; chances are you did not intend to run this program.\n",
(void) _dl_map_object (NULL, p, lt_library);
++npreloads;
}
-
- if (npreloads != 0)
- {
- /* Set up PRELOADS with a vector of the preloaded libraries. */
- struct link_map *l;
- unsigned int i;
- preloads = __alloca (npreloads * sizeof preloads[0]);
- l = _dl_rtld_map.l_next; /* End of the chain before preloads. */
- i = 0;
- do
- {
- preloads[i++] = l;
- l = l->l_next;
- } while (l);
- assert (i == npreloads);
- }
}
}
+ if (npreloads != 0)
+ {
+ /* Set up PRELOADS with a vector of the preloaded libraries. */
+ struct link_map *l;
+ unsigned int i;
+ preloads = __alloca (npreloads * sizeof preloads[0]);
+ l = _dl_rtld_map.l_next; /* End of the chain before preloads. */
+ i = 0;
+ do
+ {
+ preloads[i++] = l;
+ l = l->l_next;
+ } while (l);
+ assert (i == npreloads);
+ }
+
/* Load all the libraries specified by DT_NEEDED entries. If LD_PRELOAD
specified some libraries to load, these are inserted before the actual
dependencies in the executable's searchlist for symbol resolution. */
@@ -386,7 +463,7 @@ of this helper program; chances are you did not intend to run this program.\n",
char buf[20], *bp;
buf[sizeof buf - 1] = '\0';
bp = _itoa (l->l_addr, &buf[sizeof buf - 1], 16, 0);
- while (&buf[sizeof buf - 1] - bp < sizeof l->l_addr * 2)
+ while ((size_t) (&buf[sizeof buf - 1] - bp) < sizeof l->l_addr * 2)
*--bp = '0';
_dl_sysdep_message ("\t", l->l_libname, " => ", l->l_name,
" (0x", bp, ")\n", NULL);
@@ -403,12 +480,12 @@ of this helper program; chances are you did not intend to run this program.\n",
char buf[20], *bp;
buf[sizeof buf - 1] = '\0';
bp = _itoa (ref->st_value, &buf[sizeof buf - 1], 16, 0);
- while (&buf[sizeof buf - 1] - bp < sizeof loadbase * 2)
+ while ((size_t) (&buf[sizeof buf - 1] - bp) < sizeof loadbase * 2)
*--bp = '0';
_dl_sysdep_message (_dl_argv[i], " found at 0x", bp, NULL);
buf[sizeof buf - 1] = '\0';
bp = _itoa (loadbase, &buf[sizeof buf - 1], 16, 0);
- while (&buf[sizeof buf - 1] - bp < sizeof loadbase * 2)
+ while ((size_t) (&buf[sizeof buf - 1] - bp) < sizeof loadbase * 2)
*--bp = '0';
_dl_sysdep_message (" in object at 0x", bp, "\n", NULL);
}