time.h: Add CLOCK_TAI
[uclibc-ng.git] / ldso / include / dl-hash.h
blobd1deea9f32064c087c672284dc4e6494c737cb0f
1 /*
2 * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
4 * GNU Lesser General Public License version 2.1 or later.
5 */
7 #ifndef _DL_HASH_H
8 #define _DL_HASH_H
10 #ifndef RTLD_NEXT
11 #define RTLD_NEXT ((void*)-1)
12 #endif
14 struct init_fini {
15 struct elf_resolve **init_fini;
16 unsigned long nlist; /* Number of entries in init_fini */
19 struct dyn_elf {
20 struct elf_resolve * dyn;
21 struct dyn_elf * next_handle; /* Used by dlopen et al. */
22 struct init_fini init_fini;
23 struct dyn_elf * next;
24 struct dyn_elf * prev;
27 struct symbol_ref {
28 const ElfW(Sym) *sym;
29 struct elf_resolve *tpnt;
32 /* Structure to describe a single list of scope elements. The lookup
33 functions get passed an array of pointers to such structures. */
34 struct r_scope_elem {
35 struct elf_resolve **r_list; /* Array of maps for the scope. */
36 unsigned int r_nlist; /* Number of entries in the scope. */
37 struct r_scope_elem *next;
40 struct elf_resolve {
41 /* These entries must be in this order to be compatible with the interface used
42 by gdb to obtain the list of symbols. */
43 DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */
44 char *libname; /* Absolute file name object was found in. */
45 ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */
46 struct elf_resolve * next;
47 struct elf_resolve * prev;
48 /* Nothing after this address is used by gdb. */
50 #if defined(USE_TLS) && USE_TLS
51 /* Thread-local storage related info. */
53 /* Start of the initialization image. */
54 void *l_tls_initimage;
55 /* Size of the initialization image. */
56 size_t l_tls_initimage_size;
57 /* Size of the TLS block. */
58 size_t l_tls_blocksize;
59 /* Alignment requirement of the TLS block. */
60 size_t l_tls_align;
61 /* Offset of first byte module alignment. */
62 size_t l_tls_firstbyte_offset;
63 # ifndef NO_TLS_OFFSET
64 # define NO_TLS_OFFSET 0
65 # endif
66 /* For objects present at startup time: offset in the static TLS block. */
67 ptrdiff_t l_tls_offset;
68 /* Index of the module in the dtv array. */
69 size_t l_tls_modid;
70 /* Nonzero if _dl_init_static_tls should be called for this module */
71 unsigned int l_need_tls_init:1;
72 /* Address of TLS descriptor hash table. */
73 void *l_tlsdesc_table;
74 #endif
76 ElfW(Addr) mapaddr;
77 #ifdef __LDSO_STANDALONE_SUPPORT__
78 /* Store the entry point from the ELF header (e_entry) */
79 ElfW(Addr) l_entry;
80 #endif
81 enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
82 /* This is the local scope of the shared object */
83 struct r_scope_elem symbol_scope;
84 unsigned short usage_count;
85 unsigned short int init_flag;
86 unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
87 Elf_Symndx nbucket;
89 #ifdef __LDSO_GNU_HASH_SUPPORT__
90 /* Data needed to support GNU hash style */
91 Elf32_Word l_gnu_bitmask_idxbits;
92 Elf32_Word l_gnu_shift;
93 const ElfW(Addr) *l_gnu_bitmask;
95 union
97 const Elf32_Word *l_gnu_chain_zero;
98 const Elf_Symndx *elf_buckets;
100 #else
101 Elf_Symndx *elf_buckets;
102 #endif
104 struct init_fini_list *init_fini;
105 struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
107 * These are only used with ELF style shared libraries
109 Elf_Symndx nchain;
111 #ifdef __LDSO_GNU_HASH_SUPPORT__
112 union
114 const Elf32_Word *l_gnu_buckets;
115 const Elf_Symndx *chains;
117 #else
118 Elf_Symndx *chains;
119 #endif
120 unsigned long dynamic_info[DYNAMIC_SIZE];
122 unsigned long n_phent;
123 ElfW(Phdr) * ppnt;
125 ElfW(Addr) relro_addr;
126 size_t relro_size;
128 dev_t st_dev; /* device */
129 ino_t st_ino; /* inode */
131 #ifdef __powerpc__
132 /* this is used to store the address of relocation data words, so
133 * we don't have to calculate it every time, which requires a divide */
134 unsigned long data_words;
135 #endif
137 #if defined(__FRV_FDPIC__) || defined(__BFIN_FDPIC__) || defined(__FDPIC__)
138 /* Every loaded module holds a hashtable of function descriptors of
139 functions defined in it, such that it's easy to release the
140 memory when the module is dlclose()d. */
141 struct funcdesc_ht *funcdesc_ht;
142 #endif
143 #ifdef __DSBT__
144 /* Information for DSBT */
145 void **dsbt_table;
146 unsigned long dsbt_size;
147 unsigned long dsbt_index;
148 #endif
151 #define RELOCS_DONE 0x000001
152 #define JMP_RELOCS_DONE 0x000002
153 #define INIT_FUNCS_CALLED 0x000004
154 #define FINI_FUNCS_CALLED 0x000008
155 #define DL_OPENED2 0x000010
156 #define DL_RESERVED 0x000020
158 extern struct dyn_elf * _dl_symbol_tables;
159 extern struct elf_resolve * _dl_loaded_modules;
160 extern struct dyn_elf * _dl_handles;
162 extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
163 DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info,
164 unsigned long dynamic_addr, unsigned long dynamic_size);
166 extern char *_dl_find_hash(const char *name, struct r_scope_elem *scope,
167 struct elf_resolve *mytpnt, int type_class,
168 struct symbol_ref *symbol);
170 extern char * _dl_library_path;
172 #define LD_ERROR_NOFILE 1
173 #define LD_ERROR_NOZERO 2
174 #define LD_ERROR_NOTELF 3
175 #define LD_ERROR_NOTMAGIC 4
176 #define LD_ERROR_NOTDYN 5
177 #define LD_ERROR_MMAP_FAILED 6
178 #define LD_ERROR_NODYNAMIC 7
179 #define LD_ERROR_TLS_FAILED 8
180 #define LD_WRONG_RELOCS 9
181 #define LD_BAD_HANDLE 10
182 #define LD_NO_SYMBOL 11
184 #endif /* _DL_HASH_H */