OSDN Git Service

Blackfin FD-PIC patches 5/6.
[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 #include <bits/wordsize.h>
31 /* Pull in the arch specific type information */
32 #include <sys/types.h>
33 /* Pull in the arch specific page size */
34 #include <bits/uClibc_page.h>
35 /* Pull in the ldso syscalls and string functions */
36 #include <dl-syscall.h>
37 #include <dl-string.h>
38 /* Now the ldso specific headers */
39 #include <dl-elf.h>
40 #include <dl-hash.h>
41
42 /* For INIT/FINI dependency sorting. */
43 struct init_fini_list {
44         struct init_fini_list *next;
45         struct elf_resolve *tpnt;
46 };
47
48 /* Global variables used within the shared library loader */
49 extern char *_dl_library_path;         /* Where we look for libraries */
50 extern char *_dl_preload;              /* Things to be loaded before the libs */
51 extern char *_dl_ldsopath;             /* Where the shared lib loader was found */
52 extern const char *_dl_progname;       /* The name of the executable being run */
53 extern int _dl_secure;                 /* Are we dealing with setuid stuff? */
54 extern size_t _dl_pagesize;            /* Store the page size for use later */
55
56 #ifdef __SUPPORT_LD_DEBUG__
57 extern char *_dl_debug;
58 extern char *_dl_debug_symbols;
59 extern char *_dl_debug_move;
60 extern char *_dl_debug_reloc;
61 extern char *_dl_debug_detail;
62 extern char *_dl_debug_nofixups;
63 extern char *_dl_debug_bindings;
64 extern int   _dl_debug_file;
65 # define __dl_debug_dprint(fmt, args...) \
66         _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __FUNCTION__, __LINE__, ## args);
67 # define _dl_if_debug_dprint(fmt, args...) \
68         do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)        
69 #else
70 # define __dl_debug_dprint(fmt, args...)
71 # define _dl_if_debug_dprint(fmt, args...)
72 # define _dl_debug_file 2
73 #endif /* __SUPPORT_LD_DEBUG__ */
74
75 #ifdef IS_IN_rtld
76 # ifdef __SUPPORT_LD_DEBUG__
77 #  define _dl_assert(expr)                                              \
78         do {                                                            \
79                 if (!(expr)) {                                          \
80                         __dl_debug_dprint("assert(%s)\n", #expr);       \
81                         _dl_exit(45);                                   \
82                 }                                                       \
83         } while (0)
84 # else
85 #  define _dl_assert(expr) ((void)0)
86 # endif
87 #else
88 # include <assert.h>
89 # define _dl_assert(expr) assert(expr)
90 #endif
91
92 #ifdef __SUPPORT_LD_DEBUG_EARLY__
93 # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
94 #else
95 # define _dl_debug_early(fmt, args...)
96 #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
97
98 #ifndef NULL
99 #define NULL ((void *) 0)
100 #endif
101
102 extern void *_dl_malloc(size_t size);
103 extern void _dl_free(void *);
104 extern char *_dl_getenv(const char *symbol, char **envp);
105 extern void _dl_unsetenv(const char *symbol, char **envp);
106 extern char *_dl_strdup(const char *string);
107 extern void _dl_dprintf(int, const char *, ...);
108
109 #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
110 # define DL_GET_READY_TO_RUN_EXTRA_PARMS
111 #endif
112 #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
113 # define DL_GET_READY_TO_RUN_EXTRA_ARGS
114 #endif
115
116 extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
117                 ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
118                 DL_GET_READY_TO_RUN_EXTRA_PARMS);
119
120 #endif /* _LDSO_H_ */