xref: /titanic_50/usr/src/cmd/sgs/liblddbg/common/tls.c (revision ea8dc4b6d2251b437950c0056bc626b311c73c27)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 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	<stdio.h>
31 #include	<libc_int.h>
32 #include	<rtld.h>
33 #include	"msg.h"
34 #include	"_debug.h"
35 
36 static void
37 tls_modent(TLS_modinfo * tmodent)
38 {
39 	dbg_print(MSG_INTL(MSG_TLS_STMODENT1),
40 		EC_XWORD((uintptr_t)tmodent->tm_tlsblock),
41 		EC_XWORD(tmodent->tm_stattlsoffset),
42 		EC_XWORD(tmodent->tm_flags));
43 	dbg_print(MSG_INTL(MSG_TLS_STMODENT2),
44 		EC_XWORD(tmodent->tm_filesz),
45 		EC_XWORD(tmodent->tm_memsz),
46 		EC_XWORD(tmodent->tm_modid));
47 }
48 
49 void
50 Dbg_tls_static_block(void * vtlsmodlist, unsigned long tlsstatsize)
51 {
52 	unsigned int	i;
53 	TLS_modinfo **	tlsmodlist;
54 
55 	if (DBG_NOTCLASS(DBG_TLS))
56 		return;
57 	tlsmodlist = (TLS_modinfo **)vtlsmodlist;
58 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
59 	for (i = 0; tlsmodlist[i]; i++) {
60 		dbg_print(MSG_INTL(MSG_TLS_STATBLOCK1),
61 			i, tlsmodlist[i]->tm_modname);
62 		tls_modent(tlsmodlist[i]);
63 	}
64 	dbg_print(MSG_INTL(MSG_TLS_STATBLOCK2), EC_XWORD(tlsstatsize));
65 }
66 
67 
68 void
69 Dbg_tls_modactivity(void * vtlsmodent, uint_t flag)
70 {
71 	const char	*str;
72 	TLS_modinfo	*tlsmodent;
73 	if (DBG_NOTCLASS(DBG_TLS))
74 		return;
75 	if (flag == TM_FLG_MODADD)
76 		str = MSG_INTL(MSG_TLS_ADD);
77 	else
78 		str = MSG_INTL(MSG_TLS_REMOVE);
79 	tlsmodent = (TLS_modinfo *)vtlsmodent;
80 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
81 	dbg_print(MSG_INTL(MSG_TLS_MODACT), str, tlsmodent->tm_modname);
82 	tls_modent(tlsmodent);
83 }
84