1 /* vi: set sw=4 ts=4: */
3 * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
5 * GNU Lesser General Public License version 2.1 or later.
12 #define RTLD_NEXT ((void*)-1)
16 struct elf_resolve **init_fini;
17 unsigned long nlist; /* Number of entries in init_fini */
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;
30 struct elf_resolve *tpnt;
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. */
43 #if defined(USE_TLS) && USE_TLS
44 /* Thread-local storage related info. */
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. */
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
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. */
63 /* Nonzero if _dl_init_static_tls should be called for this module */
64 unsigned int l_need_tls_init:1;
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. */
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;
83 const Elf32_Word *l_gnu_chain_zero;
84 const Elf_Symndx *elf_buckets;
87 Elf_Symndx *elf_buckets;
90 struct init_fini_list *init_fini;
91 struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
93 * These are only used with ELF style shared libraries
97 #ifdef __LDSO_GNU_HASH_SUPPORT__
100 const Elf32_Word *l_gnu_buckets;
101 const Elf_Symndx *chains;
106 unsigned long dynamic_info[DYNAMIC_SIZE];
108 unsigned long n_phent;
111 ElfW(Addr) relro_addr;
114 dev_t st_dev; /* device */
115 ino_t st_ino; /* inode */
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;
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;
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
137 extern struct dyn_elf * _dl_symbol_tables;
138 extern struct elf_resolve * _dl_loaded_modules;
139 extern struct dyn_elf * _dl_handles;
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);
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);
149 extern int _dl_linux_dynamic_link(void);
151 extern char * _dl_library_path;
152 extern char * _dl_not_lazy;
154 static __inline__ int _dl_symbol(char * name)
156 if (name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
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
173 #endif /* _LD_HASH_H_ */