1 /* vi: set sw=4 ts=4: */
3 * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
5 * GNU Lesser General Public License version 2.1 or later.
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
30 #define LIB_ELF64 0x80
31 #define LIB_ELF_LIBC5 2
32 #define LIB_ELF_LIBC6 3
33 #define LIB_ELF_LIBC0 4
35 #if defined(__LDSO_PRELOAD_FILE_SUPPORT__) || defined(__LDSO_CACHE_SUPPORT__)
36 #ifndef __LDSO_BASE_FILENAME__
37 #define __LDSO_BASE_FILENAME__ "ld.so"
39 #define LDSO_BASE_PATH UCLIBC_RUNTIME_PREFIX "etc/" __LDSO_BASE_FILENAME__
41 #ifdef __LDSO_PRELOAD_FILE_SUPPORT__
42 #define LDSO_PRELOAD LDSO_BASE_PATH ".preload"
45 #ifdef __LDSO_CACHE_SUPPORT__
46 #define LDSO_CONF LDSO_BASE_PATH ".conf"
47 #define LDSO_CACHE LDSO_BASE_PATH ".cache"
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)
55 char magic [LDSO_CACHE_MAGIC_LEN];
56 char version [LDSO_CACHE_VER_LEN];
65 #endif /* __LDSO_CACHE_SUPPORT__ */
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.
74 #ifndef DL_LOADADDR_TYPE
75 # define DL_LOADADDR_TYPE ElfW(Addr)
78 /* When DL_LOADADDR_TYPE is not a scalar value, or some different
79 * computation is needed to relocate an address, define this.
82 # define DL_RELOC_ADDR(LOADADDR, ADDR) \
86 /* Initialize a LOADADDR representing the loader itself. It's only
87 * called from DL_BOOT, so additional arguments passed to it may be
90 #ifndef DL_INIT_LOADADDR_BOOT
91 # define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
92 ((LOADADDR) = (BASEADDR))
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.
100 #ifndef DL_INIT_LOADADDR_EXTRA_DECLS
101 # define DL_INIT_LOADADDR_EXTRA_DECLS /* int i; */
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.
108 #ifndef DL_INIT_LOADADDR
109 # define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
110 ((LOADADDR) = (BASEADDR))
113 /* Initialize a LOADADDR representing the program. It's called from
116 #ifndef DL_INIT_LOADADDR_PROG
117 # define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
118 ((LOADADDR) = (DL_LOADADDR_TYPE)(BASEADDR))
121 /* Convert a DL_LOADADDR_TYPE to an identifying pointer. Used mostly
124 #ifndef DL_LOADADDR_BASE
125 # define DL_LOADADDR_BASE(LOADADDR) (LOADADDR)
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.
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))
143 #endif /* _LD_DEFS_H */