2000-06-10 13:48:35 +08:00
|
|
|
/* Data structure for communication from the run-time dynamic linker for
|
|
|
|
loaded ELF shared objects.
|
2006-03-01 14:18:49 +08:00
|
|
|
Copyright (C) 1995-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
|
2000-06-10 13:48:35 +08:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 12:58:11 +08:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 12:58:11 +08:00
|
|
|
Lesser General Public License for more details.
|
2000-06-10 13:48:35 +08:00
|
|
|
|
2001-07-06 12:58:11 +08:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
2000-06-10 13:48:35 +08:00
|
|
|
|
2006-03-01 14:18:49 +08:00
|
|
|
#ifndef _PRIVATE_LINK_H
|
|
|
|
#define _PRIVATE_LINK_H 1
|
2000-06-10 13:48:35 +08:00
|
|
|
|
2006-03-01 14:18:49 +08:00
|
|
|
#ifdef _LINK_H
|
|
|
|
# error this should be impossible
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Get most of the contents from the public header, but we define a
|
|
|
|
different `struct link_map' type for private use. The la_objopen
|
|
|
|
prototype uses the type, so we have to declare it separately. */
|
|
|
|
#define link_map link_map_public
|
|
|
|
#define la_objopen la_objopen_wrongproto
|
|
|
|
#include <elf/link.h>
|
|
|
|
#undef link_map
|
|
|
|
#undef la_objopen
|
|
|
|
|
|
|
|
struct link_map;
|
|
|
|
extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid,
|
|
|
|
uintptr_t *__cookie);
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
|
2006-03-01 14:18:49 +08:00
|
|
|
#include <stddef.h>
|
2005-01-07 06:40:27 +08:00
|
|
|
#include <bits/linkmap.h>
|
2004-12-23 04:10:10 +08:00
|
|
|
#include <dl-lookupcfg.h>
|
|
|
|
#include <tls.h> /* Defines USE_TLS. */
|
2006-10-10 08:51:29 +08:00
|
|
|
#include <bits/libc-lock.h>
|
|
|
|
#include <rtld-lowlevel.h>
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* Some internal data structures of the dynamic linker used in the
|
|
|
|
linker map. We only provide forward declarations. */
|
|
|
|
struct libname_list;
|
|
|
|
struct r_found_version;
|
|
|
|
struct r_search_path_elem;
|
|
|
|
|
|
|
|
/* Forward declaration. */
|
|
|
|
struct link_map;
|
|
|
|
|
|
|
|
/* Structure to describe a single list of scope elements. The lookup
|
|
|
|
functions get passed an array of pointers to such structures. */
|
|
|
|
struct r_scope_elem
|
|
|
|
{
|
|
|
|
/* Array of maps for the scope. */
|
|
|
|
struct link_map **r_list;
|
|
|
|
/* Number of entries in the scope. */
|
|
|
|
unsigned int r_nlist;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-08-31 10:27:07 +08:00
|
|
|
/* Structure to record search path and allocation mechanism. */
|
|
|
|
struct r_search_path_struct
|
|
|
|
{
|
|
|
|
struct r_search_path_elem **dirs;
|
|
|
|
int malloced;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-10-10 08:51:29 +08:00
|
|
|
/* Structure for a scope. Each such data structure has a lock. The
|
|
|
|
lock allows many readers. It can be invalidated by setting bit 31
|
|
|
|
which means that no more lockers are allowe */
|
|
|
|
struct r_scoperec
|
|
|
|
{
|
|
|
|
bool remove_after_use;
|
|
|
|
bool notify;
|
|
|
|
int nusers;
|
|
|
|
struct r_scope_elem *scope[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-06-10 13:48:35 +08:00
|
|
|
/* Structure describing a loaded shared object. The `l_next' and `l_prev'
|
|
|
|
members form a chain of all the shared objects loaded at startup.
|
|
|
|
|
|
|
|
These data structures exist in space used by the run-time dynamic linker;
|
|
|
|
modifying them may have disastrous results.
|
|
|
|
|
|
|
|
This data structure might change in future, if necessary. User-level
|
|
|
|
programs must avoid defining objects of this type. */
|
|
|
|
|
|
|
|
struct link_map
|
|
|
|
{
|
|
|
|
/* These first few members are part of the protocol with the debugger.
|
|
|
|
This is the same format used in SVR4. */
|
|
|
|
|
|
|
|
ElfW(Addr) l_addr; /* Base address shared object is loaded at. */
|
|
|
|
char *l_name; /* Absolute file name object was found in. */
|
|
|
|
ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */
|
|
|
|
struct link_map *l_next, *l_prev; /* Chain of loaded objects. */
|
|
|
|
|
|
|
|
/* All following members are internal to the dynamic linker.
|
|
|
|
They may change without notice. */
|
|
|
|
|
[BZ #77]
Update.
Add support for namespaces in the dynamic linker.
* dlfcn/Makefile (libdl-routines): Add dlmopen.
* dlfcn/Versions [libdl, GLIBC_2.3.4]: Add dlmopen.
* dlfcn/dlfcn.h: Define Lmid_t, LM_ID_BASE, and LM_ID_NEWLM.
Declare dlmopen. Document RTLD_DI_LMID.
* dlfcn/dlinfo.c: Handle RTLD_DI_LMID.
* dlfcn/dlmopen.c: New file.
* dlfcn/dlopen.c: Pass new parameter to _dl_open.
* dlfcn/dlopenold.c: Likewise.
* elf/dl-addr.c: Adjust for removal of GL(dl_loaded).
* elf/dl-caller.c: Likewise.
* elf/dl-close.c: Likewise.
* elf/dl-conflict.c: Likewise.
* elf/dl-debug.c: Likewise.
* elf/dl-lookup.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-version.c: Likewise.
* elf/do-lookup.h: Likewise.
* elf/rtld.c: Likewise.
* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Likewise.
* elf/dl-depsc: Likewise. Add new parameter to _dl_map_object.
* elf/dl-fini.c: Call destructors in all namespaces.
* elf/dl-iteratephdr.c: Compute total nloaded. Adjust for removal of
GL(dl_loaded).
* elf/dl-libc.c: Pass new parameter to _dl_open. Adjust for removal
of GL(dl_loaded).
* elf/dl-load.c (_dl_map_object_from_fd): Don't load ld.so a second
time. Reuse the one from the main namespace in all others.
Pass new parameter to _dl_new_object.
Adjust for removal of GL(dl_loaded).
* elf/dl-object.c: Take new parameter. Use it to initialize l_ns.
Adjust for removal of GL(dl_loaded).
* elf/dl-open.c (_dl_open): Take new parameter.
Adjust for removal of GL(dl_loaded).
* elf/dl-support.c: Replace global _dl_loaded etc variables with
_dl_ns variable.
* include/dlfcn.h: Adjust prototype of _dl_open.
Define __LM_ID_CALLER.
* include/link.h: Add l_real, l_ns, and l_direct_opencount elements.
* sysdeps/generic/dl-tls.c: Bump TLS_STATIC_SURPLUS. Since libc is
using TLS we need memory appropriate to the number of namespaces.
* sysdeps/generic/ldsodefs.h (struct rtld_global): Replace _dl_loaded,
_dl_nloaded, _dl_global_scope, _dl_main_searchlist, and
_dl_global_scope_alloc with _dl_ns element. Define DL_NNS.
Adjust prototypes of _dl_map_object and member in rtld_global_ro.
* malloc/malloc.c: Include <dlfcn.h>.
* malloc/arena.c (ptmalloc_init): If libc is not in primary namespace,
never use brk.
* elf/Makefile: Add rules to build and run tst-dlmopen1 and
tst-dlmopen2.
* elf/tst-dlmopen1.c: New file.
* elf/tst-dlmopen1mod.c: New file.
* elf/tst-dlmopen2.c: New file.
* elf/dl-close.c: Improve reference counting by tracking direct loads.
* elf/dl-lookup.c (add_dependency): Likewise.
* elf/dl-open.c (dl_open_worker): Likewise.
* elf/rtld.c (dl_main): Likewise.
2004-09-09 GOTO Masanori <gotom@debian.or.jp>
[BZ #77]
* elf/dl-close.c: Count down l_opencount to check not only for
l_reldeps, but also l_initfini.
2004-10-13 Ulrich Drepper <drepper@redhat.com>
2004-10-14 10:08:23 +08:00
|
|
|
/* This is an element which is only ever different from a pointer to
|
|
|
|
the very same copy of this type for ld.so when it is used in more
|
|
|
|
than one namespace. */
|
|
|
|
struct link_map *l_real;
|
|
|
|
|
|
|
|
/* Number of the namespace this link map belongs to. */
|
|
|
|
Lmid_t l_ns;
|
|
|
|
|
2000-06-10 13:48:35 +08:00
|
|
|
struct libname_list *l_libname;
|
|
|
|
/* Indexed pointers to dynamic section.
|
|
|
|
[0,DT_NUM) are indexed by the processor-independent tags.
|
|
|
|
[DT_NUM,DT_NUM+DT_THISPROCNUM) are indexed by the tag minus DT_LOPROC.
|
Update.
2001-12-11 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile (dl-routines): Add conflict.
(rtld-ldscript-in, rtld-ldscript, rtld-parms): Remove.
(ld.so): Add _begin local symbol.
* elf/elf.h (DT_VALTAGIDX, DT_VALNUM, DT_ADDRTAGIDX, DT_ADDRNUM):
Define.
* elf/dl-deps.c (_dl_build_local_scope): New.
(_dl_map_object_deps): If LD_TRACE_PRELINKING, compute local scopes
of all libraries.
* elf/do-rel.h (VALIDX): Define.
(elf_dynamic_do_rel): If ELF_MACHINE_PLT_REL is defined, don't do
lazy binding for RELA. If DT_GNU_PRELINKED, DT_RELACOUNT relocations
can be skipped.
* elf/dl-conflict.c: New file.
* elf/dl-lookup.c (_dl_debug_bindings): New.
(_dl_lookup_symbol): Use _dl_debug_bindings. Reference_name is always
non-NULL.
(_dl_lookup_symbol_skip): Likewise.
(_dl_lookup_versioned_symbol): Likewise.
(_dl_lookup_versioned_symbol_skip): Likewise.
* elf/dl-runtime.c (PLTREL): If ELF_MACHINE_PLT_REL is defined,
define to ElfW(Rel).
* elf/dynamic-link.h (elf_get_dynamic_info): Record selected dynamic
tags in the DT_VALRNGLO..DT_VALRNGHI and DT_ADDRRNGLO..DT_ADDRRNGHI
ranges.
Don't adjust address dynamic tags if l_addr is 0.
* elf/rtld.c (_dl_trace_prelink, _dl_trace_prelink_map): New variables.
(_dl_start): Skip ELF_DYNAMIC_RELOCATE if ld.so is prelinked.
(VALIDX, ADDRIDX): Define.
(_dl_start_final): Initialize _dl_rtld_map's l_map_start and l_map_end.
(dl_main): Print library list for LD_TRACE_PRELINKING.
If prelinking information can be used, skip relocating libraries and
call _dl_resolve_conflicts instead.
(process_envvars): Handle LD_TRACE_PRELINKING envvar.
* elf/dl-load.c (_dl_map_object): Don't create fake libs
if LD_TRACE_PRELINKING.
* include/link.h (struct link_map) [l_info]: Add DT_VALNUM
+ DT_ADDRNUM.
* sysdeps/generic/ldsodefs.h (_dl_trace_prelink_map): New declaration.
(DL_DEBUG_PRELINK): Define.
(_dl_resolve_conflicts): Add prototype.
* sysdeps/alpha/dl-machine.h (elf_machine_runtime_setup): Reinitialize
.plt for prelinked libraries where prelinking info cannot be used.
(elf_machine_rela): If relocating R_ALPHA_JMP_SLOT in .gnu.conflict
section, use RESOLVE_CONFLICT_FIND_MAP to find out reloc's link_map.
* sysdeps/arm/bits/link.h: New file.
* sysdeps/arm/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_ARM_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/i386/bits/link.h: New file.
* sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_386_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/powerpc/dl-machine.h (elf_machine_rela): If relocating
conflicts, skip finaladdr computation. Use RESOLVE_CONFLICT_FIND_MAP
to find out map for R_PPC_JMP_SLOT relocs.
* sysdeps/sparc/sparc32/dl-machine.h (VALIDX): Define.
(OPCODE_BA): Define.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
(sparc_fixup_plt): Renamed from elf_machine_fixup_plt.
(elf_machine_fixup_plt): Call sparc_fixup_plt.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Call sparc_fixup_plt for R_SPARC_JMP_SLOT.
* sysdeps/sparc/sparc64/dl-machine.h (VALIDX): Define.
(sparc64_fixup_plt): Fix a typo.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Handle R_SPARC_JMP_SLOT relocs when relocating conflicts.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
* sysdeps/sh/bits/link.h: New file.
* sysdeps/sh/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_SH_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-32/bits/link.h: New file.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-64/bits/link.h: New file.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/x86_64/bits/link.h: New file.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_X86_64_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
2001-12-12 08:21:26 +08:00
|
|
|
[DT_NUM+DT_THISPROCNUM,DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM) are
|
|
|
|
indexed by DT_VERSIONTAGIDX(tagvalue).
|
2000-06-10 13:48:35 +08:00
|
|
|
[DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM,
|
Update.
2001-12-11 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile (dl-routines): Add conflict.
(rtld-ldscript-in, rtld-ldscript, rtld-parms): Remove.
(ld.so): Add _begin local symbol.
* elf/elf.h (DT_VALTAGIDX, DT_VALNUM, DT_ADDRTAGIDX, DT_ADDRNUM):
Define.
* elf/dl-deps.c (_dl_build_local_scope): New.
(_dl_map_object_deps): If LD_TRACE_PRELINKING, compute local scopes
of all libraries.
* elf/do-rel.h (VALIDX): Define.
(elf_dynamic_do_rel): If ELF_MACHINE_PLT_REL is defined, don't do
lazy binding for RELA. If DT_GNU_PRELINKED, DT_RELACOUNT relocations
can be skipped.
* elf/dl-conflict.c: New file.
* elf/dl-lookup.c (_dl_debug_bindings): New.
(_dl_lookup_symbol): Use _dl_debug_bindings. Reference_name is always
non-NULL.
(_dl_lookup_symbol_skip): Likewise.
(_dl_lookup_versioned_symbol): Likewise.
(_dl_lookup_versioned_symbol_skip): Likewise.
* elf/dl-runtime.c (PLTREL): If ELF_MACHINE_PLT_REL is defined,
define to ElfW(Rel).
* elf/dynamic-link.h (elf_get_dynamic_info): Record selected dynamic
tags in the DT_VALRNGLO..DT_VALRNGHI and DT_ADDRRNGLO..DT_ADDRRNGHI
ranges.
Don't adjust address dynamic tags if l_addr is 0.
* elf/rtld.c (_dl_trace_prelink, _dl_trace_prelink_map): New variables.
(_dl_start): Skip ELF_DYNAMIC_RELOCATE if ld.so is prelinked.
(VALIDX, ADDRIDX): Define.
(_dl_start_final): Initialize _dl_rtld_map's l_map_start and l_map_end.
(dl_main): Print library list for LD_TRACE_PRELINKING.
If prelinking information can be used, skip relocating libraries and
call _dl_resolve_conflicts instead.
(process_envvars): Handle LD_TRACE_PRELINKING envvar.
* elf/dl-load.c (_dl_map_object): Don't create fake libs
if LD_TRACE_PRELINKING.
* include/link.h (struct link_map) [l_info]: Add DT_VALNUM
+ DT_ADDRNUM.
* sysdeps/generic/ldsodefs.h (_dl_trace_prelink_map): New declaration.
(DL_DEBUG_PRELINK): Define.
(_dl_resolve_conflicts): Add prototype.
* sysdeps/alpha/dl-machine.h (elf_machine_runtime_setup): Reinitialize
.plt for prelinked libraries where prelinking info cannot be used.
(elf_machine_rela): If relocating R_ALPHA_JMP_SLOT in .gnu.conflict
section, use RESOLVE_CONFLICT_FIND_MAP to find out reloc's link_map.
* sysdeps/arm/bits/link.h: New file.
* sysdeps/arm/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_ARM_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/i386/bits/link.h: New file.
* sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_386_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/powerpc/dl-machine.h (elf_machine_rela): If relocating
conflicts, skip finaladdr computation. Use RESOLVE_CONFLICT_FIND_MAP
to find out map for R_PPC_JMP_SLOT relocs.
* sysdeps/sparc/sparc32/dl-machine.h (VALIDX): Define.
(OPCODE_BA): Define.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
(sparc_fixup_plt): Renamed from elf_machine_fixup_plt.
(elf_machine_fixup_plt): Call sparc_fixup_plt.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Call sparc_fixup_plt for R_SPARC_JMP_SLOT.
* sysdeps/sparc/sparc64/dl-machine.h (VALIDX): Define.
(sparc64_fixup_plt): Fix a typo.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Handle R_SPARC_JMP_SLOT relocs when relocating conflicts.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
* sysdeps/sh/bits/link.h: New file.
* sysdeps/sh/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_SH_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-32/bits/link.h: New file.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-64/bits/link.h: New file.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/x86_64/bits/link.h: New file.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_X86_64_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
2001-12-12 08:21:26 +08:00
|
|
|
DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM) are indexed by
|
|
|
|
DT_EXTRATAGIDX(tagvalue).
|
|
|
|
[DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM,
|
|
|
|
DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM+DT_VALNUM) are
|
|
|
|
indexed by DT_VALTAGIDX(tagvalue) and
|
|
|
|
[DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM+DT_VALNUM,
|
|
|
|
DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM+DT_VALNUM+DT_ADDRNUM)
|
|
|
|
are indexed by DT_ADDRTAGIDX(tagvalue), see <elf.h>. */
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
ElfW(Dyn) *l_info[DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM
|
2006-10-10 08:51:29 +08:00
|
|
|
+ DT_EXTRANUM + DT_VALNUM + DT_ADDRNUM];
|
2000-06-10 13:48:35 +08:00
|
|
|
const ElfW(Phdr) *l_phdr; /* Pointer to program header table in core. */
|
|
|
|
ElfW(Addr) l_entry; /* Entry point location. */
|
|
|
|
ElfW(Half) l_phnum; /* Number of program header entries. */
|
2006-07-11 05:59:43 +08:00
|
|
|
ElfW(Half) l_ldnum; /* Number of dynamic segment entries. */
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
/* Array of DT_NEEDED dependencies and their dependencies, in
|
|
|
|
dependency order for symbol lookup (with and without
|
|
|
|
duplicates). There is no entry before the dependencies have
|
|
|
|
been loaded. */
|
|
|
|
struct r_scope_elem l_searchlist;
|
|
|
|
|
|
|
|
/* We need a special searchlist to process objects marked with
|
|
|
|
DT_SYMBOLIC. */
|
|
|
|
struct r_scope_elem l_symbolic_searchlist;
|
|
|
|
|
|
|
|
/* Dependent object that first caused this object to be loaded. */
|
|
|
|
struct link_map *l_loader;
|
|
|
|
|
|
|
|
/* Symbol hash table. */
|
|
|
|
Elf_Symndx l_nbuckets;
|
2006-07-11 05:59:43 +08:00
|
|
|
Elf32_Word l_gnu_bitmask_idxbits;
|
|
|
|
Elf32_Word l_gnu_shift;
|
|
|
|
const ElfW(Addr) *l_gnu_bitmask;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
const Elf32_Word *l_gnu_buckets;
|
|
|
|
const Elf_Symndx *l_chain;
|
|
|
|
};
|
|
|
|
union
|
|
|
|
{
|
|
|
|
const Elf32_Word *l_gnu_chain_zero;
|
|
|
|
const Elf_Symndx *l_buckets;
|
|
|
|
};
|
2000-06-10 13:48:35 +08:00
|
|
|
|
[BZ #77]
Update.
Add support for namespaces in the dynamic linker.
* dlfcn/Makefile (libdl-routines): Add dlmopen.
* dlfcn/Versions [libdl, GLIBC_2.3.4]: Add dlmopen.
* dlfcn/dlfcn.h: Define Lmid_t, LM_ID_BASE, and LM_ID_NEWLM.
Declare dlmopen. Document RTLD_DI_LMID.
* dlfcn/dlinfo.c: Handle RTLD_DI_LMID.
* dlfcn/dlmopen.c: New file.
* dlfcn/dlopen.c: Pass new parameter to _dl_open.
* dlfcn/dlopenold.c: Likewise.
* elf/dl-addr.c: Adjust for removal of GL(dl_loaded).
* elf/dl-caller.c: Likewise.
* elf/dl-close.c: Likewise.
* elf/dl-conflict.c: Likewise.
* elf/dl-debug.c: Likewise.
* elf/dl-lookup.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-version.c: Likewise.
* elf/do-lookup.h: Likewise.
* elf/rtld.c: Likewise.
* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Likewise.
* elf/dl-depsc: Likewise. Add new parameter to _dl_map_object.
* elf/dl-fini.c: Call destructors in all namespaces.
* elf/dl-iteratephdr.c: Compute total nloaded. Adjust for removal of
GL(dl_loaded).
* elf/dl-libc.c: Pass new parameter to _dl_open. Adjust for removal
of GL(dl_loaded).
* elf/dl-load.c (_dl_map_object_from_fd): Don't load ld.so a second
time. Reuse the one from the main namespace in all others.
Pass new parameter to _dl_new_object.
Adjust for removal of GL(dl_loaded).
* elf/dl-object.c: Take new parameter. Use it to initialize l_ns.
Adjust for removal of GL(dl_loaded).
* elf/dl-open.c (_dl_open): Take new parameter.
Adjust for removal of GL(dl_loaded).
* elf/dl-support.c: Replace global _dl_loaded etc variables with
_dl_ns variable.
* include/dlfcn.h: Adjust prototype of _dl_open.
Define __LM_ID_CALLER.
* include/link.h: Add l_real, l_ns, and l_direct_opencount elements.
* sysdeps/generic/dl-tls.c: Bump TLS_STATIC_SURPLUS. Since libc is
using TLS we need memory appropriate to the number of namespaces.
* sysdeps/generic/ldsodefs.h (struct rtld_global): Replace _dl_loaded,
_dl_nloaded, _dl_global_scope, _dl_main_searchlist, and
_dl_global_scope_alloc with _dl_ns element. Define DL_NNS.
Adjust prototypes of _dl_map_object and member in rtld_global_ro.
* malloc/malloc.c: Include <dlfcn.h>.
* malloc/arena.c (ptmalloc_init): If libc is not in primary namespace,
never use brk.
* elf/Makefile: Add rules to build and run tst-dlmopen1 and
tst-dlmopen2.
* elf/tst-dlmopen1.c: New file.
* elf/tst-dlmopen1mod.c: New file.
* elf/tst-dlmopen2.c: New file.
* elf/dl-close.c: Improve reference counting by tracking direct loads.
* elf/dl-lookup.c (add_dependency): Likewise.
* elf/dl-open.c (dl_open_worker): Likewise.
* elf/rtld.c (dl_main): Likewise.
2004-09-09 GOTO Masanori <gotom@debian.or.jp>
[BZ #77]
* elf/dl-close.c: Count down l_opencount to check not only for
l_reldeps, but also l_initfini.
2004-10-13 Ulrich Drepper <drepper@redhat.com>
2004-10-14 10:08:23 +08:00
|
|
|
unsigned int l_direct_opencount; /* Reference count for dlopen/dlclose. */
|
2000-06-10 13:48:35 +08:00
|
|
|
enum /* Where this object came from. */
|
|
|
|
{
|
|
|
|
lt_executable, /* The main executable program. */
|
|
|
|
lt_library, /* Library needed by main executable. */
|
|
|
|
lt_loaded /* Extra run-time loaded shared object. */
|
|
|
|
} l_type:2;
|
|
|
|
unsigned int l_relocated:1; /* Nonzero if object's relocations done. */
|
|
|
|
unsigned int l_init_called:1; /* Nonzero if DT_INIT function called. */
|
|
|
|
unsigned int l_global:1; /* Nonzero if object in _dl_global_scope. */
|
|
|
|
unsigned int l_reserved:2; /* Reserved for internal use. */
|
|
|
|
unsigned int l_phdr_allocated:1; /* Nonzero if the data structure pointed
|
|
|
|
to by `l_phdr' is allocated. */
|
2000-10-21 14:32:16 +08:00
|
|
|
unsigned int l_soname_added:1; /* Nonzero if the SONAME is for sure in
|
|
|
|
the l_libname list. */
|
2000-10-24 09:02:15 +08:00
|
|
|
unsigned int l_faked:1; /* Nonzero if this is a faked descriptor
|
|
|
|
without associated file. */
|
2003-07-31 15:42:20 +08:00
|
|
|
unsigned int l_need_tls_init:1; /* Nonzero if GL(dl_init_static_tls)
|
|
|
|
should be called on this link map
|
|
|
|
when relocation finishes. */
|
2004-09-18 14:46:52 +08:00
|
|
|
unsigned int l_used:1; /* Nonzero if the DSO is used. */
|
2005-01-07 06:40:27 +08:00
|
|
|
unsigned int l_auditing:1; /* Nonzero if the DSO is used in auditing. */
|
|
|
|
unsigned int l_audit_any_plt:1; /* Nonzero if at least one audit module
|
|
|
|
is interested in the PLT interception.*/
|
2005-03-18 19:11:42 +08:00
|
|
|
unsigned int l_removed:1; /* Nozero if the object cannot be used anymore
|
|
|
|
since it is removed. */
|
2005-01-07 06:40:27 +08:00
|
|
|
|
2000-06-10 13:48:35 +08:00
|
|
|
/* Array with version names. */
|
|
|
|
unsigned int l_nversions;
|
|
|
|
struct r_found_version *l_versions;
|
|
|
|
|
|
|
|
/* Collected information about own RPATH directories. */
|
2000-08-31 10:27:07 +08:00
|
|
|
struct r_search_path_struct l_rpath_dirs;
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
/* Collected results of relocation while profiling. */
|
2005-01-07 06:40:27 +08:00
|
|
|
struct reloc_result
|
|
|
|
{
|
2005-02-08 06:56:07 +08:00
|
|
|
DL_FIXUP_VALUE_TYPE addr;
|
2005-01-07 06:40:27 +08:00
|
|
|
struct link_map *bound;
|
|
|
|
unsigned int boundndx;
|
|
|
|
uint32_t enterexit;
|
|
|
|
unsigned int flags;
|
|
|
|
} *l_reloc_result;
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
/* Pointer to the version information if available. */
|
|
|
|
ElfW(Versym) *l_versyms;
|
|
|
|
|
|
|
|
/* String specifying the path where this object was found. */
|
|
|
|
const char *l_origin;
|
|
|
|
|
|
|
|
/* Start and finish of memory map for this object. l_map_start
|
|
|
|
need not be the same as l_addr. */
|
|
|
|
ElfW(Addr) l_map_start, l_map_end;
|
2004-03-27 11:40:33 +08:00
|
|
|
/* End of the executable part of the mapping. */
|
|
|
|
ElfW(Addr) l_text_end;
|
2000-06-10 13:48:35 +08:00
|
|
|
|
2001-09-07 15:50:47 +08:00
|
|
|
/* Default array for 'l_scope'. */
|
2006-10-10 08:51:29 +08:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct r_scoperec l_scoperec_mem;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct r_scoperec scoperec_struct;
|
|
|
|
/* XXX This number should be increased once the scope memory
|
|
|
|
handling has been tested. */
|
|
|
|
struct r_scope_elem *scope_elems[4];
|
|
|
|
#define NINIT_SCOPE_ELEMS(map) \
|
|
|
|
(sizeof ((map)->l_scope_realmem.scope_elems) \
|
|
|
|
/ sizeof ((map)->l_scope_realmem.scope_elems[0]))
|
|
|
|
} l_scope_realmem;
|
|
|
|
};
|
2001-09-07 15:50:47 +08:00
|
|
|
/* Size of array allocated for 'l_scope'. */
|
|
|
|
size_t l_scope_max;
|
2000-06-10 13:48:35 +08:00
|
|
|
/* This is an array defining the lookup scope for this link map.
|
2006-09-21 12:04:20 +08:00
|
|
|
There are initially at most three different scope lists. */
|
2006-10-10 08:51:29 +08:00
|
|
|
struct r_scoperec *l_scoperec;
|
|
|
|
/* We need to protect using the SCOPEREC. */
|
|
|
|
__rtld_mrlock_define (, l_scoperec_lock)
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
/* A similar array, this time only with the local scope. This is
|
|
|
|
used occasionally. */
|
|
|
|
struct r_scope_elem *l_local_scope[2];
|
|
|
|
|
|
|
|
/* This information is kept to check for sure whether a shared
|
|
|
|
object is the same as one already loaded. */
|
|
|
|
dev_t l_dev;
|
2000-08-16 09:28:07 +08:00
|
|
|
ino64_t l_ino;
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
/* Collected information about own RUNPATH directories. */
|
2000-08-31 10:27:07 +08:00
|
|
|
struct r_search_path_struct l_runpath_dirs;
|
2000-06-10 13:48:35 +08:00
|
|
|
|
|
|
|
/* List of object in order of the init and fini calls. */
|
|
|
|
struct link_map **l_initfini;
|
|
|
|
|
|
|
|
/* List of the dependencies introduced through symbol binding. */
|
|
|
|
unsigned int l_reldepsmax;
|
|
|
|
unsigned int l_reldepsact;
|
|
|
|
struct link_map **l_reldeps;
|
2000-07-21 06:53:54 +08:00
|
|
|
|
|
|
|
/* Various flag words. */
|
|
|
|
ElfW(Word) l_feature_1;
|
|
|
|
ElfW(Word) l_flags_1;
|
2002-02-06 08:55:46 +08:00
|
|
|
ElfW(Word) l_flags;
|
2000-10-24 15:24:28 +08:00
|
|
|
|
|
|
|
/* Temporarily used in `dl_close'. */
|
2005-03-18 19:11:42 +08:00
|
|
|
int l_idx;
|
2001-07-26 08:27:15 +08:00
|
|
|
|
|
|
|
struct link_map_machine l_mach;
|
2001-08-26 18:50:26 +08:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const ElfW(Sym) *sym;
|
2001-08-27 06:28:16 +08:00
|
|
|
int type_class;
|
2001-08-26 18:50:26 +08:00
|
|
|
struct link_map *value;
|
|
|
|
const ElfW(Sym) *ret;
|
|
|
|
} l_lookup_cache;
|
2002-02-05 16:02:04 +08:00
|
|
|
|
2002-02-07 12:08:19 +08:00
|
|
|
#ifdef USE_TLS
|
2002-02-05 16:02:04 +08:00
|
|
|
/* Thread-local storage related info. */
|
|
|
|
|
|
|
|
/* Start of the initialization image. */
|
|
|
|
void *l_tls_initimage;
|
|
|
|
/* Size of the initialization image. */
|
|
|
|
size_t l_tls_initimage_size;
|
|
|
|
/* Size of the TLS block. */
|
|
|
|
size_t l_tls_blocksize;
|
2002-12-02 06:13:42 +08:00
|
|
|
/* Alignment requirement of the TLS block. */
|
2002-02-07 12:08:19 +08:00
|
|
|
size_t l_tls_align;
|
2003-07-25 04:07:00 +08:00
|
|
|
/* Offset of first byte module alignment. */
|
|
|
|
size_t l_tls_firstbyte_offset;
|
2003-04-25 17:12:43 +08:00
|
|
|
# ifndef NO_TLS_OFFSET
|
|
|
|
# define NO_TLS_OFFSET 0
|
|
|
|
# endif
|
2002-02-05 16:02:04 +08:00
|
|
|
/* For objects present at startup time: offset in the static TLS block. */
|
|
|
|
ptrdiff_t l_tls_offset;
|
|
|
|
/* Index of the module in the dtv array. */
|
|
|
|
size_t l_tls_modid;
|
2002-02-07 12:08:19 +08:00
|
|
|
#endif
|
2004-01-13 16:36:54 +08:00
|
|
|
|
|
|
|
/* Information used to change permission after the relocations are
|
|
|
|
done. */
|
|
|
|
ElfW(Addr) l_relro_addr;
|
|
|
|
size_t l_relro_size;
|
2005-01-07 06:40:27 +08:00
|
|
|
|
|
|
|
/* Audit information. This array apparent must be the last in the
|
|
|
|
structure. Never add something after it. */
|
|
|
|
struct auditstate
|
|
|
|
{
|
|
|
|
uintptr_t cookie;
|
|
|
|
unsigned int bindflags;
|
|
|
|
} l_audit[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if __ELF_NATIVE_CLASS == 32
|
|
|
|
# define symbind symbind32
|
|
|
|
#elif __ELF_NATIVE_CLASS == 64
|
|
|
|
# define symbind symbind64
|
|
|
|
#else
|
|
|
|
# error "__ELF_NATIVE_CLASS must be defined"
|
|
|
|
#endif
|
|
|
|
|
2001-07-26 04:47:02 +08:00
|
|
|
extern int __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
|
|
|
|
size_t size, void *data),
|
|
|
|
void *data);
|
|
|
|
|
2006-03-01 14:18:49 +08:00
|
|
|
#endif /* include/link.h */
|