link.h (22872efb9462b28180d11ea401344608e641a5aa) link.h (20272c2e66d77f79ef35e7160584b5d098c3287f)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef _LINK_H
27#define _LINK_H
28
23 * Use is subject to license terms.
24 */
25
26#ifndef _LINK_H
27#define _LINK_H
28
29#pragma ident "%Z%%M% %I% %E% SMI"
30
31#include <sys/link.h>
32
33#ifndef _ASM
34#include <libelf.h>
35#include <sys/types.h>
36#include <dlfcn.h>
37#endif
38

--- 223 unchanged lines hidden (view full) ---

262extern uintptr_t la_sparcv8_pltenter();
263extern uintptr_t la_i86_pltenter();
264extern uintptr_t la_pltexit();
265extern uintptr_t la_symbind32();
266#endif /* _LP64 */
267#endif /* __STDC__ */
268
269
29#include <sys/link.h>
30
31#ifndef _ASM
32#include <libelf.h>
33#include <sys/types.h>
34#include <dlfcn.h>
35#endif
36

--- 223 unchanged lines hidden (view full) ---

260extern uintptr_t la_sparcv8_pltenter();
261extern uintptr_t la_i86_pltenter();
262extern uintptr_t la_pltexit();
263extern uintptr_t la_symbind32();
264#endif /* _LP64 */
265#endif /* __STDC__ */
266
267
270#endif /* _ASM */
268/*
269 * The ElfW() macro is a GNU/Linux feature, provided as support for
270 * the dl_phdr_info structure used by dl_phdr_iterate(), which also
271 * originated under Linux. Given an ELF data type, without the ElfXX_
272 * prefix, it supplies the appropriate prefix (Elf32_ or Elf64_) for
273 * the ELFCLASS of the code being compiled.
274 *
275 * Note that ElfW() is not suitable in situations in which the ELFCLASS
276 * of the code being compiled does not match that of the objects that
277 * code is intended to operate on (e.g. a 32-bit link-editor building
278 * a 64-bit object). The macros defined in <sys/machelf.h> are
279 * recommended in such cases.
280 */
281#ifdef _LP64
282#define ElfW(type) Elf64_ ## type
283#else
284#define ElfW(type) Elf32_ ## type
285#endif
286
287/*
288 * The callback function to dl_interate_phdr() receives a pointer
289 * to a structure of this type.
290 *
291 * dlpi_addr is defined such that the address of any segment in
292 * the program header array can be calculated as:
293 *
294 * addr == info->dlpi_addr + info->dlpi_phdr[x].p_vaddr;
295 *
296 * It is therefore 0 for ET_EXEC objects, and the base address at
297 * which the object is mapped otherwise.
298 */
299struct dl_phdr_info {
300 ElfW(Addr) dlpi_addr; /* Base address of object */
301 const char *dlpi_name; /* Null-terminated obj name */
302 const ElfW(Phdr) *dlpi_phdr; /* Ptr to ELF program hdr arr */
303 ElfW(Half) dlpi_phnum; /* # of items in dlpi_phdr[] */
304
305 /*
306 * Note: Following members were introduced after the first version
307 * of this structure was available. The dl_iterate_phdr() callback
308 * function is passed a 'size' argument giving the size of the info
309 * structure, and must compare that size to the offset of these fields
310 * before accessing them to ensure that they are present.
311 */
312
313 /* Incremented when a new object is mapped into the process */
314 u_longlong_t dlpi_adds;
315 /* Incremented when an object is unmapped from the process */
316 u_longlong_t dlpi_subs;
317};
318
319extern int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
320 void *);
321
322#endif /* _ASM */
271#endif /* _KERNEL */
272
323#endif /* _KERNEL */
324
325
273#ifdef __cplusplus
274}
275#endif
276
277#endif /* _LINK_H */
326#ifdef __cplusplus
327}
328#endif
329
330#endif /* _LINK_H */