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