OSDN Git Service

Yet more ldso cleanups. Be more discriminating about when using inlines
[uclinux-h8/uClibc.git] / ldso / ldso / hash.h
1 #include "link.h"
2
3 #ifndef RTLD_NEXT
4 #define RTLD_NEXT       ((void*)-1)
5 #endif
6
7 struct dyn_elf{
8   unsigned long flags;
9   struct elf_resolve * dyn;
10   struct dyn_elf * next_handle;  /* Used by dlopen et al. */
11   struct dyn_elf * next;
12 };
13  
14 struct elf_resolve{
15   /* These entries must be in this order to be compatible with the interface used
16      by gdb to obtain the list of symbols. */
17   char * loadaddr;
18   char * libname;
19   unsigned long dynamic_addr;
20   struct elf_resolve * next;
21   struct elf_resolve * prev;
22   /* Nothing after this address is used by gdb. */
23   enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
24   struct dyn_elf * symbol_scope;
25   unsigned short usage_count;
26   unsigned short int init_flag;
27   unsigned int nbucket;
28   unsigned long * elf_buckets;
29   /*
30    * These are only used with ELF style shared libraries
31    */
32   unsigned long nchain;
33   unsigned long * chains;
34   unsigned long dynamic_info[24];
35
36   unsigned long dynamic_size;
37   unsigned long n_phent;
38   Elf32_Phdr * ppnt;
39 };
40
41 #if 0
42 /*
43  * The DT_DEBUG entry in the .dynamic section is given the address of this structure.
44  * gdb can pick this up to obtain the correct list of loaded modules.
45  */
46
47 struct r_debug{
48   int r_version;
49   struct elf_resolve * link_map;
50   unsigned long brk_fun;
51   enum {RT_CONSISTENT, RT_ADD, RT_DELETE};
52   unsigned long ldbase;
53 };
54 #endif
55
56 #define COPY_RELOCS_DONE 1
57 #define RELOCS_DONE 2
58 #define JMP_RELOCS_DONE 4
59 #define INIT_FUNCS_CALLED 8
60
61 extern struct dyn_elf     * _dl_symbol_tables;
62 extern struct elf_resolve * _dl_loaded_modules;
63 extern struct dyn_elf     * _dl_handles;
64
65 extern struct elf_resolve * _dl_check_hashed_files(char * libname);
66 extern struct elf_resolve * _dl_add_elf_hash_table(char * libname, 
67         char * loadaddr, unsigned long * dynamic_info, 
68         unsigned long dynamic_addr, unsigned long dynamic_size);
69 extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1, 
70         unsigned long instr_addr, struct elf_resolve * f_tpnt, 
71         int copyrel);
72 extern int _dl_linux_dynamic_link(void);
73
74 #ifdef __mc68000__
75 /* On m68k constant strings are referenced through the GOT. */
76 /* XXX Requires load_addr to be defined. */
77 #define SEND_STDERR(X)                          \
78   { const char *__s = (X);                      \
79     if (__s < (const char *) load_addr) __s += load_addr;       \
80     _dl_write (2, __s, _dl_strlen_inline (__s));        \
81   }
82 #else
83 #define SEND_STDERR(X) _dl_write(2, X, _dl_strlen_inline(X));
84 #endif
85 extern int _dl_fdprintf(int, const char *, ...);
86 extern char * _dl_library_path;
87 extern char * _dl_not_lazy;
88 extern char * _dl_strdup(const char *);
89 extern unsigned long _dl_elf_hash(const char * name);
90
91 static inline int _dl_symbol(char * name)
92 {
93   if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
94     return 0;
95   return 1;
96 }
97
98
99 #define DL_ERROR_NOFILE 1
100 #define DL_ERROR_NOZERO 2
101 #define DL_ERROR_NOTELF 3
102 #define DL_ERROR_NOTMAGIC 4
103 #define DL_ERROR_NOTDYN 5
104 #define DL_ERROR_MMAP_FAILED 6
105 #define DL_ERROR_NODYNAMIC 7
106 #define DL_WRONG_RELOCS 8
107 #define DL_BAD_HANDLE 9
108 #define DL_NO_SYMBOL 10
109