tls.c revision 9273:9a0603d78ad3
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 2009 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#include	<link.h>
28#include	<libc_int.h>
29#include	<rtld.h>
30#include	<strings.h>
31#include	<debug.h>
32#include	"msg.h"
33#include	"_debug.h"
34
35#define	FLAGSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
36		MSG_TLS_FLAG_STATIC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
37		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
38
39static void
40Dbg_tls_modent(Lm_list *lml, TLS_modinfo * tmodent)
41{
42	/*
43	 * MSG_ORIG(MSG_TLS_FLAG_STATIC)
44	 */
45	static char	flagstr[FLAGSZ];
46	static Val_desc	vda[] = {
47		{ TM_FLG_STATICTLS,	MSG_TLS_FLAG_STATIC },
48		{ 0,			0 }
49	};
50	static CONV_EXPN_FIELD_ARG conv_arg = { flagstr, sizeof (flagstr) };
51
52	ulong_t	flags;
53
54	if ((flags = tmodent->tm_flags) != 0) {
55		conv_arg.oflags = conv_arg.rflags = flags;
56		(void) conv_expn_field(&conv_arg, vda, 0);
57	} else {
58		flagstr[0] = '\0';
59	}
60
61	dbg_print(lml, MSG_INTL(MSG_TLS_MODENT1),
62	    EC_XWORD((uintptr_t)tmodent->tm_tlsblock),
63	    EC_XWORD(tmodent->tm_stattlsoffset), EC_XWORD(tmodent->tm_flags),
64	    flagstr);
65	dbg_print(lml, MSG_INTL(MSG_TLS_MODENT2),
66	    EC_XWORD(tmodent->tm_filesz), EC_XWORD(tmodent->tm_memsz),
67	    EC_XWORD(tmodent->tm_modid));
68}
69
70void
71Dbg_tls_static_block(Lm_list *lml, void *list, ulong_t size, ulong_t resv)
72{
73	if (DBG_NOTCLASS(DBG_C_TLS))
74		return;
75
76	Dbg_util_nl(lml, DBG_NL_STD);
77
78	if (list) {
79		ulong_t		ndx;
80		TLS_modinfo	**tlsmodlist;
81
82		tlsmodlist = (TLS_modinfo **)list;
83
84		for (ndx = 0; tlsmodlist[ndx]; ndx++) {
85			dbg_print(lml, MSG_INTL(MSG_TLS_STATBLOCK1), ndx,
86			    tlsmodlist[ndx]->tm_modname);
87			Dbg_tls_modent(lml, tlsmodlist[ndx]);
88			Dbg_util_nl(lml, DBG_NL_STD);
89		}
90	}
91	dbg_print(lml, MSG_INTL(MSG_TLS_STATBLOCK2), EC_XWORD(size),
92	    EC_XWORD(resv));
93}
94
95void
96Dbg_tls_static_resv(Rt_map *lmp, ulong_t size, ulong_t resv)
97{
98	Lm_list	*lml = LIST(lmp);
99
100	if (DBG_NOTCLASS(DBG_C_TLS))
101		return;
102
103	Dbg_util_nl(lml, DBG_NL_STD);
104	dbg_print(lml, MSG_INTL(MSG_TLS_STATBLOCK3), TLSMODID(lmp), NAME(lmp),
105	    EC_XWORD(size), EC_XWORD(resv));
106}
107
108void
109Dbg_tls_modactivity(Lm_list *lml, void *vtlsmodent, uint_t flag)
110{
111	const char	*str;
112	TLS_modinfo	*tlsmodent;
113
114	if (DBG_NOTCLASS(DBG_C_TLS))
115		return;
116
117	if (flag == TM_FLG_MODADD)
118		str = MSG_INTL(MSG_TLS_ADD);
119	else
120		str = MSG_INTL(MSG_TLS_REMOVE);
121
122	tlsmodent = (TLS_modinfo *)vtlsmodent;
123	Dbg_util_nl(lml, DBG_NL_STD);
124	dbg_print(lml, MSG_INTL(MSG_TLS_MODACT), str, tlsmodent->tm_modname);
125	Dbg_tls_modent(lml, tlsmodent);
126}
127