* 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.
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
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
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. */
{
/* 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;
/* 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
/* 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
#include <assert.h>
#include <fcntl.h>
-#include <unistd.h>
+#include <link.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
_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;
{
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;
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];
#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;
}
#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
/* 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;
--- /dev/null
+/* 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
--- /dev/null
+/* On Linux we have stat64 available. */
+#define elf_stat stat64
+#define elf_fxstat __fxstat64
+#define elf_xstat __xstat64
+#define elf_ino_t ino64_t