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
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
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 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	__RTLD_DB_H
28 #define	__RTLD_DB_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <proc_service.h>
33 #include <thread.h>
34 #include <synch.h>
35 #include <sgs.h>
36 #include <machdep.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 struct rd_agent {
43 	mutex_t				rd_mutex;
44 	struct ps_prochandle		*rd_psp;	/* prochandle pointer */
45 	psaddr_t			rd_rdebug;	/* rtld r_debug */
46 	psaddr_t			rd_preinit;	/* rtld_db_preinit */
47 	psaddr_t			rd_postinit;	/* rtld_db_postinit */
48 	psaddr_t			rd_dlact;	/* rtld_db_dlact */
49 	psaddr_t			rd_tbinder;	/* tail of binder */
50 	psaddr_t			rd_rtlddbpriv;	/* rtld rtld_db_priv */
51 	ulong_t				rd_flags;	/* flags */
52 	ulong_t				rd_rdebugvers;	/* rtld_db_priv.vers */
53 	int				rd_dmodel;	/* data model */
54 	rd_helper_t			rd_helper;	/* private to helper */
55 };
56 
57 /*
58  * Values for rd_flags
59  */
60 #define	RDF_FL_COREFILE		0x0001		/* client is core file image */
61 
62 
63 
64 #define	RDAGLOCK(x)	(void) mutex_lock(&(x->rd_mutex));
65 #define	RDAGUNLOCK(x)	(void) mutex_unlock(&(x->rd_mutex));
66 #define	LOG(func)	{						\
67 				(void) mutex_lock(&glob_mutex);		\
68 				if (rtld_db_logging)			\
69 					func;				\
70 				(void) mutex_unlock(&glob_mutex);	\
71 			}
72 
73 extern mutex_t		glob_mutex;
74 extern int		rtld_db_version;
75 extern int		rtld_db_logging;
76 
77 extern rd_err_e		rd_binder_exit_addr(struct rd_agent *, const char *,
78 				psaddr_t *);
79 extern rd_err_e		_rd_reset32(struct rd_agent *);
80 extern rd_err_e		_rd_event_enable32(rd_agent_t *, int);
81 extern rd_err_e		_rd_event_getmsg32(rd_agent_t *, rd_event_msg_t *);
82 extern rd_err_e		_rd_objpad_enable32(struct rd_agent *, size_t);
83 extern rd_err_e		_rd_loadobj_iter32(rd_agent_t *, rl_iter_f *, void *);
84 extern rd_err_e		find_dynamic_ent32(struct rd_agent *, psaddr_t,
85 			    Xword, Dyn *);
86 
87 extern rd_err_e		plt32_resolution(rd_agent_t *, psaddr_t, lwpid_t,
88 			    psaddr_t, rd_plt_info_t *);
89 #ifdef _LP64
90 extern rd_err_e		_rd_reset64(struct rd_agent *);
91 extern rd_err_e		_rd_event_enable64(rd_agent_t *, int);
92 extern rd_err_e		_rd_event_getmsg64(rd_agent_t *, rd_event_msg_t *);
93 extern rd_err_e		_rd_objpad_enable64(struct rd_agent *, size_t);
94 extern rd_err_e		_rd_loadobj_iter64(rd_agent_t *, rl_iter_f *, void *);
95 extern rd_err_e		find_dynamic_ent64(struct rd_agent *, psaddr_t,
96 			    Xword, Elf64_Dyn *);
97 extern rd_err_e		plt64_resolution(rd_agent_t *, psaddr_t, lwpid_t,
98 			    psaddr_t, rd_plt_info_t *);
99 #endif
100 
101 #ifdef	__cplusplus
102 }
103 #endif
104 
105 #endif /* __RTLD_DB_H */
106