1 /* Data structure for communication from the run-time dynamic linker for
2 loaded ELF shared objects.
3 Copyright (C) 1995-2012 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 Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the 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 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _PRIVATE_LINK_H
21 #define _PRIVATE_LINK_H 1
24 # error this should be impossible
27 /* Get most of the contents from the public header, but we define a
28 different `struct link_map' type for private use. The la_objopen
29 prototype uses the type, so we have to declare it separately. */
30 #define link_map link_map_public
31 #define la_objopen la_objopen_wrongproto
37 extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid,
42 #include <bits/linkmap.h>
43 #include <dl-lookupcfg.h>
45 #include <bits/libc-lock.h>
48 /* Some internal data structures of the dynamic linker used in the
49 linker map. We only provide forward declarations. */
51 struct r_found_version;
52 struct r_search_path_elem;
54 /* Forward declaration. */
57 /* Structure to describe a single list of scope elements. The lookup
58 functions get passed an array of pointers to such structures. */
61 /* Array of maps for the scope. */
62 struct link_map **r_list;
63 /* Number of entries in the scope. */
68 /* Structure to record search path and allocation mechanism. */
69 struct r_search_path_struct
71 struct r_search_path_elem **dirs;
76 /* Structure describing a loaded shared object. The `l_next' and `l_prev'
77 members form a chain of all the shared objects loaded at startup.
79 These data structures exist in space used by the run-time dynamic linker;
80 modifying them may have disastrous results.
82 This data structure might change in future, if necessary. User-level
83 programs must avoid defining objects of this type. */
87 /* These first few members are part of the protocol with the debugger.
88 This is the same format used in SVR4. */
90 ElfW(Addr) l_addr; /* Base address shared object is loaded at. */
91 char *l_name; /* Absolute file name object was found in. */
92 ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */
93 struct link_map *l_next, *l_prev; /* Chain of loaded objects. */
95 /* All following members are internal to the dynamic linker.
96 They may change without notice. */
98 /* This is an element which is only ever different from a pointer to
99 the very same copy of this type for ld.so when it is used in more
100 than one namespace. */
101 struct link_map *l_real;
103 /* Number of the namespace this link map belongs to. */
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_THISPROCNUM) are indexed by the tag minus DT_LOPROC.
110 [DT_NUM+DT_THISPROCNUM,DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM) are
111 indexed by DT_VERSIONTAGIDX(tagvalue).
112 [DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM,
113 DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM) are indexed by
114 DT_EXTRATAGIDX(tagvalue).
115 [DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM,
116 DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM+DT_VALNUM) are
117 indexed by DT_VALTAGIDX(tagvalue) and
118 [DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM+DT_VALNUM,
119 DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM+DT_VALNUM+DT_ADDRNUM)
120 are indexed by DT_ADDRTAGIDX(tagvalue), see <elf.h>. */
122 ElfW(Dyn) *l_info[DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM
123 + DT_EXTRANUM + DT_VALNUM + DT_ADDRNUM];
124 const ElfW(Phdr) *l_phdr; /* Pointer to program header table in core. */
125 ElfW(Addr) l_entry; /* Entry point location. */
126 ElfW(Half) l_phnum; /* Number of program header entries. */
127 ElfW(Half) l_ldnum; /* Number of dynamic segment entries. */
129 /* Array of DT_NEEDED dependencies and their dependencies, in
130 dependency order for symbol lookup (with and without
131 duplicates). There is no entry before the dependencies have
133 struct r_scope_elem l_searchlist;
135 /* We need a special searchlist to process objects marked with
137 struct r_scope_elem l_symbolic_searchlist;
139 /* Dependent object that first caused this object to be loaded. */
140 struct link_map *l_loader;
142 /* Array with version names. */
143 struct r_found_version *l_versions;
144 unsigned int l_nversions;
146 /* Symbol hash table. */
147 Elf_Symndx l_nbuckets;
148 Elf32_Word l_gnu_bitmask_idxbits;
149 Elf32_Word l_gnu_shift;
150 const ElfW(Addr) *l_gnu_bitmask;
153 const Elf32_Word *l_gnu_buckets;
154 const Elf_Symndx *l_chain;
158 const Elf32_Word *l_gnu_chain_zero;
159 const Elf_Symndx *l_buckets;
162 unsigned int l_direct_opencount; /* Reference count for dlopen/dlclose. */
163 enum /* Where this object came from. */
165 lt_executable, /* The main executable program. */
166 lt_library, /* Library needed by main executable. */
167 lt_loaded /* Extra run-time loaded shared object. */
169 unsigned int l_relocated:1; /* Nonzero if object's relocations done. */
170 unsigned int l_init_called:1; /* Nonzero if DT_INIT function called. */
171 unsigned int l_global:1; /* Nonzero if object in _dl_global_scope. */
172 unsigned int l_reserved:2; /* Reserved for internal use. */
173 unsigned int l_phdr_allocated:1; /* Nonzero if the data structure pointed
174 to by `l_phdr' is allocated. */
175 unsigned int l_soname_added:1; /* Nonzero if the SONAME is for sure in
176 the l_libname list. */
177 unsigned int l_faked:1; /* Nonzero if this is a faked descriptor
178 without associated file. */
179 unsigned int l_need_tls_init:1; /* Nonzero if GL(dl_init_static_tls)
180 should be called on this link map
181 when relocation finishes. */
182 unsigned int l_auditing:1; /* Nonzero if the DSO is used in auditing. */
183 unsigned int l_audit_any_plt:1; /* Nonzero if at least one audit module
184 is interested in the PLT interception.*/
185 unsigned int l_removed:1; /* Nozero if the object cannot be used anymore
186 since it is removed. */
187 unsigned int l_contiguous:1; /* Nonzero if inter-segment holes are
188 mprotected or if no holes are present at
190 unsigned int l_symbolic_in_local_scope:1; /* Nonzero if l_local_scope
191 during LD_TRACE_PRELINKING=1
192 contains any DT_SYMBOLIC
194 unsigned int l_free_initfini:1; /* Nonzero if l_initfini can be
195 freed, ie. not allocated with
196 the dummy malloc in ld.so. */
198 /* Collected information about own RPATH directories. */
199 struct r_search_path_struct l_rpath_dirs;
201 /* Collected results of relocation while profiling. */
204 DL_FIXUP_VALUE_TYPE addr;
205 struct link_map *bound;
206 unsigned int boundndx;
211 /* Pointer to the version information if available. */
212 ElfW(Versym) *l_versyms;
214 /* String specifying the path where this object was found. */
215 const char *l_origin;
217 /* Start and finish of memory map for this object. l_map_start
218 need not be the same as l_addr. */
219 ElfW(Addr) l_map_start, l_map_end;
220 /* End of the executable part of the mapping. */
221 ElfW(Addr) l_text_end;
223 /* Default array for 'l_scope'. */
224 struct r_scope_elem *l_scope_mem[4];
225 /* Size of array allocated for 'l_scope'. */
227 /* This is an array defining the lookup scope for this link map.
228 There are initially at most three different scope lists. */
229 struct r_scope_elem **l_scope;
231 /* A similar array, this time only with the local scope. This is
232 used occasionally. */
233 struct r_scope_elem *l_local_scope[2];
235 /* This information is kept to check for sure whether a shared
236 object is the same as one already loaded. */
240 /* Collected information about own RUNPATH directories. */
241 struct r_search_path_struct l_runpath_dirs;
243 /* List of object in order of the init and fini calls. */
244 struct link_map **l_initfini;
246 /* List of the dependencies introduced through symbol binding. */
247 struct link_map_reldeps
250 struct link_map *list[];
252 unsigned int l_reldepsmax;
254 /* Nonzero if the DSO is used. */
257 /* Various flag words. */
258 ElfW(Word) l_feature_1;
259 ElfW(Word) l_flags_1;
262 /* Temporarily used in `dl_close'. */
265 struct link_map_machine l_mach;
269 const ElfW(Sym) *sym;
271 struct link_map *value;
272 const ElfW(Sym) *ret;
275 /* Thread-local storage related info. */
277 /* Start of the initialization image. */
278 void *l_tls_initimage;
279 /* Size of the initialization image. */
280 size_t l_tls_initimage_size;
281 /* Size of the TLS block. */
282 size_t l_tls_blocksize;
283 /* Alignment requirement of the TLS block. */
285 /* Offset of first byte module alignment. */
286 size_t l_tls_firstbyte_offset;
287 #ifndef NO_TLS_OFFSET
288 # define NO_TLS_OFFSET 0
290 #ifndef FORCED_DYNAMIC_TLS_OFFSET
291 # if NO_TLS_OFFSET == 0
292 # define FORCED_DYNAMIC_TLS_OFFSET 1
293 # elif NO_TLS_OFFSET == -1
294 # define FORCED_DYNAMIC_TLS_OFFSET -2
296 # error "FORCED_DYNAMIC_TLS_OFFSET is not defined"
299 /* For objects present at startup time: offset in the static TLS block. */
300 ptrdiff_t l_tls_offset;
301 /* Index of the module in the dtv array. */
304 /* Information used to change permission after the relocations are
306 ElfW(Addr) l_relro_addr;
309 unsigned long long int l_serial;
311 /* Audit information. This array apparent must be the last in the
312 structure. Never add something after it. */
316 unsigned int bindflags;
321 #if __ELF_NATIVE_CLASS == 32
322 # define symbind symbind32
323 #elif __ELF_NATIVE_CLASS == 64
324 # define symbind symbind64
326 # error "__ELF_NATIVE_CLASS must be defined"
329 extern int __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
330 size_t size, void *data),
333 /* We use this macro to refer to ELF macros independent of the native
334 wordsize. `ELFW(R_TYPE)' is used in place of `ELF32_R_TYPE' or
336 #define ELFW(type) _ElfW (ELF, __ELF_NATIVE_CLASS, type)
338 #endif /* include/link.h */