Revert "mips64: time64 for n32 ABI breaks a lot of tests, disable it for now"
[uclibc-ng.git] / ldso / include / ldso.h
bloba397cce6180c01861c4116c1819ec7a1c9f36bfb
1 /*
2 * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
4 * GNU Lesser General Public License version 2.1 or later.
5 */
7 #ifndef _LDSO_H
8 #define _LDSO_H
10 #include <features.h>
12 #ifdef __ARCH_USE_MMU__
13 # define _MAP_UNINITIALIZED 0
14 #else
15 # define _MAP_UNINITIALIZED MAP_UNINITIALIZED
16 #endif
18 /* Prepare for the case that `__builtin_expect' is not available. */
19 #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
20 #define __builtin_expect(x, expected_value) (x)
21 #endif
22 #ifndef likely
23 # define likely(x) __builtin_expect((!!(x)),1)
24 #endif
25 #ifndef unlikely
26 # define unlikely(x) __builtin_expect((!!(x)),0)
27 #endif
28 #ifndef __LINUX_COMPILER_H
29 #define __LINUX_COMPILER_H
30 #endif
32 /* Pull in compiler and arch stuff */
33 #include <stdlib.h>
34 #include <stdarg.h>
35 #include <stddef.h> /* for ptrdiff_t */
36 #include <stdbool.h>
37 #define _FCNTL_H
38 /* We need this if arch has only new syscalls defined */
39 #ifndef AT_FDCWD
40 #define AT_FDCWD -100
41 #endif /* AT_FDCWD */
42 #include <bits/fcntl.h>
43 #include <bits/wordsize.h>
44 /* Pull in the arch specific type information */
45 #include <sys/types.h>
46 /* Pull in the arch specific page size */
47 #include <bits/uClibc_page.h>
48 /* Pull in the MIN macro */
49 #include <sys/param.h>
50 /* Pull in the ldso syscalls and string functions */
51 #if !defined(__ARCH_HAS_NO_SHARED__) || !defined(__ARCH_HAS_NO_LDSO__)
52 #include <dl-syscall.h>
53 #include <dl-string.h>
54 /* Now the ldso specific headers */
55 #include <dl-elf.h>
56 #ifdef __UCLIBC_HAS_TLS__
57 /* Defines USE_TLS */
58 #include <tls.h>
59 #endif
60 #include <dl-hash.h>
62 /* common align masks, if not specified by sysdep headers */
63 #ifndef ADDR_ALIGN
64 #define ADDR_ALIGN (_dl_pagesize - 1)
65 #endif
67 #ifndef PAGE_ALIGN
68 #define PAGE_ALIGN (~ADDR_ALIGN)
69 #endif
71 #ifndef OFFS_ALIGN
72 #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
73 #endif
75 /* For INIT/FINI dependency sorting. */
76 struct init_fini_list {
77 struct init_fini_list *next;
78 struct elf_resolve *tpnt;
81 /* Global variables used within the shared library loader */
82 extern char *_dl_library_path; /* Where we look for libraries */
83 extern char *_dl_preload; /* Things to be loaded before the libs */
84 #ifdef __LDSO_SEARCH_INTERP_PATH__
85 extern const char *_dl_ldsopath; /* Where the shared lib loader was found */
86 #endif
87 extern const char *_dl_progname; /* The name of the executable being run */
88 extern size_t _dl_pagesize; /* Store the page size for use later */
89 #ifdef __LDSO_PRELINK_SUPPORT__
90 extern char *_dl_trace_prelink; /* Library for prelinking trace */
91 extern struct elf_resolve *_dl_trace_prelink_map; /* Library map for prelinking trace */
92 #else
93 #define _dl_trace_prelink 0
94 #endif
95 #ifdef __DSBT__
96 extern void **_dl_ldso_dsbt;
97 #endif
99 #if defined(USE_TLS) && USE_TLS
100 extern void _dl_add_to_slotinfo (struct link_map *l);
101 extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
102 #endif
104 #ifdef __SUPPORT_LD_DEBUG__
105 extern char *_dl_debug;
106 extern char *_dl_debug_symbols;
107 extern char *_dl_debug_move;
108 extern char *_dl_debug_reloc;
109 extern char *_dl_debug_detail;
110 extern char *_dl_debug_nofixups;
111 extern char *_dl_debug_bindings;
112 extern char *_dl_debug_vdso;
113 extern int _dl_debug_file;
114 # define __dl_debug_dprint(fmt, args...) \
115 _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __func__, __LINE__, ## args);
116 # define _dl_if_debug_dprint(fmt, args...) \
117 do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
118 #else
119 # define __dl_debug_dprint(fmt, args...) do {} while (0)
120 # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
121 /* disabled on purpose, _dl_debug_file should be guarded by __SUPPORT_LD_DEBUG__
122 # define _dl_debug_file 2*/
123 #endif /* __SUPPORT_LD_DEBUG__ */
125 #ifdef IS_IN_rtld
126 # ifdef __SUPPORT_LD_DEBUG__
127 # define _dl_assert(expr) \
128 do { \
129 if (!(expr)) { \
130 __dl_debug_dprint("assert(%s)\n", #expr); \
131 _dl_exit(45); \
133 } while (0)
134 # else
135 # define _dl_assert(expr) ((void)0)
136 # endif
137 #else
138 # include <assert.h>
139 # define _dl_assert(expr) assert(expr)
140 #endif
142 #ifdef __SUPPORT_LD_DEBUG_EARLY__
143 # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
144 #else
145 # define _dl_debug_early(fmt, args...) do {} while (0)
146 #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
148 #ifndef NULL
149 #define NULL ((void *) 0)
150 #endif
153 extern void *_dl_malloc(size_t size);
154 extern void *_dl_calloc(size_t __nmemb, size_t __size);
155 extern void *_dl_realloc(void *__ptr, size_t __size);
156 extern void _dl_free(void *);
157 extern char *_dl_getenv(const char *symbol, char **envp);
158 extern void _dl_unsetenv(const char *symbol, char **envp);
159 #ifdef IS_IN_rtld
160 extern char *_dl_strdup(const char *string);
161 extern void _dl_dprintf(int, const char *, ...);
162 #else
163 # include <string.h>
164 # define _dl_strdup strdup
165 # include <stdio.h>
166 # ifdef __USE_GNU
167 # define _dl_dprintf dprintf
168 # else
169 # define _dl_dprintf(fd, fmt, args...) fprintf(stderr, fmt, ## args)
170 # endif
171 #endif
173 #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
174 # define DL_GET_READY_TO_RUN_EXTRA_PARMS
175 #endif
176 #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
177 # define DL_GET_READY_TO_RUN_EXTRA_ARGS
178 #endif
180 extern void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
181 char **envp, char **argv
182 DL_GET_READY_TO_RUN_EXTRA_PARMS);
184 #ifdef HAVE_DL_INLINES_H
185 #include <dl-inlines.h>
186 #endif
188 #else /* __ARCH_HAS_NO_SHARED__ */
189 #include <dl-defs.h>
190 #include <dl-elf.h>
192 #endif
194 #define AUX_MAX_AT_ID 40
195 extern ElfW(auxv_t) _dl_auxvt[AUX_MAX_AT_ID];
197 void load_vdso(void *sys_info_ehdr, char **envp );
199 #endif /* _LDSO_H */