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;
29 /* These entries must be in this order to be compatible with the interface used
30 by gdb to obtain the list of symbols. */
31 DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */
32 char *libname; /* Absolute file name object was found in. */
33 ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */
34 struct elf_resolve * next;
35 struct elf_resolve * prev;
36 /* Nothing after this address is used by gdb. */
37 ElfW(Addr) mapaddr; /* Address at which ELF segments (either main app and DSO) are mapped into */
38 enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
39 struct dyn_elf * symbol_scope;
40 unsigned short usage_count;
41 unsigned short int init_flag;
42 unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
45 #ifdef __LDSO_GNU_HASH_SUPPORT__
46 /* Data needed to support GNU hash style */
47 Elf32_Word l_gnu_bitmask_idxbits;
48 Elf32_Word l_gnu_shift;
49 const ElfW(Addr) *l_gnu_bitmask;
53 const Elf32_Word *l_gnu_chain_zero;
54 const Elf_Symndx *elf_buckets;
57 Elf_Symndx *elf_buckets;
60 struct init_fini_list *init_fini;
61 struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
63 * These are only used with ELF style shared libraries
67 #ifdef __LDSO_GNU_HASH_SUPPORT__
70 const Elf32_Word *l_gnu_buckets;
71 const Elf_Symndx *chains;
76 unsigned long dynamic_info[DYNAMIC_SIZE];
78 unsigned long n_phent;
81 ElfW(Addr) relro_addr;
84 dev_t st_dev; /* device */
85 ino_t st_ino; /* inode */
88 /* this is used to store the address of relocation data words, so
89 * we don't have to calculate it every time, which requires a divide */
90 unsigned long data_words;
94 /* Every loaded module holds a hashtable of function descriptors of
95 functions defined in it, such that it's easy to release the
96 memory when the module is dlclose()d. */
97 struct funcdesc_ht *funcdesc_ht;
101 #define RELOCS_DONE 0x000001
102 #define JMP_RELOCS_DONE 0x000002
103 #define INIT_FUNCS_CALLED 0x000004
104 #define FINI_FUNCS_CALLED 0x000008
105 #define DL_OPENED 0x000010
107 extern struct dyn_elf * _dl_symbol_tables;
108 extern struct elf_resolve * _dl_loaded_modules;
109 extern struct dyn_elf * _dl_handles;
111 extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
112 DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info,
113 unsigned long dynamic_addr, unsigned long dynamic_size);
115 extern char * _dl_lookup_hash(const char * name, struct dyn_elf * rpnt,
116 struct elf_resolve *mytpnt, int type_class
118 , struct elf_resolve **tpntp
122 static __always_inline char *_dl_find_hash(const char *name, struct dyn_elf *rpnt,
123 struct elf_resolve *mytpnt, int type_class)
126 return _dl_lookup_hash(name, rpnt, mytpnt, type_class, NULL);
128 return _dl_lookup_hash(name, rpnt, mytpnt, type_class);
132 extern int _dl_linux_dynamic_link(void);
134 extern char * _dl_library_path;
135 extern char * _dl_not_lazy;
137 static inline int _dl_symbol(char * name)
139 if (name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
144 #define LD_ERROR_NOFILE 1
145 #define LD_ERROR_NOZERO 2
146 #define LD_ERROR_NOTELF 3
147 #define LD_ERROR_NOTMAGIC 4
148 #define LD_ERROR_NOTDYN 5
149 #define LD_ERROR_MMAP_FAILED 6
150 #define LD_ERROR_NODYNAMIC 7
151 #define LD_WRONG_RELOCS 8
152 #define LD_BAD_HANDLE 9
153 #define LD_NO_SYMBOL 10
155 #endif /* _LD_HASH_H_ */