xref: /illumos-gate/usr/src/boot/sys/sys/link_elf.h (revision 199767f8)
1*199767f8SToomas Soome /*-
2*199767f8SToomas Soome  * Copyright (c) 1993 Paul Kranenburg
3*199767f8SToomas Soome  * All rights reserved.
4*199767f8SToomas Soome  *
5*199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
6*199767f8SToomas Soome  * modification, are permitted provided that the following conditions
7*199767f8SToomas Soome  * are met:
8*199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
9*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
10*199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
11*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
12*199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
13*199767f8SToomas Soome  * 3. All advertising materials mentioning features or use of this software
14*199767f8SToomas Soome  *    must display the following acknowledgement:
15*199767f8SToomas Soome  *      This product includes software developed by Paul Kranenburg.
16*199767f8SToomas Soome  * 4. The name of the author may not be used to endorse or promote products
17*199767f8SToomas Soome  *    derived from this software without specific prior written permission
18*199767f8SToomas Soome  *
19*199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20*199767f8SToomas Soome  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21*199767f8SToomas Soome  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22*199767f8SToomas Soome  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23*199767f8SToomas Soome  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24*199767f8SToomas Soome  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25*199767f8SToomas Soome  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26*199767f8SToomas Soome  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27*199767f8SToomas Soome  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28*199767f8SToomas Soome  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*199767f8SToomas Soome  *
30*199767f8SToomas Soome  * $FreeBSD$
31*199767f8SToomas Soome  */
32*199767f8SToomas Soome 
33*199767f8SToomas Soome /*
34*199767f8SToomas Soome  * RRS section definitions.
35*199767f8SToomas Soome  *
36*199767f8SToomas Soome  * The layout of some data structures defined in this header file is
37*199767f8SToomas Soome  * such that we can provide compatibility with the SunOS 4.x shared
38*199767f8SToomas Soome  * library scheme.
39*199767f8SToomas Soome  */
40*199767f8SToomas Soome 
41*199767f8SToomas Soome #ifndef _SYS_LINK_ELF_H_
42*199767f8SToomas Soome #define	_SYS_LINK_ELF_H_
43*199767f8SToomas Soome 
44*199767f8SToomas Soome #include <sys/elf.h>
45*199767f8SToomas Soome 
46*199767f8SToomas Soome /*
47*199767f8SToomas Soome  * Flags that describe the origin of the entries in Dl_serinfo.
48*199767f8SToomas Soome  * SunOS has these in <sys/link.h>, we follow the suit.
49*199767f8SToomas Soome  */
50*199767f8SToomas Soome #define	LA_SER_ORIG	0x01	/* original (needed) name */
51*199767f8SToomas Soome #define	LA_SER_LIBPATH	0x02	/* LD_LIBRARY_PATH entry prepended */
52*199767f8SToomas Soome #define	LA_SER_RUNPATH	0x04	/* runpath entry prepended */
53*199767f8SToomas Soome #define	LA_SER_CONFIG	0x08	/* configuration entry prepended */
54*199767f8SToomas Soome #define	LA_SER_DEFAULT	0x40	/* default path prepended */
55*199767f8SToomas Soome #define	LA_SER_SECURE	0x80	/* default (secure) path prepended */
56*199767f8SToomas Soome 
57*199767f8SToomas Soome typedef struct link_map {
58*199767f8SToomas Soome 	caddr_t		l_addr;			/* Base Address of library */
59*199767f8SToomas Soome #ifdef __mips__
60*199767f8SToomas Soome 	caddr_t		l_offs;			/* Load Offset of library */
61*199767f8SToomas Soome #endif
62*199767f8SToomas Soome 	const char	*l_name;		/* Absolute Path to Library */
63*199767f8SToomas Soome 	const void	*l_ld;			/* Pointer to .dynamic in memory */
64*199767f8SToomas Soome 	struct link_map	*l_next, *l_prev;	/* linked list of of mapped libs */
65*199767f8SToomas Soome } Link_map;
66*199767f8SToomas Soome 
67*199767f8SToomas Soome struct r_debug {
68*199767f8SToomas Soome 	int		r_version;		/* not used */
69*199767f8SToomas Soome 	struct link_map *r_map;			/* list of loaded images */
70*199767f8SToomas Soome 	void		(*r_brk)(struct r_debug *, struct link_map *);
71*199767f8SToomas Soome 						/* pointer to break point */
72*199767f8SToomas Soome 	enum {
73*199767f8SToomas Soome 		RT_CONSISTENT,			/* things are stable */
74*199767f8SToomas Soome 		RT_ADD,				/* adding a shared library */
75*199767f8SToomas Soome 		RT_DELETE			/* removing a shared library */
76*199767f8SToomas Soome 	}		r_state;
77*199767f8SToomas Soome };
78*199767f8SToomas Soome 
79*199767f8SToomas Soome struct dl_phdr_info
80*199767f8SToomas Soome {
81*199767f8SToomas Soome 	Elf_Addr dlpi_addr;			/* module relocation base */
82*199767f8SToomas Soome 	const char *dlpi_name;			/* module name */
83*199767f8SToomas Soome 	const Elf_Phdr *dlpi_phdr;		/* pointer to module's phdr */
84*199767f8SToomas Soome 	Elf_Half dlpi_phnum;			/* number of entries in phdr */
85*199767f8SToomas Soome 	unsigned long long int dlpi_adds;	/* total # of loads */
86*199767f8SToomas Soome 	unsigned long long int dlpi_subs;	/* total # of unloads */
87*199767f8SToomas Soome 	size_t dlpi_tls_modid;
88*199767f8SToomas Soome 	void *dlpi_tls_data;
89*199767f8SToomas Soome };
90*199767f8SToomas Soome 
91*199767f8SToomas Soome __BEGIN_DECLS
92*199767f8SToomas Soome 
93*199767f8SToomas Soome typedef int (*__dl_iterate_hdr_callback)(struct dl_phdr_info *, size_t, void *);
94*199767f8SToomas Soome extern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
95*199767f8SToomas Soome int _rtld_addr_phdr(const void *, struct dl_phdr_info *);
96*199767f8SToomas Soome int _rtld_get_stack_prot(void);
97*199767f8SToomas Soome int _rtld_is_dlopened(void *);
98*199767f8SToomas Soome 
99*199767f8SToomas Soome #ifdef __ARM_EABI__
100*199767f8SToomas Soome void * dl_unwind_find_exidx(const void *, int *);
101*199767f8SToomas Soome #endif
102*199767f8SToomas Soome 
103*199767f8SToomas Soome __END_DECLS
104*199767f8SToomas Soome 
105*199767f8SToomas Soome #endif /* _SYS_LINK_ELF_H_ */
106