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