1 /* Map in a shared object's segments from the file.
2 Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
29 #include <sys/param.h>
31 #include <sys/types.h>
32 #include "dynamic-link.h"
33 #include <stdio-common/_itoa.h>
37 /* On some systems, no flag bits are given to specify file mapping. */
42 /* The right way to map in the shared library files is MAP_COPY, which
43 makes a virtual copy of the data at the time of the mmap call; this
44 guarantees the mapped pages will be consistent even if the file is
45 overwritten. Some losing VM systems like Linux's lack MAP_COPY. All we
46 get is MAP_PRIVATE, which copies each page when it is modified; this
47 means if the file is overwritten, we may at some point get some pages
48 from the new version after starting with pages from the old version. */
50 # define MAP_COPY MAP_PRIVATE
53 /* Some systems link their relocatable objects for another base address
54 than 0. We want to know the base address for these such that we can
55 subtract this address from the segment addresses during mapping.
56 This results in a more efficient address space usage. Defaults to
57 zero for almost all systems. */
59 # define MAP_BASE_ADDR(l) 0
64 #if BYTE_ORDER == BIG_ENDIAN
65 # define byteorder ELFDATA2MSB
66 #elif BYTE_ORDER == LITTLE_ENDIAN
67 # define byteorder ELFDATA2LSB
69 # error "Unknown BYTE_ORDER " BYTE_ORDER
70 # define byteorder ELFDATANONE
73 #define STRING(x) __STRING (x)
76 /* The fd is not examined when using MAP_ANON. */
80 # define ANONFD _dl_zerofd
83 /* Handle situations where we have a preferred location in memory for
84 the shared objects. */
85 #ifdef ELF_PREFERRED_ADDRESS_DATA
86 ELF_PREFERRED_ADDRESS_DATA;
88 #ifndef ELF_PREFERRED_ADDRESS
89 # define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) (mapstartpref)
91 #ifndef ELF_FIXED_ADDRESS
92 # define ELF_FIXED_ADDRESS(loader, mapstart) ((void) 0)
95 /* Type for the buffer we put the ELF header and hopefully the program
96 header. This buffer does not really have to be too large. In most
97 cases the program header follows the ELF header directly. If this
98 is not the case all bets are off and we can make the header arbitrarily
99 large and still won't get it read. This means the only question is
100 how large are the ELF and program header combined. The ELF header
101 in 64-bit files is 56 bytes long. Each program header entry is again
102 56 bytes long. I.e., even with a file which has 17 program header
103 entries we only have to read 1kB. And 17 program header entries is
104 plenty, normal files have < 10. If this heuristic should really fail
105 for some file the code in `_dl_map_object_from_fd' knows how to
117 extern const char *_dl_platform;
118 extern size_t _dl_platformlen;
120 /* This is the decomposed LD_LIBRARY_PATH search path. */
121 static struct r_search_path_struct env_path_list;
123 /* List of the hardware capabilities we might end up using. */
124 static const struct r_strlenpair *capstr;
125 static size_t ncapstr;
126 static size_t max_capstrlen;
128 const unsigned char _dl_pf_to_prot[8] =
133 [PF_R | PF_W] = PROT_READ | PROT_WRITE,
135 [PF_R | PF_X] = PROT_READ | PROT_EXEC,
136 [PF_W | PF_X] = PROT_WRITE | PROT_EXEC,
137 [PF_R | PF_W | PF_X] = PROT_READ | PROT_WRITE | PROT_EXEC
141 /* Get the generated information about the trusted directories. */
142 #include "trusted-dirs.h"
144 static const char system_dirs[] = SYSTEM_DIRS;
145 static const size_t system_dirs_len[] =
149 #define nsystem_dirs_len \
150 (sizeof (system_dirs_len) / sizeof (system_dirs_len[0]))
153 /* Local version of `strdup' function. */
155 local_strdup (const char *s)
157 size_t len = strlen (s) + 1;
158 void *new = malloc (len);
163 return (char *) memcpy (new, s, len);
168 _dl_dst_count (const char *name, int is_path)
170 const char *const start = name;
177 /* $ORIGIN is not expanded for SUID/GUID programs.
179 Note that it is no bug that the strings in the first two `strncmp'
180 calls are longer than the sequence which is actually tested. */
181 if ((((strncmp (&name[1], "ORIGIN}", 6) == 0
182 && (!__libc_enable_secure
183 || ((name[7] == '\0' || (is_path && name[7] == ':'))
184 && (name == start || (is_path && name[-1] == ':'))))
186 || (strncmp (&name[1], "PLATFORM}", 8) == 0 && (len = 9) != 0))
187 && (name[len] == '\0' || name[len] == '/'
188 || (is_path && name[len] == ':')))
190 && ((strncmp (&name[2], "ORIGIN}", 7) == 0
191 && (!__libc_enable_secure
192 || ((name[9] == '\0' || (is_path && name[9] == ':'))
193 && (name == start || (is_path && name[-1] == ':'))))
195 || (strncmp (&name[2], "PLATFORM}", 9) == 0
196 && (len = 11) != 0))))
199 name = strchr (name + len, '$');
201 while (name != NULL);
208 _dl_dst_substitute (struct link_map *l, const char *name, char *result,
211 const char *const start = name;
212 char *last_elem, *wp;
214 /* Now fill the result path. While copying over the string we keep
215 track of the start of the last path element. When we come accross
216 a DST we copy over the value or (if the value is not available)
217 leave the entire path element out. */
218 last_elem = wp = result;
227 /* Note that it is no bug that the strings in the first two `strncmp'
228 calls are longer than the sequence which is actually tested. */
229 if ((((strncmp (&name[1], "ORIGIN}", 6) == 0 && (len = 7) != 0)
230 || (strncmp (&name[1], "PLATFORM}", 8) == 0 && (len = 9) != 0))
231 && (name[len] == '\0' || name[len] == '/'
232 || (is_path && name[len] == ':')))
234 && ((strncmp (&name[2], "ORIGIN}", 7) == 0 && (len = 9) != 0)
235 || (strncmp (&name[2], "PLATFORM}", 9) == 0
236 && (len = 11) != 0))))
238 repl = ((len == 7 || name[2] == 'O')
239 ? (__libc_enable_secure
240 && ((name[len] != '\0'
241 && (!is_path || name[len] != ':'))
243 && (!is_path || name[-1] != ':')))
244 ? NULL : l->l_origin)
247 if (repl != NULL && repl != (const char *) -1)
249 wp = __stpcpy (wp, repl);
254 /* We cannot use this path element, the value of the
255 replacement is unknown. */
258 while (*name != '\0' && (!is_path || *name != ':'))
263 /* No DST we recognize. */
266 else if (is_path && *name == ':')
274 while (*name != '\0');
282 /* Return copy of argument with all recognized dynamic string tokens
283 ($ORIGIN and $PLATFORM for now) replaced. On some platforms it
284 might not be possible to determine the path from which the object
285 belonging to the map is loaded. In this case the path element
286 containing $ORIGIN is left out. */
288 expand_dynamic_string_token (struct link_map *l, const char *s)
290 /* We make two runs over the string. First we determine how large the
291 resulting string is and then we copy it over. Since this is now
292 frequently executed operation we are looking here not for performance
293 but rather for code size. */
298 /* Determine the number of DST elements. */
299 cnt = DL_DST_COUNT (s, 1);
301 /* If we do not have to replace anything simply copy the string. */
303 return local_strdup (s);
305 /* Determine the length of the substituted string. */
306 total = DL_DST_REQUIRED (l, s, strlen (s), cnt);
308 /* Allocate the necessary memory. */
309 result = (char *) malloc (total + 1);
313 return DL_DST_SUBSTITUTE (l, s, result, 1);
317 /* Add `name' to the list of names for a particular shared object.
318 `name' is expected to have been allocated with malloc and will
319 be freed if the shared object already has this name.
320 Returns false if the object already had this name. */
323 add_name_to_object (struct link_map *l, const char *name)
325 struct libname_list *lnp, *lastp;
326 struct libname_list *newname;
330 for (lnp = l->l_libname; lnp != NULL; lastp = lnp, lnp = lnp->next)
331 if (strcmp (name, lnp->name) == 0)
334 name_len = strlen (name) + 1;
335 newname = (struct libname_list *) malloc (sizeof *newname + name_len);
338 /* No more memory. */
339 _dl_signal_error (ENOMEM, name, N_("cannot allocate name record"));
342 /* The object should have a libname set from _dl_new_object. */
343 assert (lastp != NULL);
345 newname->name = memcpy (newname + 1, name, name_len);
346 newname->next = NULL;
347 newname->dont_free = 0;
348 lastp->next = newname;
351 /* All known directories in sorted order. */
352 struct r_search_path_elem *_dl_all_dirs;
354 /* All directories after startup. */
355 struct r_search_path_elem *_dl_init_all_dirs;
357 /* Standard search directories. */
358 static struct r_search_path_struct rtld_search_dirs;
360 static size_t max_dirnamelen;
362 static inline struct r_search_path_elem **
363 fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
364 int check_trusted, const char *what, const char *where)
369 while ((cp = __strsep (&rpath, sep)) != NULL)
371 struct r_search_path_elem *dirp;
372 size_t len = strlen (cp);
374 /* `strsep' can pass an empty string. This has to be
375 interpreted as `use the current directory'. */
378 static const char curwd[] = "./";
382 /* Remove trailing slashes (except for "/"). */
383 while (len > 1 && cp[len - 1] == '/')
386 /* Now add one if there is none so far. */
387 if (len > 0 && cp[len - 1] != '/')
390 /* See if this directory is already known. */
391 for (dirp = _dl_all_dirs; dirp != NULL; dirp = dirp->next)
392 if (dirp->dirnamelen == len && memcmp (cp, dirp->dirname, len) == 0)
397 /* It is available, see whether it's on our own list. */
399 for (cnt = 0; cnt < nelems; ++cnt)
400 if (result[cnt] == dirp)
404 result[nelems++] = dirp;
409 enum r_dir_status init_val;
410 size_t where_len = where ? strlen (where) + 1 : 0;
412 /* It's a new directory. Create an entry and add it. */
413 dirp = (struct r_search_path_elem *)
414 malloc (sizeof (*dirp) + ncapstr * sizeof (enum r_dir_status)
415 + where_len + len + 1);
417 _dl_signal_error (ENOMEM, NULL,
418 N_("cannot create cache for search path"));
420 dirp->dirname = ((char *) dirp + sizeof (*dirp)
421 + ncapstr * sizeof (enum r_dir_status));
422 *((char *) __mempcpy ((char *) dirp->dirname, cp, len)) = '\0';
423 dirp->dirnamelen = len;
425 if (len > max_dirnamelen)
426 max_dirnamelen = len;
428 /* Make sure we don't use untrusted directories if we run SUID. */
429 if (__builtin_expect (check_trusted, 0))
431 const char *trun = system_dirs;
434 /* By default we don't trust anything. */
435 init_val = nonexisting;
437 /* All trusted directories must be complete names. */
440 for (idx = 0; idx < nsystem_dirs_len; ++idx)
442 if (len == system_dirs_len[idx]
443 && memcmp (trun, cp, len) == 0)
447 trun += system_dirs_len[idx] + 1;
450 if (idx < nsystem_dirs_len)
451 /* It's a trusted directory so allow checking for it. */
456 /* We don't have to check for trusted directories and can
457 accept everything. We have to make sure all the
458 relative directories are never ignored. The current
459 directory might change and all our saved information
461 init_val = cp[0] != '/' ? existing : unknown;
463 for (cnt = 0; cnt < ncapstr; ++cnt)
464 dirp->status[cnt] = init_val;
467 if (__builtin_expect (where != NULL, 1))
468 dirp->where = memcpy ((char *) dirp + sizeof (*dirp) + len + 1
469 + ncapstr * sizeof (enum r_dir_status),
474 dirp->next = _dl_all_dirs;
477 /* Put it in the result array. */
478 result[nelems++] = dirp;
482 /* Terminate the array. */
483 result[nelems] = NULL;
491 decompose_rpath (struct r_search_path_struct *sps,
492 const char *rpath, struct link_map *l, const char *what)
494 /* Make a copy we can work with. */
495 const char *where = l->l_name;
498 struct r_search_path_elem **result;
501 /* First see whether we must forget the RUNPATH and RPATH from this
503 if (__builtin_expect (_dl_inhibit_rpath != NULL, 0) && !__libc_enable_secure)
505 const char *found = strstr (_dl_inhibit_rpath, where);
508 size_t len = strlen (where);
509 if ((found == _dl_inhibit_rpath || found[-1] == ':')
510 && (found[len] == '\0' || found[len] == ':'))
512 /* This object is on the list of objects for which the
513 RUNPATH and RPATH must not be used. */
514 result = (struct r_search_path_elem **)
515 malloc (sizeof (*result));
517 _dl_signal_error (ENOMEM, NULL,
518 N_("cannot create cache for search path"));
529 /* Make a writable copy. At the same time expand possible dynamic
531 copy = expand_dynamic_string_token (l, rpath);
533 _dl_signal_error (ENOMEM, NULL, N_("cannot create RUNPATH/RPATH copy"));
535 /* Count the number of necessary elements in the result array. */
537 for (cp = copy; *cp != '\0'; ++cp)
541 /* Allocate room for the result. NELEMS + 1 is an upper limit for the
542 number of necessary entries. */
543 result = (struct r_search_path_elem **) malloc ((nelems + 1 + 1)
546 _dl_signal_error (ENOMEM, NULL, N_("cannot create cache for search path"));
548 fillin_rpath (copy, result, ":", 0, what, where);
550 /* Free the copied RPATH string. `fillin_rpath' make own copies if
555 /* The caller will change this value if we haven't used a real malloc. */
562 _dl_init_paths (const char *llp)
566 struct r_search_path_elem *pelem, **aelem;
572 /* Fill in the information about the application's RPATH and the
573 directories addressed by the LD_LIBRARY_PATH environment variable. */
575 /* Get the capabilities. */
576 capstr = _dl_important_hwcaps (_dl_platform, _dl_platformlen,
577 &ncapstr, &max_capstrlen);
579 /* First set up the rest of the default search directory entries. */
580 aelem = rtld_search_dirs.dirs = (struct r_search_path_elem **)
581 malloc ((nsystem_dirs_len + 1) * sizeof (struct r_search_path_elem *));
582 if (rtld_search_dirs.dirs == NULL)
583 _dl_signal_error (ENOMEM, NULL, N_("cannot create search path array"));
585 round_size = ((2 * sizeof (struct r_search_path_elem) - 1
586 + ncapstr * sizeof (enum r_dir_status))
587 / sizeof (struct r_search_path_elem));
589 rtld_search_dirs.dirs[0] = (struct r_search_path_elem *)
590 malloc ((sizeof (system_dirs) / sizeof (system_dirs[0]))
591 * round_size * sizeof (struct r_search_path_elem));
592 if (rtld_search_dirs.dirs[0] == NULL)
593 _dl_signal_error (ENOMEM, NULL, N_("cannot create cache for search path"));
595 rtld_search_dirs.malloced = 0;
596 pelem = _dl_all_dirs = rtld_search_dirs.dirs[0];
606 pelem->what = "system search path";
609 pelem->dirname = strp;
610 pelem->dirnamelen = system_dirs_len[idx];
611 strp += system_dirs_len[idx] + 1;
613 /* System paths must be absolute. */
614 assert (pelem->dirname[0] == '/');
615 for (cnt = 0; cnt < ncapstr; ++cnt)
616 pelem->status[cnt] = unknown;
618 pelem->next = (++idx == nsystem_dirs_len ? NULL : (pelem + round_size));
622 while (idx < nsystem_dirs_len);
624 max_dirnamelen = SYSTEM_DIRS_MAX_LEN;
628 /* This points to the map of the main object. */
632 assert (l->l_type != lt_loaded);
634 if (l->l_info[DT_RUNPATH])
636 /* Allocate room for the search path and fill in information
638 decompose_rpath (&l->l_runpath_dirs,
639 (const void *) (D_PTR (l, l_info[DT_STRTAB])
640 + l->l_info[DT_RUNPATH]->d_un.d_val),
643 /* The RPATH is ignored. */
644 l->l_rpath_dirs.dirs = (void *) -1;
648 l->l_runpath_dirs.dirs = (void *) -1;
650 if (l->l_info[DT_RPATH])
652 /* Allocate room for the search path and fill in information
654 decompose_rpath (&l->l_rpath_dirs,
655 (const void *) (D_PTR (l, l_info[DT_STRTAB])
656 + l->l_info[DT_RPATH]->d_un.d_val),
658 l->l_rpath_dirs.malloced = 0;
661 l->l_rpath_dirs.dirs = (void *) -1;
666 if (llp != NULL && *llp != '\0')
669 const char *cp = llp;
671 /* Decompose the LD_LIBRARY_PATH contents. First determine how many
676 if (*cp == ':' || *cp == ';')
681 env_path_list.dirs = (struct r_search_path_elem **)
682 malloc ((nllp + 1) * sizeof (struct r_search_path_elem *));
683 if (env_path_list.dirs == NULL)
684 _dl_signal_error (ENOMEM, NULL,
685 N_("cannot create cache for search path"));
687 (void) fillin_rpath (strdupa (llp), env_path_list.dirs, ":;",
688 __libc_enable_secure, "LD_LIBRARY_PATH", NULL);
690 if (env_path_list.dirs[0] == NULL)
692 free (env_path_list.dirs);
693 env_path_list.dirs = (void *) -1;
696 env_path_list.malloced = 0;
699 env_path_list.dirs = (void *) -1;
701 /* Remember the last search directory added at startup. */
702 _dl_init_all_dirs = _dl_all_dirs;
706 /* Think twice before changing anything in this function. It is placed
707 here and prepared using the `alloca' magic to prevent it from being
708 inlined. The function is only called in case of an error. But then
709 performance does not count. The function used to be "inlinable" and
710 the compiled did so all the time. This increased the code size for
711 absolutely no good reason. */
712 #define LOSE(code, s) lose (code, fd, name, realname, l, s)
714 __attribute__ ((noreturn))
715 lose (int code, int fd, const char *name, char *realname, struct link_map *l,
718 /* The use of `alloca' here looks ridiculous but it helps. The goal
719 is to avoid the function from being inlined. There is no official
720 way to do this so we use this trick. gcc never inlines functions
721 which use `alloca'. */
722 int *a = alloca (sizeof (int));
724 (void) __close (a[0]);
727 /* Remove the stillborn object from the list and free it. */
729 l->l_prev->l_next = l->l_next;
731 l->l_next->l_prev = l->l_prev;
736 _dl_signal_error (code, name, msg);
740 /* Map in the shared object NAME, actually located in REALNAME, and already
743 #ifndef EXTERNAL_MAP_FROM_FD
747 _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
748 char *realname, struct link_map *loader, int l_type,
751 struct link_map *l = NULL;
753 auto inline caddr_t map_segment (ElfW(Addr) mapstart, size_t len,
754 int prot, int fixed, off_t offset);
756 inline caddr_t map_segment (ElfW(Addr) mapstart, size_t len,
757 int prot, int fixed, off_t offset)
759 caddr_t mapat = __mmap ((caddr_t) mapstart, len, prot,
760 fixed|MAP_COPY|MAP_FILE,
762 if (mapat == MAP_FAILED)
763 LOSE (errno, N_("failed to map segment from shared object"));
767 const ElfW(Ehdr) *header;
768 const ElfW(Phdr) *phdr;
769 const ElfW(Phdr) *ph;
774 /* Get file information. */
775 if (__fxstat64 (_STAT_VER, fd, &st) < 0)
776 LOSE (errno, N_("cannot stat shared object"));
778 /* Look again to see if the real name matched another already loaded. */
779 for (l = _dl_loaded; l; l = l->l_next)
780 if (l->l_ino == st.st_ino && l->l_dev == st.st_dev)
782 /* The object is already loaded.
783 Just bump its reference count and return it. */
786 /* If the name is not in the list of names for this object add
789 add_name_to_object (l, name);
794 if (mode & RTLD_NOLOAD)
795 /* We are not supposed to load the object unless it is already
796 loaded. So return now. */
799 /* Print debugging message. */
800 if (__builtin_expect (_dl_debug_files, 0))
801 _dl_debug_message (1, "file=", name, "; generating link map\n", NULL);
803 /* This is the ELF header. We read it in `open_verify'. */
804 header = (void *) fbp->buf;
808 if (_dl_zerofd == -1)
810 _dl_zerofd = _dl_sysdep_open_zero_fill ();
811 if (_dl_zerofd == -1)
814 _dl_signal_error (errno, NULL, N_("cannot open zero fill device"));
819 /* Enter the new object in the list of loaded objects. */
820 l = _dl_new_object (realname, name, l_type, loader);
821 if (__builtin_expect (! l, 0))
822 LOSE (ENOMEM, N_("cannot create shared object descriptor"));
824 /* Extract the remaining details we need from the ELF header
825 and then read in the program header table. */
826 l->l_entry = header->e_entry;
827 type = header->e_type;
828 l->l_phnum = header->e_phnum;
830 maplength = header->e_phnum * sizeof (ElfW(Phdr));
831 if (header->e_phoff + maplength <= fbp->len)
832 phdr = (void *) (fbp->buf + header->e_phoff);
835 phdr = alloca (maplength);
836 __lseek (fd, SEEK_SET, header->e_phoff);
837 if (__libc_read (fd, (void *) phdr, maplength) != maplength)
838 LOSE (errno, N_("cannot read file data"));
842 /* Scan the program header table, collecting its load commands. */
845 ElfW(Addr) mapstart, mapend, dataend, allocend;
848 } loadcmds[l->l_phnum], *c;
849 size_t nloadcmds = 0;
851 /* The struct is initialized to zero so this is not necessary:
855 for (ph = phdr; ph < &phdr[l->l_phnum]; ++ph)
858 /* These entries tell us where to find things once the file's
859 segments are mapped in. We record the addresses it says
860 verbatim, and later correct for the run-time load address. */
862 l->l_ld = (void *) ph->p_vaddr;
863 l->l_ldnum = ph->p_memsz / sizeof (ElfW(Dyn));
866 l->l_phdr = (void *) ph->p_vaddr;
870 /* A load command tells us to map in part of the file.
871 We record the load commands and process them all later. */
872 if (ph->p_align % _dl_pagesize != 0)
873 LOSE (0, N_("ELF load command alignment not page-aligned"));
874 if ((ph->p_vaddr - ph->p_offset) % ph->p_align)
876 N_("ELF load command address/offset not properly aligned"));
878 struct loadcmd *c = &loadcmds[nloadcmds++];
879 c->mapstart = ph->p_vaddr & ~(ph->p_align - 1);
880 c->mapend = ((ph->p_vaddr + ph->p_filesz + _dl_pagesize - 1)
881 & ~(_dl_pagesize - 1));
882 c->dataend = ph->p_vaddr + ph->p_filesz;
883 c->allocend = ph->p_vaddr + ph->p_memsz;
884 c->mapoff = ph->p_offset & ~(ph->p_align - 1);
886 /* Optimize a common case. */
887 if ((PF_R | PF_W | PF_X) == 7
888 && (PROT_READ | PROT_WRITE | PROT_EXEC) == 7)
889 c->prot = _dl_pf_to_prot[ph->p_flags & (PF_R | PF_W | PF_X)];
893 if (ph->p_flags & PF_R)
894 c->prot |= PROT_READ;
895 if (ph->p_flags & PF_W)
896 c->prot |= PROT_WRITE;
897 if (ph->p_flags & PF_X)
898 c->prot |= PROT_EXEC;
904 /* Now process the load commands and map segments into memory. */
907 /* Length of the sections to be loaded. */
908 maplength = loadcmds[nloadcmds - 1].allocend - c->mapstart;
910 if (__builtin_expect (type, ET_DYN) == ET_DYN)
912 /* This is a position-independent shared object. We can let the
913 kernel map it anywhere it likes, but we must have space for all
914 the segments in their specified positions relative to the first.
915 So we map the first segment without MAP_FIXED, but with its
916 extent increased to cover all the segments. Then we remove
917 access from excess portion, and there is known sufficient space
918 there to remap from the later segments.
920 As a refinement, sometimes we have an address that we would
921 prefer to map such objects at; but this is only a preference,
922 the OS can do whatever it likes. */
924 mappref = (ELF_PREFERRED_ADDRESS (loader, maplength, c->mapstart)
925 - MAP_BASE_ADDR (l));
927 /* Remember which part of the address space this object uses. */
928 l->l_map_start = (ElfW(Addr)) map_segment (mappref, maplength, c->prot,
930 l->l_map_end = l->l_map_start + maplength;
931 l->l_addr = l->l_map_start - c->mapstart;
933 /* Change protection on the excess portion to disallow all access;
934 the portions we do not remap later will be inaccessible as if
935 unallocated. Then jump into the normal segment-mapping loop to
936 handle the portion of the segment past the end of the file
938 __mprotect ((caddr_t) (l->l_addr + c->mapend),
939 loadcmds[nloadcmds - 1].allocend - c->mapend,
946 /* This object is loaded at a fixed address. This must never
947 happen for objects loaded with dlopen(). */
948 if (mode & __RTLD_DLOPEN)
950 LOSE (0, N_("cannot dynamically load executable"));
953 /* Notify ELF_PREFERRED_ADDRESS that we have to load this one
955 ELF_FIXED_ADDRESS (loader, c->mapstart);
958 /* Remember which part of the address space this object uses. */
959 l->l_map_start = c->mapstart + l->l_addr;
960 l->l_map_end = l->l_map_start + maplength;
962 while (c < &loadcmds[nloadcmds])
964 if (c->mapend > c->mapstart)
965 /* Map the segment contents from the file. */
966 map_segment (l->l_addr + c->mapstart, c->mapend - c->mapstart,
967 c->prot, MAP_FIXED, c->mapoff);
971 && c->mapoff <= header->e_phoff
972 && (c->mapend - c->mapstart + c->mapoff
973 >= header->e_phoff + header->e_phnum * sizeof (ElfW(Phdr))))
974 /* Found the program header in this segment. */
975 l->l_phdr = (void *) (c->mapstart + header->e_phoff - c->mapoff);
977 if (c->allocend > c->dataend)
979 /* Extra zero pages should appear at the end of this segment,
980 after the data mapped from the file. */
981 ElfW(Addr) zero, zeroend, zeropage;
983 zero = l->l_addr + c->dataend;
984 zeroend = l->l_addr + c->allocend;
985 zeropage = (zero + _dl_pagesize - 1) & ~(_dl_pagesize - 1);
987 if (zeroend < zeropage)
988 /* All the extra data is in the last page of the segment.
989 We can just zero it. */
994 /* Zero the final part of the last page of the segment. */
995 if ((c->prot & PROT_WRITE) == 0)
998 if (__mprotect ((caddr_t) (zero & ~(_dl_pagesize - 1)),
999 _dl_pagesize, c->prot|PROT_WRITE) < 0)
1000 LOSE (errno, N_("cannot change memory protections"));
1002 memset ((void *) zero, 0, zeropage - zero);
1003 if ((c->prot & PROT_WRITE) == 0)
1004 __mprotect ((caddr_t) (zero & ~(_dl_pagesize - 1)),
1005 _dl_pagesize, c->prot);
1008 if (zeroend > zeropage)
1010 /* Map the remaining zero pages in from the zero fill FD. */
1012 mapat = __mmap ((caddr_t) zeropage, zeroend - zeropage,
1013 c->prot, MAP_ANON|MAP_PRIVATE|MAP_FIXED,
1015 if (mapat == MAP_FAILED)
1016 LOSE (errno, N_("cannot map zero-fill pages"));
1023 if (l->l_phdr == NULL)
1025 /* The program header is not contained in any of the segmenst.
1026 We have to allocate memory ourself and copy it over from
1027 out temporary place. */
1028 ElfW(Phdr) *newp = (ElfW(Phdr) *) malloc (header->e_phnum
1029 * sizeof (ElfW(Phdr)));
1031 LOSE (ENOMEM, N_("cannot allocate memory for program header"));
1033 l->l_phdr = memcpy (newp, phdr,
1034 (header->e_phnum * sizeof (ElfW(Phdr))));
1035 l->l_phdr_allocated = 1;
1038 /* Adjust the PT_PHDR value by the runtime load address. */
1039 (ElfW(Addr)) l->l_phdr += l->l_addr;
1042 /* We are done mapping in the file. We no longer need the descriptor. */
1045 if (l->l_type == lt_library && type == ET_EXEC)
1046 l->l_type = lt_executable;
1051 LOSE (0, N_("object file has no dynamic section"));
1054 (ElfW(Addr)) l->l_ld += l->l_addr;
1056 l->l_entry += l->l_addr;
1058 if (__builtin_expect (_dl_debug_files, 0))
1060 const size_t nibbles = sizeof (void *) * 2;
1061 char buf1[nibbles + 1];
1062 char buf2[nibbles + 1];
1063 char buf3[nibbles + 1];
1065 buf1[nibbles] = '\0';
1066 buf2[nibbles] = '\0';
1067 buf3[nibbles] = '\0';
1069 memset (buf1, '0', nibbles);
1070 memset (buf2, '0', nibbles);
1071 memset (buf3, '0', nibbles);
1072 _itoa_word ((unsigned long int) l->l_ld, &buf1[nibbles], 16, 0);
1073 _itoa_word ((unsigned long int) l->l_addr, &buf2[nibbles], 16, 0);
1074 _itoa_word (maplength, &buf3[nibbles], 16, 0);
1076 _dl_debug_message (1, " dynamic: 0x", buf1, " base: 0x", buf2,
1077 " size: 0x", buf3, "\n", NULL);
1078 memset (buf1, '0', nibbles);
1079 memset (buf2, '0', nibbles);
1080 memset (buf3, ' ', nibbles);
1081 _itoa_word ((unsigned long int) l->l_entry, &buf1[nibbles], 16, 0);
1082 _itoa_word ((unsigned long int) l->l_phdr, &buf2[nibbles], 16, 0);
1083 _itoa_word (l->l_phnum, &buf3[nibbles], 10, 0);
1084 _dl_debug_message (1, " entry: 0x", buf1, " phdr: 0x", buf2,
1085 " phnum: ", buf3, "\n\n", NULL);
1088 elf_get_dynamic_info (l);
1090 /* Make sure we are dlopen()ing an object which has the DF_1_NOOPEN
1092 if (__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0)
1093 && (mode & __RTLD_DLOPEN))
1095 /* Remove from the module list. */
1096 assert (l->l_next == NULL);
1098 if (l->l_prev == NULL)
1099 /* No other module loaded. */
1103 l->l_prev->l_next = NULL;
1106 /* We are not supposed to load this object. Free all resources. */
1107 __munmap ((void *) l->l_map_start, l->l_map_end - l->l_map_start);
1109 free (l->l_libname);
1111 if (l->l_phdr_allocated)
1112 free ((void *) l->l_phdr);
1116 _dl_signal_error (0, name, N_("shared object cannot be dlopen()ed"));
1119 if (l->l_info[DT_HASH])
1122 /* If this object has DT_SYMBOLIC set modify now its scope. We don't
1123 have to do this for the main map. */
1124 if (__builtin_expect (l->l_info[DT_SYMBOLIC] != NULL, 0)
1125 && &l->l_searchlist != l->l_scope[0])
1127 /* Create an appropriate searchlist. It contains only this map.
1129 XXX This is the definition of DT_SYMBOLIC in SysVr4. The old
1130 GNU ld.so implementation had a different interpretation which
1131 is more reasonable. We are prepared to add this possibility
1132 back as part of a GNU extension of the ELF format. */
1133 l->l_symbolic_searchlist.r_list =
1134 (struct link_map **) malloc (sizeof (struct link_map *));
1136 if (l->l_symbolic_searchlist.r_list == NULL)
1137 LOSE (ENOMEM, N_("cannot create searchlist"));
1139 l->l_symbolic_searchlist.r_list[0] = l;
1140 l->l_symbolic_searchlist.r_nlist = 1;
1141 l->l_symbolic_searchlist.r_duplist = l->l_symbolic_searchlist.r_list;
1142 l->l_symbolic_searchlist.r_nduplist = 1;
1144 /* Now move the existing entries one back. */
1145 memmove (&l->l_scope[1], &l->l_scope[0],
1146 sizeof (l->l_scope) - sizeof (l->l_scope[0]));
1148 /* Now add the new entry. */
1149 l->l_scope[0] = &l->l_symbolic_searchlist;
1152 /* Finally the file information. */
1153 l->l_dev = st.st_dev;
1154 l->l_ino = st.st_ino;
1159 /* Print search path. */
1161 print_search_path (struct r_search_path_elem **list,
1162 const char *what, const char *name)
1164 char buf[max_dirnamelen + max_capstrlen];
1167 _dl_debug_message (1, " search path=", NULL);
1169 while (*list != NULL && (*list)->what == what) /* Yes, ==. */
1171 char *endp = __mempcpy (buf, (*list)->dirname, (*list)->dirnamelen);
1174 for (cnt = 0; cnt < ncapstr; ++cnt)
1175 if ((*list)->status[cnt] != nonexisting)
1177 char *cp = __mempcpy (endp, capstr[cnt].str, capstr[cnt].len);
1178 if (cp == buf || (cp == buf + 1 && buf[0] == '/'))
1182 _dl_debug_message (0, first ? "" : ":", buf, NULL);
1190 _dl_debug_message (0, "\t\t(", what, " from file ",
1191 name[0] ? name : _dl_argv[0], ")\n", NULL);
1193 _dl_debug_message (0, "\t\t(", what, ")\n", NULL);
1196 /* Open a file and verify it is an ELF file for this architecture. We
1197 ignore only ELF files for other architectures. Non-ELF files and
1198 ELF files with different header information cause fatal errors since
1199 this could mean there is something wrong in the installation and the
1200 user might want to know about this. */
1202 open_verify (const char *name, struct filebuf *fbp)
1204 /* This is the expected ELF header. */
1205 #define ELF32_CLASS ELFCLASS32
1206 #define ELF64_CLASS ELFCLASS64
1207 #ifndef VALID_ELF_HEADER
1208 # define VALID_ELF_HEADER(hdr,exp,size) (memcmp (hdr, exp, size) == 0)
1209 # define VALID_ELF_OSABI(osabi) (osabi == ELFOSABI_SYSV)
1210 # define VALID_ELF_ABIVERSION(ver) (ver == 0)
1212 static const unsigned char expected[EI_PAD] =
1214 [EI_MAG0] = ELFMAG0,
1215 [EI_MAG1] = ELFMAG1,
1216 [EI_MAG2] = ELFMAG2,
1217 [EI_MAG3] = ELFMAG3,
1218 [EI_CLASS] = ELFW(CLASS),
1219 [EI_DATA] = byteorder,
1220 [EI_VERSION] = EV_CURRENT,
1221 [EI_OSABI] = ELFOSABI_SYSV,
1226 /* Open the file. We always open files read-only. */
1227 fd = __open (name, O_RDONLY);
1232 /* We successfully openened the file. Now verify it is a file
1235 fbp->len = __libc_read (fd, fbp->buf, sizeof (fbp->buf));
1237 /* This is where the ELF header is loaded. */
1238 assert (sizeof (fbp->buf) > sizeof (ElfW(Ehdr)));
1239 ehdr = (ElfW(Ehdr) *) fbp->buf;
1241 /* Now run the tests. */
1242 if (__builtin_expect (fbp->len < (ssize_t) sizeof (ElfW(Ehdr)), 0))
1243 lose (errno, fd, name, NULL, NULL,
1244 errno == 0 ? N_("file too short") : N_("cannot read file data"));
1246 /* See whether the ELF header is what we expect. */
1247 if (__builtin_expect (! VALID_ELF_HEADER (ehdr->e_ident, expected,
1250 /* Something is wrong. */
1251 if (*(Elf32_Word *) &ehdr->e_ident !=
1252 #if BYTE_ORDER == LITTLE_ENDIAN
1253 ((ELFMAG0 << (EI_MAG0 * 8)) |
1254 (ELFMAG1 << (EI_MAG1 * 8)) |
1255 (ELFMAG2 << (EI_MAG2 * 8)) |
1256 (ELFMAG3 << (EI_MAG3 * 8)))
1258 ((ELFMAG0 << (EI_MAG3 * 8)) |
1259 (ELFMAG1 << (EI_MAG2 * 8)) |
1260 (ELFMAG2 << (EI_MAG1 * 8)) |
1261 (ELFMAG3 << (EI_MAG0 * 8)))
1264 lose (0, fd, name, NULL, NULL, N_("invalid ELF header"));
1266 if (ehdr->e_ident[EI_CLASS] != ELFW(CLASS))
1267 /* This is not a fatal error. On architectures where
1268 32-bit and 64-bit binaries can be run this might
1272 if (ehdr->e_ident[EI_DATA] != byteorder)
1274 if (BYTE_ORDER == BIG_ENDIAN)
1275 lose (0, fd, name, NULL, NULL,
1276 "ELF file data encoding not big-endian");
1278 lose (0, fd, name, NULL, NULL,
1279 "ELF file data encoding not little-endian");
1281 if (ehdr->e_ident[EI_VERSION] != EV_CURRENT)
1282 lose (0, fd, name, NULL, NULL,
1283 N_("ELF file version ident does not match current one"));
1284 /* XXX We should be able so set system specific versions which are
1286 if (!VALID_ELF_OSABI (ehdr->e_ident[EI_OSABI]))
1287 lose (0, fd, name, NULL, NULL, N_("ELF file OS ABI invalid"));
1288 if (!VALID_ELF_ABIVERSION (ehdr->e_ident[EI_ABIVERSION]))
1289 lose (0, fd, name, NULL, NULL,
1290 N_("ELF file ABI version invalid"));
1291 lose (0, fd, name, NULL, NULL, N_("internal error"));
1294 if (__builtin_expect (ehdr->e_version, EV_CURRENT) != EV_CURRENT)
1295 lose (0, fd, name, NULL, NULL,
1296 N_("ELF file version does not match current one"));
1297 if (! __builtin_expect (elf_machine_matches_host (ehdr), 1))
1301 __set_errno (ENOENT);
1304 else if (__builtin_expect (ehdr->e_phentsize, sizeof (ElfW(Phdr)))
1305 != sizeof (ElfW(Phdr)))
1306 lose (0, fd, name, NULL, NULL,
1307 N_("ELF file's phentsize not the expected size"));
1308 else if (__builtin_expect (ehdr->e_type, ET_DYN) != ET_DYN
1309 && __builtin_expect (ehdr->e_type, ET_EXEC) != ET_EXEC)
1310 lose (0, fd, name, NULL, NULL,
1311 N_("only ET_DYN and ET_EXEC can be loaded"));
1317 /* Try to open NAME in one of the directories in *DIRSP.
1318 Return the fd, or -1. If successful, fill in *REALNAME
1319 with the malloc'd full directory name. If it turns out
1320 that none of the directories in *DIRSP exists, *DIRSP is
1321 replaced with (void *) -1, and the old value is free()d
1322 if MAY_FREE_DIRS is true. */
1325 open_path (const char *name, size_t namelen, int preloaded,
1326 struct r_search_path_struct *sps, char **realname,
1327 struct filebuf *fbp)
1329 struct r_search_path_elem **dirs = sps->dirs;
1332 const char *current_what = NULL;
1335 buf = alloca (max_dirnamelen + max_capstrlen + namelen);
1338 struct r_search_path_elem *this_dir = *dirs;
1344 /* If we are debugging the search for libraries print the path
1345 now if it hasn't happened now. */
1346 if (__builtin_expect (_dl_debug_libs, 0)
1347 && current_what != this_dir->what)
1349 current_what = this_dir->what;
1350 print_search_path (dirs, current_what, this_dir->where);
1353 edp = (char *) __mempcpy (buf, this_dir->dirname, this_dir->dirnamelen);
1354 for (cnt = 0; fd == -1 && cnt < ncapstr; ++cnt)
1356 /* Skip this directory if we know it does not exist. */
1357 if (this_dir->status[cnt] == nonexisting)
1361 ((char *) __mempcpy (__mempcpy (edp,
1362 capstr[cnt].str, capstr[cnt].len),
1366 /* Print name we try if this is wanted. */
1367 if (__builtin_expect (_dl_debug_libs, 0))
1368 _dl_debug_message (1, " trying file=", buf, "\n", NULL);
1370 fd = open_verify (buf, fbp);
1371 if (this_dir->status[cnt] == unknown)
1374 this_dir->status[cnt] = existing;
1377 /* We failed to open machine dependent library. Let's
1378 test whether there is any directory at all. */
1381 buf[buflen - namelen - 1] = '\0';
1383 if (__xstat64 (_STAT_VER, buf, &st) != 0
1384 || ! S_ISDIR (st.st_mode))
1385 /* The directory does not exist or it is no directory. */
1386 this_dir->status[cnt] = nonexisting;
1388 this_dir->status[cnt] = existing;
1392 /* Remember whether we found any existing directory. */
1393 here_any |= this_dir->status[cnt] == existing;
1395 if (fd != -1 && preloaded && __libc_enable_secure)
1397 /* This is an extra security effort to make sure nobody can
1398 preload broken shared objects which are in the trusted
1399 directories and so exploit the bugs. */
1402 if (__fxstat64 (_STAT_VER, fd, &st) != 0
1403 || (st.st_mode & S_ISUID) == 0)
1405 /* The shared object cannot be tested for being SUID
1406 or this bit is not set. In this case we must not
1410 /* We simply ignore the file, signal this by setting
1411 the error value which would have been set by `open'. */
1419 *realname = malloc (buflen);
1420 if (*realname != NULL)
1422 memcpy (*realname, buf, buflen);
1427 /* No memory for the name, we certainly won't be able
1428 to load and link it. */
1433 if (here_any && errno != ENOENT && errno != EACCES)
1434 /* The file exists and is readable, but something went wrong. */
1437 /* Remember whether we found anything. */
1440 while (*++dirs != NULL);
1442 /* Remove the whole path if none of the directories exists. */
1445 /* Paths which were allocated using the minimal malloc() in ld.so
1446 must not be freed using the general free() in libc. */
1449 sps->dirs = (void *) -1;
1455 /* Map in the shared object file NAME. */
1459 _dl_map_object (struct link_map *loader, const char *name, int preloaded,
1460 int type, int trace_mode, int mode)
1468 /* Look for this name among those already loaded. */
1469 for (l = _dl_loaded; l; l = l->l_next)
1471 /* If the requested name matches the soname of a loaded object,
1472 use that object. Elide this check for names that have not
1474 /* XXX Is this test still correct after the reference counter
1475 handling rewrite? */
1476 if (l->l_opencount == 0)
1478 if (!_dl_name_match_p (name, l))
1482 if (__builtin_expect (l->l_soname_added, 1)
1483 || l->l_info[DT_SONAME] == NULL)
1486 soname = ((const char *) D_PTR (l, l_info[DT_STRTAB])
1487 + l->l_info[DT_SONAME]->d_un.d_val);
1488 if (strcmp (name, soname) != 0)
1491 /* We have a match on a new name -- cache it. */
1492 add_name_to_object (l, soname);
1493 l->l_soname_added = 1;
1496 /* We have a match. */
1500 /* Display information if we are debugging. */
1501 if (__builtin_expect (_dl_debug_files, 0) && loader != NULL)
1502 _dl_debug_message (1, "\nfile=", name, "; needed by ",
1503 loader->l_name[0] ? loader->l_name : _dl_argv[0],
1506 if (strchr (name, '/') == NULL)
1508 /* Search for NAME in several places. */
1510 size_t namelen = strlen (name) + 1;
1512 if (__builtin_expect (_dl_debug_libs, 0))
1513 _dl_debug_message (1, "find library=", name, "; searching\n", NULL);
1517 /* When the object has the RUNPATH information we don't use any
1519 if (loader == NULL || loader->l_info[DT_RUNPATH] == NULL)
1521 /* First try the DT_RPATH of the dependent object that caused NAME
1522 to be loaded. Then that object's dependent, and on up. */
1523 for (l = loader; fd == -1 && l; l = l->l_loader)
1525 if (l->l_rpath_dirs.dirs == NULL)
1527 if (l->l_info[DT_RPATH] == NULL)
1528 /* There is no path. */
1529 l->l_rpath_dirs.dirs = (void *) -1;
1532 /* Make sure the cache information is available. */
1533 size_t ptrval = (D_PTR (l, l_info[DT_STRTAB])
1534 + l->l_info[DT_RPATH]->d_un.d_val);
1535 decompose_rpath (&l->l_rpath_dirs,
1536 (const char *) ptrval, l, "RPATH");
1538 if (l->l_rpath_dirs.dirs != (void *) -1)
1539 fd = open_path (name, namelen, preloaded,
1540 &l->l_rpath_dirs, &realname, &fb);
1543 else if (l->l_rpath_dirs.dirs != (void *) -1)
1544 fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs,
1548 /* If dynamically linked, try the DT_RPATH of the executable
1551 if (fd == -1 && l && l->l_type != lt_loaded && l != loader
1552 && l->l_rpath_dirs.dirs != (void *) -1)
1553 fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs,
1557 /* Try the LD_LIBRARY_PATH environment variable. */
1558 if (fd == -1 && env_path_list.dirs != (void *) -1)
1559 fd = open_path (name, namelen, preloaded, &env_path_list,
1562 /* Look at the RUNPATH informaiton for this binary. */
1563 if (loader != NULL && loader->l_runpath_dirs.dirs != (void *) -1)
1565 if (loader->l_runpath_dirs.dirs == NULL)
1567 if (loader->l_info[DT_RUNPATH] == NULL)
1569 loader->l_runpath_dirs.dirs = (void *) -1;
1572 /* Make sure the cache information is available. */
1573 size_t ptrval = (D_PTR (loader, l_info[DT_STRTAB])
1574 + loader->l_info[DT_RUNPATH]->d_un.d_val);
1575 decompose_rpath (&loader->l_runpath_dirs,
1576 (const char *) ptrval, loader, "RUNPATH");
1578 if (loader->l_runpath_dirs.dirs != (void *) -1)
1579 fd = open_path (name, namelen, preloaded,
1580 &loader->l_runpath_dirs, &realname, &fb);
1583 else if (loader->l_runpath_dirs.dirs != (void *) -1)
1584 fd = open_path (name, namelen, preloaded,
1585 &loader->l_runpath_dirs, &realname, &fb);
1590 /* Check the list of libraries in the file /etc/ld.so.cache,
1591 for compatibility with Linux's ldconfig program. */
1592 const char *cached = _dl_load_cache_lookup (name);
1595 l = loader ?: _dl_loaded;
1602 /* If the loader has the DF_1_NODEFLIB flag set we must not
1603 use a cache entry from any of these directories. */
1604 if (l && __builtin_expect (l->l_flags_1 & DF_1_NODEFLIB, 0))
1606 const char *dirp = system_dirs;
1611 if (memcmp (cached, dirp, system_dirs_len[cnt]) == 0)
1613 /* The prefix matches. Don't use the entry. */
1618 dirp += system_dirs_len[cnt] + 1;
1621 while (cnt < nsystem_dirs_len);
1626 fd = open_verify (cached, &fb);
1629 realname = local_strdup (cached);
1630 if (realname == NULL)
1640 /* Finally, try the default path. */
1643 __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
1644 && rtld_search_dirs.dirs != (void *) -1)
1645 fd = open_path (name, namelen, preloaded, &rtld_search_dirs,
1648 /* Add another newline when we a tracing the library loading. */
1649 if (__builtin_expect (_dl_debug_libs, 0))
1650 _dl_debug_message (1, "\n", NULL);
1654 /* The path may contain dynamic string tokens. */
1656 ? expand_dynamic_string_token (loader, name)
1657 : local_strdup (name));
1658 if (realname == NULL)
1662 fd = open_verify (realname, &fb);
1672 /* We haven't found an appropriate library. But since we
1673 are only interested in the list of libraries this isn't
1674 so severe. Fake an entry with all the information we
1676 static const Elf_Symndx dummy_bucket = STN_UNDEF;
1678 /* Enter the new object in the list of loaded objects. */
1679 if ((name_copy = local_strdup (name)) == NULL
1680 || (l = _dl_new_object (name_copy, name, type, loader)) == NULL)
1681 _dl_signal_error (ENOMEM, name,
1682 N_("cannot create shared object descriptor"));
1683 /* Signal that this is a faked entry. */
1685 /* Since the descriptor is initialized with zero we do not
1687 l->l_reserved = 0; */
1688 l->l_buckets = &dummy_bucket;
1695 _dl_signal_error (errno, name, N_("cannot open shared object file"));
1698 return _dl_map_object_from_fd (name, fd, &fb, realname, loader, type, mode);