OSDN Git Service

Fix nommu handling of DT_TEXTREL
[uclinux-h8/uClibc.git] / ldso / include / ldso.h
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
4  *
5  * GNU Lesser General Public License version 2.1 or later.
6  */
7
8 #ifndef _LDSO_H_
9 #define _LDSO_H_
10
11 #include <features.h>
12
13 /* Prepare for the case that `__builtin_expect' is not available.  */
14 #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
15 #define __builtin_expect(x, expected_value) (x)
16 #endif
17 #ifndef likely
18 # define likely(x)      __builtin_expect((!!(x)),1)
19 #endif
20 #ifndef unlikely
21 # define unlikely(x)    __builtin_expect((!!(x)),0)
22 #endif
23 #ifndef __LINUX_COMPILER_H
24 #define __LINUX_COMPILER_H
25 #endif
26
27 /* Pull in compiler and arch stuff */
28 #include <stdlib.h>
29 #include <stdarg.h>
30 #define _FCNTL_H
31 #include <bits/fcntl.h>
32 #include <bits/wordsize.h>
33 /* Pull in the arch specific type information */
34 #include <sys/types.h>
35 /* Pull in the arch specific page size */
36 #include <bits/uClibc_page.h>
37 /* Pull in the MIN macro */
38 #include <sys/param.h>
39 /* Pull in the ldso syscalls and string functions */
40 #ifndef __ARCH_HAS_NO_SHARED__
41 #include <dl-syscall.h>
42 #include <dl-string.h>
43 #include <dlfcn.h>
44 /* Now the ldso specific headers */
45 #include <dl-elf.h>
46 #ifdef __UCLIBC_HAS_TLS__
47 /* Defines USE_TLS */
48 #include <tls.h>
49 #endif
50 #include <dl-hash.h>
51
52 /* common align masks, if not specified by sysdep headers */
53 #ifndef ADDR_ALIGN
54 #define ADDR_ALIGN (_dl_pagesize - 1)
55 #endif
56
57 #ifndef PAGE_ALIGN
58 #define PAGE_ALIGN (~ADDR_ALIGN)
59 #endif
60
61 #ifndef OFFS_ALIGN
62 #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
63 #endif
64
65 /* For INIT/FINI dependency sorting. */
66 struct init_fini_list {
67         struct init_fini_list *next;
68         struct elf_resolve *tpnt;
69 };
70
71 /* Global variables used within the shared library loader */
72 extern char *_dl_library_path;         /* Where we look for libraries */
73 extern char *_dl_preload;              /* Things to be loaded before the libs */
74 extern char *_dl_ldsopath;             /* Where the shared lib loader was found */
75 extern const char *_dl_progname;       /* The name of the executable being run */
76 extern size_t _dl_pagesize;            /* Store the page size for use later */
77
78 #if defined(USE_TLS) && USE_TLS
79 extern void _dl_add_to_slotinfo (struct link_map  *l);
80 extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
81 #endif
82
83 #ifdef USE_TLS
84 void _dl_add_to_slotinfo (struct link_map  *l);
85 void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
86 #endif
87 #ifdef __SUPPORT_LD_DEBUG__
88 extern char *_dl_debug;
89 extern char *_dl_debug_symbols;
90 extern char *_dl_debug_move;
91 extern char *_dl_debug_reloc;
92 extern char *_dl_debug_detail;
93 extern char *_dl_debug_nofixups;
94 extern char *_dl_debug_bindings;
95 extern int   _dl_debug_file;
96 # define __dl_debug_dprint(fmt, args...) \
97         _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __FUNCTION__, __LINE__, ## args);
98 # define _dl_if_debug_dprint(fmt, args...) \
99         do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
100 #else
101 # define __dl_debug_dprint(fmt, args...) do {} while (0)
102 # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
103 # define _dl_debug_file 2
104 #endif /* __SUPPORT_LD_DEBUG__ */
105
106 #ifdef IS_IN_rtld
107 # ifdef __SUPPORT_LD_DEBUG__
108 #  define _dl_assert(expr)                                              \
109         do {                                                            \
110                 if (!(expr)) {                                          \
111                         __dl_debug_dprint("assert(%s)\n", #expr);       \
112                         _dl_exit(45);                                   \
113                 }                                                       \
114         } while (0)
115 # else
116 #  define _dl_assert(expr) ((void)0)
117 # endif
118 #else
119 # include <assert.h>
120 # define _dl_assert(expr) assert(expr)
121 #endif
122
123 #ifdef __SUPPORT_LD_DEBUG_EARLY__
124 # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
125 #else
126 # define _dl_debug_early(fmt, args...) do {} while (0)
127 #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
128
129 #ifndef NULL
130 #define NULL ((void *) 0)
131 #endif
132
133 extern void *_dl_malloc(size_t size);
134 extern void *_dl_calloc(size_t __nmemb, size_t __size);
135 extern void *_dl_realloc(void *__ptr, size_t __size);
136 extern void _dl_free(void *);
137 extern char *_dl_getenv(const char *symbol, char **envp);
138 extern void _dl_unsetenv(const char *symbol, char **envp);
139 extern char *_dl_strdup(const char *string);
140 extern void _dl_dprintf(int, const char *, ...);
141
142 #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
143 # define DL_GET_READY_TO_RUN_EXTRA_PARMS
144 #endif
145 #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
146 # define DL_GET_READY_TO_RUN_EXTRA_ARGS
147 #endif
148
149 extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
150                 ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
151                 DL_GET_READY_TO_RUN_EXTRA_PARMS);
152
153 #ifdef HAVE_DL_INLINES_H
154 #include <dl-inlines.h>
155 #endif
156
157 #else /* __ARCH_HAS_NO_SHARED__ */
158 #include <dl-defs.h>
159 #endif
160
161 #endif /* _LDSO_H_ */