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. */
39 /* Thread-local storage related info. */
41 /* Start of the initialization image. */
42 void *l_tls_initimage;
43 /* Size of the initialization image. */
44 size_t l_tls_initimage_size;
45 /* Size of the TLS block. */
46 size_t l_tls_blocksize;
47 /* Alignment requirement of the TLS block. */
49 /* Offset of first byte module alignment. */
50 size_t l_tls_firstbyte_offset;
51 # ifndef NO_TLS_OFFSET
52 # define NO_TLS_OFFSET 0
54 /* For objects present at startup time: offset in the static TLS block. */
55 ptrdiff_t l_tls_offset;
56 /* Index of the module in the dtv array. */
58 /* Nonzero if _dl_init_static_tls should be called for this module */
59 unsigned int l_need_tls_init:1;
63 enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
64 struct dyn_elf * symbol_scope;
65 unsigned short usage_count;
66 unsigned short int init_flag;
67 unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
70 #ifdef __LDSO_GNU_HASH_SUPPORT__
71 /* Data needed to support GNU hash style */
72 Elf32_Word l_gnu_bitmask_idxbits;
73 Elf32_Word l_gnu_shift;
74 const ElfW(Addr) *l_gnu_bitmask;
78 const Elf32_Word *l_gnu_chain_zero;
79 const Elf_Symndx *elf_buckets;
82 Elf_Symndx *elf_buckets;
85 struct init_fini_list *init_fini;
86 struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
88 * These are only used with ELF style shared libraries
92 #ifdef __LDSO_GNU_HASH_SUPPORT__
95 const Elf32_Word *l_gnu_buckets;
96 const Elf_Symndx *chains;
101 unsigned long dynamic_info[DYNAMIC_SIZE];
103 unsigned long n_phent;
106 ElfW(Addr) relro_addr;
109 dev_t st_dev; /* device */
110 ino_t st_ino; /* inode */
113 /* this is used to store the address of relocation data words, so
114 * we don't have to calculate it every time, which requires a divide */
115 unsigned long data_words;
119 /* Every loaded module holds a hashtable of function descriptors of
120 functions defined in it, such that it's easy to release the
121 memory when the module is dlclose()d. */
122 struct funcdesc_ht *funcdesc_ht;
126 #define RELOCS_DONE 0x000001
127 #define JMP_RELOCS_DONE 0x000002
128 #define INIT_FUNCS_CALLED 0x000004
129 #define FINI_FUNCS_CALLED 0x000008
130 #define DL_OPENED 0x000010
132 extern struct dyn_elf * _dl_symbol_tables;
133 extern struct elf_resolve * _dl_loaded_modules;
134 extern struct dyn_elf * _dl_handles;
136 extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
137 DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info,
138 unsigned long dynamic_addr, unsigned long dynamic_size);
140 /* Only need extra arg with some configurations */
141 #if !(USE_TLS || defined __FDPIC__)
142 # define _dl_lookup_hash(n, r, m, c, t) _dl_lookup_hash(n, r, m, c)
144 extern char *_dl_lookup_hash(const char *name, struct dyn_elf *rpnt,
145 struct elf_resolve *mytpnt, int type_class,
146 struct elf_resolve **tpntp);
148 static __always_inline char *_dl_find_hash(const char *name, struct dyn_elf *rpnt,
149 struct elf_resolve *mytpnt, int type_class,
150 struct elf_resolve **tpntp)
152 return _dl_lookup_hash(name, rpnt, mytpnt, type_class, tpntp);
155 extern int _dl_linux_dynamic_link(void);
157 extern char * _dl_library_path;
158 extern char * _dl_not_lazy;
160 static __inline__ int _dl_symbol(char * name)
162 if (name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
167 #define LD_ERROR_NOFILE 1
168 #define LD_ERROR_NOZERO 2
169 #define LD_ERROR_NOTELF 3
170 #define LD_ERROR_NOTMAGIC 4
171 #define LD_ERROR_NOTDYN 5
172 #define LD_ERROR_MMAP_FAILED 6
173 #define LD_ERROR_NODYNAMIC 7
174 #define LD_ERROR_TLS_FAILED 8
175 #define LD_WRONG_RELOCS 9
176 #define LD_BAD_HANDLE 10
177 #define LD_NO_SYMBOL 11
179 #endif /* _LD_HASH_H_ */