OSDN Git Service

932f6ac531f4284792b7756e467c6e7e61350c5e
[uclinux-h8/uClibc.git] / ldso / include / dl-defs.h
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
4  *
5  * GNU Lesser General Public License version 2.1 or later.
6  */
7
8 #ifndef _LD_DEFS_H
9 #define _LD_DEFS_H
10
11 #define FLAG_ANY             -1
12 #define FLAG_TYPE_MASK       0x00ff
13 #define FLAG_LIBC4           0x0000
14 #define FLAG_ELF             0x0001
15 #define FLAG_ELF_LIBC5       0x0002
16 #define FLAG_ELF_LIBC6       0x0003
17 #define FLAG_ELF_UCLIBC      0x0004
18 #define FLAG_REQUIRED_MASK   0xff00
19 #define FLAG_SPARC_LIB64     0x0100
20 #define FLAG_IA64_LIB64      0x0200
21 #define FLAG_X8664_LIB64     0x0300
22 #define FLAG_S390_LIB64      0x0400
23 #define FLAG_POWERPC_LIB64   0x0500
24 #define FLAG_MIPS64_LIBN32   0x0600
25 #define FLAG_MIPS64_LIBN64   0x0700
26
27 #define LIB_ANY      -1
28 #define LIB_DLL       0
29 #define LIB_ELF       1
30 #define LIB_ELF64     0x80
31 #define LIB_ELF_LIBC5 2
32 #define LIB_ELF_LIBC6 3
33 #define LIB_ELF_LIBC0 4
34
35 #if defined(__LDSO_PRELOAD_FILE_SUPPORT__) || defined(__LDSO_CACHE_SUPPORT__)
36 #ifndef __LDSO_BASE_FILENAME__
37 #define __LDSO_BASE_FILENAME__ "ld.so"
38 #endif
39 #define LDSO_BASE_PATH UCLIBC_RUNTIME_PREFIX "etc/" __LDSO_BASE_FILENAME__
40
41 #ifdef __LDSO_PRELOAD_FILE_SUPPORT__
42 #define LDSO_PRELOAD LDSO_BASE_PATH ".preload"
43 #endif
44
45 #ifdef __LDSO_CACHE_SUPPORT__
46 #define LDSO_CONF    LDSO_BASE_PATH ".conf"
47 #define LDSO_CACHE   LDSO_BASE_PATH ".cache"
48
49 #define LDSO_CACHE_MAGIC "ld.so-"
50 #define LDSO_CACHE_MAGIC_LEN (sizeof LDSO_CACHE_MAGIC -1)
51 #define LDSO_CACHE_VER "1.7.0"
52 #define LDSO_CACHE_VER_LEN (sizeof LDSO_CACHE_VER -1)
53
54 typedef struct {
55         char magic   [LDSO_CACHE_MAGIC_LEN];
56         char version [LDSO_CACHE_VER_LEN];
57         int nlibs;
58 } header_t;
59
60 typedef struct {
61         int flags;
62         int sooffset;
63         int liboffset;
64 } libentry_t;
65 #endif  /* __LDSO_CACHE_SUPPORT__ */
66
67 #endif
68
69 /* Machines in which different sections may be relocated by different
70  * amounts should define this and LD_RELOC_ADDR.  If you change this,
71  * make sure you change struct link_map in include/link.h accordingly
72  * such that it matches a prefix of struct elf_resolve.
73  */
74 #ifndef DL_LOADADDR_TYPE
75 # define DL_LOADADDR_TYPE ElfW(Addr)
76 #endif
77
78 /* When DL_LOADADDR_TYPE is not a scalar value, or some different
79  * computation is needed to relocate an address, define this.
80  */
81 #ifndef DL_RELOC_ADDR
82 # define DL_RELOC_ADDR(LOADADDR, ADDR) \
83         ((LOADADDR) + (ADDR))
84 #endif
85
86 /* Initialize a LOADADDR representing the loader itself.  It's only
87  * called from DL_BOOT, so additional arguments passed to it may be
88  * referenced.
89  */
90 #ifndef DL_INIT_LOADADDR_BOOT
91 # define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
92         ((LOADADDR) = (BASEADDR))
93 #endif
94
95 /* Define if any declarations/definitions of local variables are
96  * needed in a function that calls DT_INIT_LOADADDR or
97  * DL_INIT_LOADADDR_HDR.  Declarations must be properly terminated
98  * with a semicolon, and non-declaration statements are forbidden.
99  */
100 #ifndef DL_INIT_LOADADDR_EXTRA_DECLS
101 # define DL_INIT_LOADADDR_EXTRA_DECLS /* int i; */
102 #endif
103
104 /* Prepare a DL_LOADADDR_TYPE data structure for incremental
105  * initialization with DL_INIT_LOADADDR_HDR, given pointers to a base
106  * load address and to program headers.
107  */
108 #ifndef DL_INIT_LOADADDR
109 # define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
110         ((LOADADDR) = (BASEADDR))
111 #endif
112
113 /* Initialize a LOADADDR representing the program.  It's called from
114  * DL_BOOT only.
115  */
116 #ifndef DL_INIT_LOADADDR_PROG
117 # define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
118         ((LOADADDR) = (DL_LOADADDR_TYPE)(BASEADDR))
119 #endif
120
121 /* Convert a DL_LOADADDR_TYPE to an identifying pointer.  Used mostly
122  * for debugging.
123  */
124 #ifndef DL_LOADADDR_BASE
125 # define DL_LOADADDR_BASE(LOADADDR) (LOADADDR)
126 #endif
127
128 /* Test whether a given ADDR is more likely to be within the memory
129  * region mapped to TPNT (a struct elf_resolve *) than to TFROM.
130  * Everywhere that this is used, TFROM is initially NULL, and whenever
131  * a potential match is found, it's updated.  One might want to walk
132  * the chain of elf_resolve to locate the best match and return false
133  * whenever TFROM is non-NULL, or use an exact-matching algorithm
134  * using additional information encoded in DL_LOADADDR_TYPE to test
135  * for exact containment.
136  */
137 #ifndef DL_ADDR_IN_LOADADDR
138 # define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
139         ((void*)(TPNT)->loadaddr < (void*)(ADDR) \
140          && (!(TFROM) || (TFROM)->loadaddr < (TPNT)->loadaddr))
141 #endif
142
143 #endif  /* _LD_DEFS_H */