Print this page
3263 link.h should work in a largefile environment
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/link.h
+++ new/usr/src/head/link.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
21 21 /*
22 22 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 25 #ifndef _LINK_H
26 26 #define _LINK_H
27 27
28 28 #include <sys/link.h>
29 29
30 30 #ifndef _ASM
31 -#include <libelf.h>
31 +#include <elf.h>
32 32 #include <sys/types.h>
33 33 #include <dlfcn.h>
34 34 #endif
35 35
36 36 #ifdef __cplusplus
37 37 extern "C" {
38 38 #endif
39 39
40 40 #ifndef _ASM
41 41 /*
42 - * ld support library calls
42 + * ld support library calls.
43 + *
44 + * These cannot be used in a 32bit large file capable environment,
45 + * thanks to the use of libelf.
43 46 */
47 +#if !defined(_ILP32) || _FILE_OFFSET_BITS != 64
44 48 #ifdef __STDC__
49 +#include <libelf.h>
45 50 extern uint_t ld_version(uint_t);
46 51 extern void ld_input_done(uint_t *);
47 52
48 53 extern void ld_start(const char *, const Elf32_Half, const char *);
49 54 extern void ld_atexit(int);
50 55 extern void ld_open(const char **, const char **, int *, int, Elf **,
51 56 Elf *, size_t, const Elf_Kind);
52 57 extern void ld_file(const char *, const Elf_Kind, int, Elf *);
53 58 extern void ld_input_section(const char *, Elf32_Shdr **, Elf32_Word,
54 59 Elf_Data *, Elf *, uint_t *);
55 60 extern void ld_section(const char *, Elf32_Shdr *, Elf32_Word,
56 61 Elf_Data *, Elf *);
57 62
58 63 #if defined(_LP64) || defined(_LONGLONG_TYPE)
59 64 extern void ld_start64(const char *, const Elf64_Half, const char *);
60 65 extern void ld_atexit64(int);
61 66 extern void ld_open64(const char **, const char **, int *, int, Elf **,
62 67 Elf *, size_t, const Elf_Kind);
63 68 extern void ld_file64(const char *, const Elf_Kind, int, Elf *);
64 69 extern void ld_input_section64(const char *, Elf64_Shdr **, Elf64_Word,
65 70 Elf_Data *, Elf *, uint_t *);
66 71 extern void ld_section64(const char *, Elf64_Shdr *, Elf64_Word,
67 72 Elf_Data *, Elf *);
68 73
69 74 #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
70 75 #else
71 76 extern void ld_version();
72 77 extern void ld_input_done();
73 78
74 79 extern void ld_start();
75 80 extern void ld_atexit();
76 81 extern void ld_open();
77 82 extern void ld_file();
78 83 extern void ld_input_section();
79 84 extern void ld_section();
80 85
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
81 86 #if defined(_LP64) || defined(_LONGLONG_TYPE)
82 87 extern void ld_start64();
83 88 extern void ld_atexit64();
84 89 extern void ld_open64();
85 90 extern void ld_file64();
86 91 extern void ld_input_section64();
87 92 extern void ld_section64();
88 93
89 94 #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
90 95 #endif /* __STDC__ */
96 +#endif /* !defined(_ILP32) || _FILE_OFFSET_BITS != 64 */
91 97
92 98 /*
93 99 * ld_version() version values.
94 100 */
95 101 #define LD_SUP_VNONE 0
96 102 #define LD_SUP_VERSION1 1
97 103 #define LD_SUP_VERSION2 2
98 104 #define LD_SUP_VERSION3 3
99 105 #define LD_SUP_VCURRENT LD_SUP_VERSION3
100 106
101 107 /*
102 108 * Flags passed to ld support calls.
103 109 */
104 110 #define LD_SUP_DERIVED 0x1 /* derived filename */
105 111 #define LD_SUP_INHERITED 0x2 /* file inherited from .so DT_NEEDED */
106 112 #define LD_SUP_EXTRACTED 0x4 /* file extracted from archive */
107 113 #endif
108 114
109 115 /*
110 116 * Runtime link-map identifiers.
111 117 */
112 118 #define LM_ID_BASE 0x00
113 119 #define LM_ID_LDSO 0x01
114 120 #define LM_ID_NUM 2
115 121
116 122 #define LM_ID_BRAND 0xfd /* brand emulation linkmap objs */
117 123 #define LM_ID_NONE 0xfe /* no link map specified */
118 124 #define LM_ID_NEWLM 0xff /* create a new link-map */
119 125
120 126 /*
121 127 * Runtime Link-Edit Auditing.
122 128 */
123 129 #define LAV_NONE 0
124 130 #define LAV_VERSION1 1
125 131 #define LAV_VERSION2 2
126 132 #define LAV_VERSION3 3
127 133 #define LAV_VERSION4 4
128 134 #define LAV_VERSION5 5
129 135 #define LAV_CURRENT LAV_VERSION5
130 136 #define LAV_NUM 6
131 137
132 138 /*
133 139 * Flags that can be or'd into the la_objopen() return code
134 140 */
135 141 #define LA_FLG_BINDTO 0x0001 /* audit symbinds TO this object */
136 142 #define LA_FLG_BINDFROM 0x0002 /* audit symbinding FROM this object */
137 143
138 144 /*
139 145 * Flags that can be or'd into the 'flags' argument of la_symbind()
140 146 */
141 147 #define LA_SYMB_NOPLTENTER 0x0001 /* disable pltenter for this symbol */
142 148 #define LA_SYMB_NOPLTEXIT 0x0002 /* disable pltexit for this symbol */
143 149 #define LA_SYMB_STRUCTCALL 0x0004 /* this function call passes a */
144 150 /* structure as it's return code */
145 151 #define LA_SYMB_DLSYM 0x0008 /* this symbol bindings is due to */
146 152 /* a call to dlsym() */
147 153 #define LA_SYMB_ALTVALUE 0x0010 /* alternate symbol binding returned */
148 154 /* by la_symbind() */
149 155
150 156 /*
151 157 * Flags that describe the object passed to la_objsearch()
152 158 */
153 159 #define LA_SER_ORIG 0x001 /* original (needed) name */
154 160 #define LA_SER_LIBPATH 0x002 /* LD_LIBRARY_PATH entry prepended */
155 161 #define LA_SER_RUNPATH 0x004 /* runpath entry prepended */
156 162 #define LA_SER_CONFIG 0x008 /* configuration entry prepended */
157 163 #define LA_SER_DEFAULT 0x040 /* default path prepended */
158 164 #define LA_SER_SECURE 0x080 /* default (secure) path prepended */
159 165
160 166 #define LA_SER_MASK 0xfff /* mask of known flags */
161 167
162 168 /*
163 169 * Flags that describe the la_activity()
164 170 */
165 171 #define LA_ACT_CONSISTENT 0x00 /* add/deletion of objects complete */
166 172 #define LA_ACT_ADD 0x01 /* objects being added */
167 173 #define LA_ACT_DELETE 0x02 /* objects being deleted */
168 174 #define LA_ACT_MAX 3
169 175
170 176
171 177 #ifndef _KERNEL
172 178 #ifndef _ASM
173 179
174 180 #if defined(_LP64)
175 181 typedef long lagreg_t;
176 182 #else
177 183 typedef int lagreg_t;
178 184 #endif
179 185
180 186 struct _la_sparc_regs {
181 187 lagreg_t lr_rego0;
182 188 lagreg_t lr_rego1;
183 189 lagreg_t lr_rego2;
184 190 lagreg_t lr_rego3;
185 191 lagreg_t lr_rego4;
186 192 lagreg_t lr_rego5;
187 193 lagreg_t lr_rego6;
188 194 lagreg_t lr_rego7;
189 195 };
190 196
191 197 #if defined(_LP64)
192 198 typedef struct _la_sparc_regs La_sparcv9_regs;
193 199 typedef struct {
194 200 lagreg_t lr_rsp;
195 201 lagreg_t lr_rbp;
196 202 lagreg_t lr_rdi; /* arg1 */
197 203 lagreg_t lr_rsi; /* arg2 */
198 204 lagreg_t lr_rdx; /* arg3 */
199 205 lagreg_t lr_rcx; /* arg4 */
200 206 lagreg_t lr_r8; /* arg5 */
201 207 lagreg_t lr_r9; /* arg6 */
202 208 } La_amd64_regs;
203 209 #else
204 210 typedef struct _la_sparc_regs La_sparcv8_regs;
205 211 typedef struct {
206 212 lagreg_t lr_esp;
207 213 lagreg_t lr_ebp;
208 214 } La_i86_regs;
209 215 #endif
210 216
211 217 #if !defined(_SYS_INT_TYPES_H)
212 218 #if defined(_LP64) || defined(_I32LPx)
213 219 typedef unsigned long uintptr_t;
214 220 #else
215 221 typedef unsigned int uintptr_t;
216 222 #endif
217 223 #endif
218 224
219 225
220 226 #ifdef __STDC__
221 227 extern uint_t la_version(uint_t);
222 228 extern void la_activity(uintptr_t *, uint_t);
223 229 extern void la_preinit(uintptr_t *);
224 230 extern char *la_objsearch(const char *, uintptr_t *, uint_t);
225 231 extern uint_t la_objopen(Link_map *, Lmid_t, uintptr_t *);
226 232 extern uint_t la_objclose(uintptr_t *);
227 233 extern int la_objfilter(uintptr_t *, const char *, uintptr_t *,
228 234 uint_t);
229 235 #if defined(_LP64)
230 236 extern uintptr_t la_amd64_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
231 237 uintptr_t *, La_amd64_regs *, uint_t *,
232 238 const char *);
233 239 extern uintptr_t la_symbind64(Elf64_Sym *, uint_t, uintptr_t *,
234 240 uintptr_t *, uint_t *, const char *);
235 241 extern uintptr_t la_sparcv9_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
236 242 uintptr_t *, La_sparcv9_regs *, uint_t *,
237 243 const char *);
238 244 extern uintptr_t la_pltexit64(Elf64_Sym *, uint_t, uintptr_t *,
239 245 uintptr_t *, uintptr_t, const char *);
240 246 #else /* !defined(_LP64) */
241 247 extern uintptr_t la_symbind32(Elf32_Sym *, uint_t, uintptr_t *,
242 248 uintptr_t *, uint_t *);
243 249 extern uintptr_t la_sparcv8_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
244 250 uintptr_t *, La_sparcv8_regs *, uint_t *);
245 251 extern uintptr_t la_i86_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
246 252 uintptr_t *, La_i86_regs *, uint_t *);
247 253 extern uintptr_t la_pltexit(Elf32_Sym *, uint_t, uintptr_t *,
248 254 uintptr_t *, uintptr_t);
249 255 #endif /* _LP64 */
250 256 #else /* __STDC__ */
251 257 extern uint_t la_version();
252 258 extern void la_preinit();
253 259 extern uint_t la_objopen();
254 260 extern uint_t la_objclose();
255 261 extern int la_objfilter();
256 262 #if defined(_LP64)
257 263 extern uintptr_t la_sparcv9_pltenter();
258 264 extern uintptr_t la_pltexit64();
259 265 extern uintptr_t la_symbind64();
260 266 #else /* _ILP32 */
261 267 extern uintptr_t la_sparcv8_pltenter();
262 268 extern uintptr_t la_i86_pltenter();
263 269 extern uintptr_t la_pltexit();
264 270 extern uintptr_t la_symbind32();
265 271 #endif /* _LP64 */
266 272 #endif /* __STDC__ */
267 273
268 274 #ifdef __STDC__
269 275 /*
270 276 * The ElfW() macro is a GNU/Linux feature, provided as support for
271 277 * the dl_phdr_info structure used by dl_phdr_iterate(), which also
272 278 * originated under Linux. Given an ELF data type, without the ElfXX_
273 279 * prefix, it supplies the appropriate prefix (Elf32_ or Elf64_) for
274 280 * the ELFCLASS of the code being compiled.
275 281 *
276 282 * Note that ElfW() is not suitable in situations in which the ELFCLASS
277 283 * of the code being compiled does not match that of the objects that
278 284 * code is intended to operate on (e.g. a 32-bit link-editor building
279 285 * a 64-bit object). The macros defined in <sys/machelf.h> are
280 286 * recommended in such cases.
281 287 */
282 288 #ifdef _LP64
283 289 #define ElfW(type) Elf64_ ## type
284 290 #else
285 291 #define ElfW(type) Elf32_ ## type
286 292 #endif
287 293
288 294 /*
289 295 * The callback function to dl_interate_phdr() receives a pointer
290 296 * to a structure of this type.
291 297 *
292 298 * dlpi_addr is defined such that the address of any segment in
293 299 * the program header array can be calculated as:
294 300 *
295 301 * addr == info->dlpi_addr + info->dlpi_phdr[x].p_vaddr;
296 302 *
297 303 * It is therefore 0 for ET_EXEC objects, and the base address at
298 304 * which the object is mapped otherwise.
299 305 */
300 306 struct dl_phdr_info {
301 307 ElfW(Addr) dlpi_addr; /* Base address of object */
302 308 const char *dlpi_name; /* Null-terminated obj name */
303 309 const ElfW(Phdr) *dlpi_phdr; /* Ptr to ELF program hdr arr */
304 310 ElfW(Half) dlpi_phnum; /* # of items in dlpi_phdr[] */
305 311
306 312 /*
307 313 * Note: Following members were introduced after the first version
308 314 * of this structure was available. The dl_iterate_phdr() callback
309 315 * function is passed a 'size' argument giving the size of the info
310 316 * structure, and must compare that size to the offset of these fields
311 317 * before accessing them to ensure that they are present.
312 318 */
313 319
314 320 /* Incremented when a new object is mapped into the process */
315 321 u_longlong_t dlpi_adds;
316 322 /* Incremented when an object is unmapped from the process */
317 323 u_longlong_t dlpi_subs;
318 324 };
319 325
320 326 extern int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
321 327 void *);
322 328 #endif /* __STDC__ */
323 329
324 330 #endif /* _ASM */
325 331 #endif /* _KERNEL */
326 332
327 333
328 334 #ifdef __cplusplus
329 335 }
330 336 #endif
331 337
332 338 #endif /* _LINK_H */
↓ open down ↓ |
232 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX