2 * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
4 * GNU Lesser General Public License version 2.1 or later.
12 #ifdef __ARCH_USE_MMU__
13 # define _MAP_UNINITIALIZED 0
15 # define _MAP_UNINITIALIZED MAP_UNINITIALIZED
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)
23 # define likely(x) __builtin_expect((!!(x)),1)
26 # define unlikely(x) __builtin_expect((!!(x)),0)
28 #ifndef __LINUX_COMPILER_H
29 #define __LINUX_COMPILER_H
32 /* Pull in compiler and arch stuff */
35 #include <stddef.h> /* for ptrdiff_t */
38 /* We need this if arch has only new syscalls defined */
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 #ifndef __ARCH_HAS_NO_SHARED__
52 #include <dl-syscall.h>
53 #include <dl-string.h>
54 /* Now the ldso specific headers */
56 #ifdef __UCLIBC_HAS_TLS__
62 /* common align masks, if not specified by sysdep headers */
64 #define ADDR_ALIGN (_dl_pagesize - 1)
68 #define PAGE_ALIGN (~ADDR_ALIGN)
72 #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
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 */
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 */
93 #define _dl_trace_prelink 0
96 extern void **_dl_ldso_dsbt
;
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);
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 int _dl_debug_file
;
113 # define __dl_debug_dprint(fmt, args...) \
114 _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __func__, __LINE__, ## args);
115 # define _dl_if_debug_dprint(fmt, args...) \
116 do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
118 # define __dl_debug_dprint(fmt, args...) do {} while (0)
119 # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
120 /* disabled on purpose, _dl_debug_file should be guarded by __SUPPORT_LD_DEBUG__
121 # define _dl_debug_file 2*/
122 #endif /* __SUPPORT_LD_DEBUG__ */
125 # ifdef __SUPPORT_LD_DEBUG__
126 # define _dl_assert(expr) \
129 __dl_debug_dprint("assert(%s)\n", #expr); \
134 # define _dl_assert(expr) ((void)0)
138 # define _dl_assert(expr) assert(expr)
141 #ifdef __SUPPORT_LD_DEBUG_EARLY__
142 # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
144 # define _dl_debug_early(fmt, args...) do {} while (0)
145 #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
148 #define NULL ((void *) 0)
151 extern void *_dl_malloc(size_t size
);
152 extern void *_dl_calloc(size_t __nmemb
, size_t __size
);
153 extern void *_dl_realloc(void *__ptr
, size_t __size
);
154 extern void _dl_free(void *);
155 extern char *_dl_getenv(const char *symbol
, char **envp
);
156 extern void _dl_unsetenv(const char *symbol
, char **envp
);
158 extern char *_dl_strdup(const char *string
);
159 extern void _dl_dprintf(int, const char *, ...);
162 # define _dl_strdup strdup
165 # define _dl_dprintf dprintf
167 # define _dl_dprintf(fd, fmt, args...) fprintf(stderr, fmt, ## args)
171 #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
172 # define DL_GET_READY_TO_RUN_EXTRA_PARMS
174 #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
175 # define DL_GET_READY_TO_RUN_EXTRA_ARGS
178 extern void *_dl_get_ready_to_run(struct elf_resolve
*tpnt
, DL_LOADADDR_TYPE load_addr
,
179 ElfW(auxv_t
) auxvt
[AT_EGID
+ 1], char **envp
, char **argv
180 DL_GET_READY_TO_RUN_EXTRA_PARMS
);
182 #ifdef HAVE_DL_INLINES_H
183 #include <dl-inlines.h>
186 #else /* __ARCH_HAS_NO_SHARED__ */