]> 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 _LD_HASH_H_
9 #define _LD_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 struct elf_resolve {
34   /* These entries must be in this order to be compatible with the interface used
35      by gdb to obtain the list of symbols. */
36   DL_LOADADDR_TYPE loadaddr;    /* Base address shared object is loaded at.  */
37   char *libname;                /* Absolute file name object was found in.  */
38   ElfW(Dyn) *dynamic_addr;      /* Dynamic section of the shared object.  */
39   struct elf_resolve * next;
40   struct elf_resolve * prev;
41   /* Nothing after this address is used by gdb. */
42
43 #if defined(USE_TLS) && USE_TLS
44   /* Thread-local storage related info.  */
45
46   /* Start of the initialization image.  */
47   void *l_tls_initimage;
48   /* Size of the initialization image.  */
49   size_t l_tls_initimage_size;
50   /* Size of the TLS block.  */
51   size_t l_tls_blocksize;
52   /* Alignment requirement of the TLS block.  */
53   size_t l_tls_align;
54   /* Offset of first byte module alignment.  */
55   size_t l_tls_firstbyte_offset;
56 # ifndef NO_TLS_OFFSET
57 #  define NO_TLS_OFFSET 0
58 # endif
59   /* For objects present at startup time: offset in the static TLS block.  */
60   ptrdiff_t l_tls_offset;
61   /* Index of the module in the dtv array.  */
62   size_t l_tls_modid;
63   /* Nonzero if _dl_init_static_tls should be called for this module */
64   unsigned int l_need_tls_init:1;
65 #endif
66
67   ElfW(Addr) mapaddr;
68   enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
69   struct dyn_elf * symbol_scope;
70   unsigned short usage_count;
71   unsigned short int init_flag;
72   unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
73   Elf_Symndx nbucket;
74
75 #ifdef __LDSO_GNU_HASH_SUPPORT__
76   /* Data needed to support GNU hash style */
77   Elf32_Word l_gnu_bitmask_idxbits;
78   Elf32_Word l_gnu_shift;
79   const ElfW(Addr) *l_gnu_bitmask;
80
81   union
82   {
83     const Elf32_Word *l_gnu_chain_zero;
84     const Elf_Symndx *elf_buckets;
85   };
86 #else
87   Elf_Symndx *elf_buckets;
88 #endif
89
90   struct init_fini_list *init_fini;
91   struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
92   /*
93    * These are only used with ELF style shared libraries
94    */
95   Elf_Symndx nchain;
96
97 #ifdef __LDSO_GNU_HASH_SUPPORT__
98   union
99   {
100     const Elf32_Word *l_gnu_buckets;
101     const Elf_Symndx *chains;
102   };
103 #else
104   Elf_Symndx *chains;
105 #endif
106   unsigned long dynamic_info[DYNAMIC_SIZE];
107
108   unsigned long n_phent;
109   ElfW(Phdr) * ppnt;
110
111   ElfW(Addr) relro_addr;
112   size_t relro_size;
113
114   dev_t st_dev;      /* device */
115   ino_t st_ino;      /* inode */
116
117 #ifdef __powerpc__
118   /* this is used to store the address of relocation data words, so
119    * we don't have to calculate it every time, which requires a divide */
120   unsigned long data_words;
121 #endif
122
123 #ifdef __FDPIC__
124   /* Every loaded module holds a hashtable of function descriptors of
125      functions defined in it, such that it's easy to release the
126      memory when the module is dlclose()d.  */
127   struct funcdesc_ht *funcdesc_ht;
128 #endif
129 };
130
131 #define RELOCS_DONE         0x000001
132 #define JMP_RELOCS_DONE     0x000002
133 #define INIT_FUNCS_CALLED   0x000004
134 #define FINI_FUNCS_CALLED   0x000008
135 #define DL_OPENED           0x000010
136
137 extern struct dyn_elf     * _dl_symbol_tables;
138 extern struct elf_resolve * _dl_loaded_modules;
139 extern struct dyn_elf     * _dl_handles;
140
141 extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
142         DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info,
143         unsigned long dynamic_addr, unsigned long dynamic_size);
144
145 extern char *_dl_find_hash(const char *name, struct dyn_elf *rpnt,
146                 struct elf_resolve *mytpnt, int type_class,
147                 struct symbol_ref *symbol);
148
149 extern int _dl_linux_dynamic_link(void);
150
151 extern char * _dl_library_path;
152 extern char * _dl_not_lazy;
153
154 static __inline__ int _dl_symbol(char * name)
155 {
156   if (name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
157     return 0;
158   return 1;
159 }
160
161 #define LD_ERROR_NOFILE 1
162 #define LD_ERROR_NOZERO 2
163 #define LD_ERROR_NOTELF 3
164 #define LD_ERROR_NOTMAGIC 4
165 #define LD_ERROR_NOTDYN 5
166 #define LD_ERROR_MMAP_FAILED 6
167 #define LD_ERROR_NODYNAMIC 7
168 #define LD_ERROR_TLS_FAILED 8
169 #define LD_WRONG_RELOCS 9
170 #define LD_BAD_HANDLE 10
171 #define LD_NO_SYMBOL 11
172
173 #endif /* _LD_HASH_H_ */