diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-08-15 08:06:15 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-08-15 08:06:15 +0000 |
commit | fc7f617d300f075fe28567391b10b4c5d64be46f (patch) | |
tree | b0a8765937d52ccdb09a796e4e0c322dae9b804b | |
parent | 07a3d63e524f13dd09e14adb0ac2623f6600401d (diff) | |
download | glibc-fc7f617d300f075fe28567391b10b4c5d64be46f.tar.gz |
Update.
* include/link.h: Include sysd-link.h.
* sysdeps/generic/sysd-link.h: New file.
* sysdeps/unix/sysv/linux/sysd-link.h: New file.
* elf/Makefile (distribute): Add sysd-link.h.
* elf/dl-load.c: Use definitions from sysd-link.h instead of stat
types and functions directly.
* elf/dl-misc.c: Likewise.
* elf/dl-profile.c: Likewise.
* elf/loadfail.c (main): Close all successfully loaded objects.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | elf/Makefile | 3 | ||||
-rw-r--r-- | elf/dl-load.c | 12 | ||||
-rw-r--r-- | elf/dl-misc.c | 8 | ||||
-rw-r--r-- | elf/dl-profile.c | 4 | ||||
-rw-r--r-- | elf/loadfail.c | 23 | ||||
-rw-r--r-- | include/link.h | 5 | ||||
-rw-r--r-- | sysdeps/generic/sysd-link.h | 5 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sysd-link.h | 5 |
9 files changed, 56 insertions, 20 deletions
@@ -1,5 +1,16 @@ 2000-08-15 Ulrich Drepper <drepper@redhat.com> + * include/link.h: Include sysd-link.h. + * sysdeps/generic/sysd-link.h: New file. + * sysdeps/unix/sysv/linux/sysd-link.h: New file. + * elf/Makefile (distribute): Add sysd-link.h. + * elf/dl-load.c: Use definitions from sysd-link.h instead of stat + types and functions directly. + * elf/dl-misc.c: Likewise. + * elf/dl-profile.c: Likewise. + + * elf/loadfail.c (main): Close all successfully loaded objects. + * elf/multiload.c: Add mtrace call. Call dlclose for all handles and free wd. * elf/dl-deps.c (_dl_map_object_deps): Don't allocate needed list if diff --git a/elf/Makefile b/elf/Makefile index 3021596428..420db73aee 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -47,7 +47,8 @@ distribute := $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \ vismain.c vismod1.c vismod2.c vismod3.c \ constload2.c constload3.c filtmod1.c filtmod2.c \ nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \ - nodelmod3.c nodelmod4.c nodlopen.c + nodelmod3.c nodelmod4.c nodlopen.c \ + sysd-link.h include ../Makeconfig diff --git a/elf/dl-load.c b/elf/dl-load.c index ebe4c80534..e0c9a61c2f 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -730,10 +730,10 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, int type; char *readbuf; ssize_t readlength; - struct stat st; + struct elf_stat st; /* Get file information. */ - if (__fxstat (_STAT_VER, fd, &st) < 0) + if (elf_fxstat (_STAT_VER, fd, &st) < 0) LOSE (errno, N_("cannot stat shared object")); /* Look again to see if the real name matched another already loaded. */ @@ -1260,11 +1260,11 @@ open_path (const char *name, size_t namelen, int preloaded, { /* We failed to open machine dependent library. Let's test whether there is any directory at all. */ - struct stat st; + struct elf_stat st; buf[buflen - namelen - 1] = '\0'; - if (__xstat (_STAT_VER, buf, &st) != 0 + if (elf_xstat (_STAT_VER, buf, &st) != 0 || ! S_ISDIR (st.st_mode)) /* The directory does not exist or it is no directory. */ this_dir->status[cnt] = nonexisting; @@ -1281,9 +1281,9 @@ open_path (const char *name, size_t namelen, int preloaded, /* This is an extra security effort to make sure nobody can preload broken shared objects which are in the trusted directories and so exploit the bugs. */ - struct stat st; + struct elf_stat st; - if (__fxstat (_STAT_VER, fd, &st) != 0 + if (elf_fxstat (_STAT_VER, fd, &st) != 0 || (st.st_mode & S_ISUID) == 0) { /* The shared object cannot be tested for being SUID diff --git a/elf/dl-misc.c b/elf/dl-misc.c index 63f9266422..5261007822 100644 --- a/elf/dl-misc.c +++ b/elf/dl-misc.c @@ -1,5 +1,5 @@ /* Miscellaneous support functions for dynamic linker - Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000 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 @@ -19,7 +19,7 @@ #include <assert.h> #include <fcntl.h> -#include <unistd.h> +#include <link.h> #include <stdarg.h> #include <string.h> #include <unistd.h> @@ -45,11 +45,11 @@ void * _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot) { void *result; - struct stat st; + struct elf_stat st; int fd = __open (file, O_RDONLY); if (fd < 0) return NULL; - if (__fxstat (_STAT_VER, fd, &st) < 0 + if (elf_fxstat (_STAT_VER, fd, &st) < 0 /* No need to map the file if it is empty. */ || st.st_size == 0) result = NULL; diff --git a/elf/dl-profile.c b/elf/dl-profile.c index 5d69b718e1..9f5ee14f32 100644 --- a/elf/dl-profile.c +++ b/elf/dl-profile.c @@ -175,7 +175,7 @@ _dl_start_profile (struct link_map *map, const char *output_dir) { char *filename; int fd; - struct stat st; + struct elf_stat st; const ElfW(Phdr) *ph; ElfW(Addr) mapstart = ~((ElfW(Addr)) 0); ElfW(Addr) mapend = 0; @@ -267,7 +267,7 @@ _dl_start_profile (struct link_map *map, const char *output_dir) return; } - if (fstat (fd, &st) < 0 || !S_ISREG (st.st_mode)) + if (elf_fxstat (_STAT_VER, fd, &st) < 0 || !S_ISREG (st.st_mode)) { /* Not stat'able or not a regular file => don't use it. */ char buf[400]; diff --git a/elf/loadfail.c b/elf/loadfail.c index 60deb7737b..e423356348 100644 --- a/elf/loadfail.c +++ b/elf/loadfail.c @@ -1,25 +1,36 @@ #include <dlfcn.h> #include <error.h> +#include <mcheck.h> #include <stdio.h> #include <stdlib.h> int main (void) { + void *su[5]; void *h; + int n; - if (dlopen ("testobj1.so", RTLD_GLOBAL | RTLD_NOW) == NULL - || dlopen ("testobj1.so", RTLD_GLOBAL | RTLD_NOW) == NULL - || dlopen ("testobj2.so", RTLD_GLOBAL | RTLD_NOW) == NULL - || dlopen ("testobj3.so", RTLD_GLOBAL | RTLD_NOW) == NULL - || dlopen ("testobj4.so", RTLD_GLOBAL | RTLD_NOW) == NULL - || dlopen ("testobj5.so", RTLD_GLOBAL | RTLD_NOW) == NULL) + mtrace (); + + if ((su[0] = dlopen ("testobj1.so", RTLD_GLOBAL | RTLD_NOW)) == NULL + || (su[1] = dlopen ("testobj2.so", RTLD_GLOBAL | RTLD_NOW)) == NULL + || (su[2] = dlopen ("testobj3.so", RTLD_GLOBAL | RTLD_NOW)) == NULL + || (su[3] = dlopen ("testobj4.so", RTLD_GLOBAL | RTLD_NOW)) == NULL + || (su[4] = dlopen ("testobj5.so", RTLD_GLOBAL | RTLD_NOW)) == NULL) error (EXIT_FAILURE, 0, "failed to load shared object: %s", dlerror ()); h = dlopen ("failobj.so", RTLD_GLOBAL | RTLD_NOW); printf ("h = %p, %s\n", h, h == NULL ? "ok" : "fail"); + for (n = 0; n < 5; ++n) + if (dlclose (su[n]) != 0) + { + printf ("failed to unload su[%d]: %s\n", n, dlerror ()); + exit (EXIT_FAILURE); + } + return h != NULL; } diff --git a/include/link.h b/include/link.h index 375d5d1781..8e69f57e05 100644 --- a/include/link.h +++ b/include/link.h @@ -34,6 +34,9 @@ #include <bits/elfclass.h> /* Defines __ELF_NATIVE_CLASS. */ +/* Get some system specific definitions. */ +#include <sysd-link.h> + /* Rendezvous structure used by the run-time dynamic linker to communicate details of shared object loading to the debugger. If the executable's dynamic section has a DT_DEBUG element, the run-time linker sets that @@ -202,7 +205,7 @@ struct link_map /* This information is kept to check for sure whether a shared object is the same as one already loaded. */ dev_t l_dev; - ino_t l_ino; + elf_ino_t l_ino; /* Collected information about own RUNPATH directories. */ struct r_search_path_elem **l_runpath_dirs; diff --git a/sysdeps/generic/sysd-link.h b/sysdeps/generic/sysd-link.h new file mode 100644 index 0000000000..2faa1a4f51 --- /dev/null +++ b/sysdeps/generic/sysd-link.h @@ -0,0 +1,5 @@ +/* In general we don't have stat64 available. */ +#define elf_stat stat +#define elf_fxstat __fxstat +#define elf_xstat __xstat +#define elf_ino_t ino_t diff --git a/sysdeps/unix/sysv/linux/sysd-link.h b/sysdeps/unix/sysv/linux/sysd-link.h new file mode 100644 index 0000000000..c722d55d1d --- /dev/null +++ b/sysdeps/unix/sysv/linux/sysd-link.h @@ -0,0 +1,5 @@ +/* On Linux we have stat64 available. */ +#define elf_stat stat64 +#define elf_fxstat __fxstat64 +#define elf_xstat __xstat64 +#define elf_ino_t ino64_t |