1 /* Data structure for communication from the run-time dynamic linker for
2 loaded ELF shared objects.
3 Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
28 /* We use this macro to refer to ELF types independent of the native wordsize.
29 `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
30 #define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type)
31 #define _ElfW(e,w,t) _ElfW_1 (e, w, _##t)
32 #define _ElfW_1(e,w,t) e##w##t
34 #include <bits/elfclass.h> /* Defines __ELF_NATIVE_CLASS. */
36 /* Rendezvous structure used by the run-time dynamic linker to communicate
37 details of shared object loading to the debugger. If the executable's
38 dynamic section has a DT_DEBUG element, the run-time linker sets that
39 element's value to the address where this structure can be found. */
43 int r_version
; /* Version number for this protocol. */
45 struct link_map
*r_map
; /* Head of the chain of loaded objects. */
47 /* This is the address of a function internal to the run-time linker,
48 that will always be called when the linker begins to map in a
49 library or unmap it, and again when the mapping change is complete.
50 The debugger can set a breakpoint at this address if it wants to
51 notice shared object mapping changes. */
55 /* This state value describes the mapping change taking place when
56 the `r_brk' address is called. */
57 RT_CONSISTENT
, /* Mapping change is complete. */
58 RT_ADD
, /* Beginning to add a new object. */
59 RT_DELETE
/* Beginning to remove an object mapping. */
62 ElfW(Addr
) r_ldbase
; /* Base address the linker is loaded at. */
65 /* This is the instance of that structure used by the dynamic linker. */
66 extern struct r_debug _r_debug
;
68 /* This symbol refers to the "dynamic structure" in the `.dynamic' section
69 of whatever module refers to `_DYNAMIC'. So, to find its own
70 `struct r_debug', a program could do:
71 for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL)
72 if (dyn->d_tag == DT_DEBUG) r_debug = (struct r_debug) dyn->d_un.d_ptr;
74 extern ElfW(Dyn
) _DYNAMIC
[];
77 /* Some internal data structures of the dynamic linker used in the
78 linker map. We only provide forward declarations. */
80 struct r_found_version
;
81 struct r_search_path_elem
;
84 /* Structure describing a loaded shared object. The `l_next' and `l_prev'
85 members form a chain of all the shared objects loaded at startup.
87 These data structures exist in space used by the run-time dynamic linker;
88 modifying them may have disastrous results.
90 This data structure might change in future, if necessary. User-level
91 programs must avoid defining objects of this type. */
95 /* These first few members are part of the protocol with the debugger.
96 This is the same format used in SVR4. */
98 ElfW(Addr
) l_addr
; /* Base address shared object is loaded at. */
99 char *l_name
; /* Absolute file name object was found in. */
100 ElfW(Dyn
) *l_ld
; /* Dynamic section of the shared object. */
101 struct link_map
*l_next
, *l_prev
; /* Chain of loaded objects. */
103 /* All following members are internal to the dynamic linker.
104 They may change without notice. */
106 struct libname_list
*l_libname
;
107 /* Indexed pointers to dynamic section.
108 [0,DT_NUM) are indexed by the processor-independent tags.
109 [DT_NUM,DT_NUM+DT_PROCNUM) are indexed by the tag minus DT_LOPROC.
110 [DT_NUM+DT_PROCNUM,DT_NUM+DT_PROCNUM+DT_EXTRANUM) are indexed
111 by DT_EXTRATAGIDX(tagvalue) and
112 [DT_NUM+DT_PROCNUM+DT_VERSIONTAGNUM,
113 DT_NUM+DT_PROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM)
114 are indexed by DT_EXTRATAGIDX(tagvalue) (see <elf.h>). */
116 ElfW(Dyn
) *l_info
[DT_NUM
+ DT_PROCNUM
+ DT_VERSIONTAGNUM
+ DT_EXTRANUM
];
117 const ElfW(Phdr
) *l_phdr
; /* Pointer to program header table in core. */
118 ElfW(Addr
) l_entry
; /* Entry point location. */
119 ElfW(Half
) l_phnum
; /* Number of program header entries. */
121 /* Array of DT_NEEDED dependencies and their dependencies, in
122 dependency order for symbol lookup. This is null before the
123 dependencies have been loaded. */
124 struct link_map
**l_searchlist
;
125 unsigned int l_nsearchlist
;
127 /* We keep another list in which we keep duplicates. This is
128 needed in _dl_lookup_symbol_skip to implemented RTLD_NEXT. */
129 struct link_map
**l_dupsearchlist
;
130 unsigned int l_ndupsearchlist
;
132 /* Dependent object that first caused this object to be loaded. */
133 struct link_map
*l_loader
;
135 /* Symbol hash table. */
136 ElfW(Symndx
) l_nbuckets
;
137 const ElfW(Symndx
) *l_buckets
, *l_chain
;
139 unsigned int l_opencount
; /* Reference count for dlopen/dlclose. */
140 enum /* Where this object came from. */
142 lt_executable
, /* The main executable program. */
143 lt_library
, /* Library needed by main executable. */
144 lt_loaded
/* Extra run-time loaded shared object. */
146 unsigned int l_relocated
:1; /* Nonzero if object's relocations done. */
147 unsigned int l_init_called
:1; /* Nonzero if DT_INIT function called. */
148 unsigned int l_init_running
:1; /* Nonzero while DT_INIT function runs. */
149 unsigned int l_global
:1; /* Nonzero if object in _dl_global_scope. */
150 unsigned int l_reserved
:2; /* Reserved for internal use. */
152 /* Array with version names. */
153 unsigned int l_nversions
;
154 struct r_found_version
*l_versions
;
156 /* Collected information about own RPATH directories. */
157 struct r_search_path_elem
**l_rpath_dirs
;
159 /* Collected results of relocation while profiling. */
160 ElfW(Addr
) *l_reloc_result
;
162 /* Pointer to the version information if available. */
163 ElfW(Half
) *l_versyms
;