xref: /titanic_50/usr/src/cmd/sgs/liblddbg/common/tls.c (revision 004388ebfdfe2ed7dfd2d153a876dfcc22d2c006)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include	<link.h>
30 #include	<libc_int.h>
31 #include	<rtld.h>
32 #include	<debug.h>
33 #include	"msg.h"
34 #include	"_debug.h"
35 
36 static void
37 Dbg_tls_modent(Lm_list *lml, TLS_modinfo * tmodent)
38 {
39 	dbg_print(lml, MSG_INTL(MSG_TLS_STMODENT1),
40 	    EC_XWORD((uintptr_t)tmodent->tm_tlsblock),
41 	    EC_XWORD(tmodent->tm_stattlsoffset), EC_XWORD(tmodent->tm_flags));
42 	dbg_print(lml, MSG_INTL(MSG_TLS_STMODENT2),
43 	    EC_XWORD(tmodent->tm_filesz), EC_XWORD(tmodent->tm_memsz),
44 	    EC_XWORD(tmodent->tm_modid));
45 }
46 
47 void
48 Dbg_tls_static_block(Lm_list *lml, void *vtlsmodlist, ulong_t tlsstatsize)
49 {
50 	uint_t		i;
51 	TLS_modinfo **	tlsmodlist;
52 
53 	if (DBG_NOTCLASS(DBG_C_TLS))
54 		return;
55 
56 	tlsmodlist = (TLS_modinfo **)vtlsmodlist;
57 	Dbg_util_nl(lml, DBG_NL_STD);
58 
59 	for (i = 0; tlsmodlist[i]; i++) {
60 		dbg_print(lml, MSG_INTL(MSG_TLS_STATBLOCK1), i,
61 		    tlsmodlist[i]->tm_modname);
62 		Dbg_tls_modent(lml, tlsmodlist[i]);
63 	}
64 	dbg_print(lml, MSG_INTL(MSG_TLS_STATBLOCK2), EC_XWORD(tlsstatsize));
65 }
66 
67 void
68 Dbg_tls_modactivity(Lm_list *lml, void *vtlsmodent, uint_t flag)
69 {
70 	const char	*str;
71 	TLS_modinfo	*tlsmodent;
72 
73 	if (DBG_NOTCLASS(DBG_C_TLS))
74 		return;
75 
76 	if (flag == TM_FLG_MODADD)
77 		str = MSG_INTL(MSG_TLS_ADD);
78 	else
79 		str = MSG_INTL(MSG_TLS_REMOVE);
80 
81 	tlsmodent = (TLS_modinfo *)vtlsmodent;
82 	Dbg_util_nl(lml, DBG_NL_STD);
83 	dbg_print(lml, MSG_INTL(MSG_TLS_MODACT), str, tlsmodent->tm_modname);
84 	Dbg_tls_modent(lml, tlsmodent);
85 }
86