xref: /titanic_44/usr/src/cmd/sgs/liblddbg/common/map.c (revision 54925bf60766fbb4f1f2d7c843721406a7b7a3fb)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include	"msg.h"
29 #include	"_debug.h"
30 #include	"libld.h"
31 
32 static const char
33 	*Dbg_decl =	NULL;
34 
35 void
36 Dbg_map_set_atsign(Boolean new)
37 {
38 	if (DBG_NOTCLASS(DBG_C_MAP))
39 		return;
40 
41 	if (new)
42 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_4);
43 	else
44 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_5);
45 }
46 
47 void
48 Dbg_map_set_equal(Boolean new)
49 {
50 	if (DBG_NOTCLASS(DBG_C_MAP))
51 		return;
52 
53 	if (new)
54 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_1);
55 	else
56 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_2);
57 }
58 
59 void
60 Dbg_map_version(Lm_list *lml, const char *version, const char *name, int scope)
61 {
62 	const char	*str, *scp;
63 
64 	if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_SYMBOLS))
65 		return;
66 
67 	str = MSG_INTL(MSG_MAP_SYM_SCOPE);
68 	if (scope)
69 		scp = MSG_ORIG(MSG_SYM_GLOBAL);
70 	else
71 		scp = MSG_ORIG(MSG_SYM_LOCAL);
72 
73 	if (version)
74 		dbg_print(lml, MSG_INTL(MSG_MAP_SYM_VER_1), str, version,
75 		    Dbg_demangle_name(name), scp);
76 	else
77 		dbg_print(lml, MSG_INTL(MSG_MAP_SYM_VER_2), str,
78 		    Dbg_demangle_name(name), scp);
79 }
80 
81 void
82 Dbg_map_size_new(Lm_list *lml, const char *name)
83 {
84 	if (DBG_NOTCLASS(DBG_C_MAP))
85 		return;
86 
87 	dbg_print(lml, MSG_INTL(MSG_MAP_SYM_SIZE), Dbg_demangle_name(name),
88 	    MSG_INTL(MSG_STR_ADD));
89 }
90 
91 void
92 Dbg_map_size_old(Ofl_desc *ofl, Sym_desc *sdp)
93 {
94 	Conv_inv_buf_t	inv_buf;
95 	Lm_list		*lml = ofl->ofl_lml;
96 
97 	if (DBG_NOTCLASS(DBG_C_MAP))
98 		return;
99 
100 	dbg_print(lml, MSG_INTL(MSG_MAP_SYM_SIZE), sdp->sd_name,
101 	    MSG_INTL(MSG_STR_UP_1));
102 
103 	if (DBG_NOTDETAIL())
104 		return;
105 
106 	Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_UP_2),
107 	    ofl->ofl_dehdr->e_machine, sdp->sd_sym,
108 	    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
109 	    conv_def_tag(sdp->sd_ref, &inv_buf));
110 }
111 
112 void
113 Dbg_map_symbol(Ofl_desc *ofl, Sym_desc *sdp)
114 {
115 	Conv_inv_buf_t	inv_buf;
116 	Lm_list		*lml = ofl->ofl_lml;
117 
118 	if (DBG_NOTCLASS(DBG_C_MAP))
119 		return;
120 	if (DBG_NOTDETAIL())
121 		return;
122 
123 	/*
124 	 * Provide for printing mapfile entered symbols when symbol debugging
125 	 * hasn't been enabled.
126 	 */
127 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
128 		Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_ENTERED),
129 		    ofl->ofl_dehdr->e_machine, sdp->sd_sym,
130 		    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
131 		    conv_def_tag(sdp->sd_ref, &inv_buf));
132 }
133 
134 void
135 Dbg_map_dash(Lm_list *lml, const char *name, Sdf_desc *sdf)
136 {
137 	const char	*str;
138 
139 	if (DBG_NOTCLASS(DBG_C_MAP))
140 		return;
141 
142 	if (sdf->sdf_flags & FLG_SDF_SONAME)
143 		str = MSG_INTL(MSG_MAP_CNT_DEF_1);
144 	else
145 		str = MSG_INTL(MSG_MAP_CNT_DEF_2);
146 
147 	dbg_print(lml, str, name, sdf->sdf_soname);
148 }
149 
150 void
151 Dbg_map_sort_orig(Lm_list *lml, Sg_desc *sgp)
152 {
153 	const char	*str;
154 
155 	if (DBG_NOTCLASS(DBG_C_MAP))
156 		return;
157 	if (DBG_NOTDETAIL())
158 		return;
159 
160 	if (sgp->sg_name && *sgp->sg_name)
161 		str = sgp->sg_name;
162 	else
163 		str = MSG_INTL(MSG_STR_NULL);
164 
165 	dbg_print(lml, MSG_INTL(MSG_MAP_SORTSEG), str);
166 }
167 
168 void
169 Dbg_map_sort_fini(Lm_list *lml, Sg_desc *sgp)
170 {
171 	const char	*str;
172 
173 	if (DBG_NOTCLASS(DBG_C_MAP))
174 		return;
175 	if (DBG_NOTDETAIL())
176 		return;
177 
178 	if (sgp->sg_name && *sgp->sg_name)
179 		str = sgp->sg_name;
180 	else
181 		str = MSG_INTL(MSG_STR_NULL);
182 
183 	dbg_print(lml, MSG_INTL(MSG_MAP_SEGSORT), str);
184 }
185 
186 void
187 Dbg_map_parse(Lm_list *lml, const char *file)
188 {
189 	if (DBG_NOTCLASS(DBG_C_MAP))
190 		return;
191 
192 	Dbg_util_nl(lml, DBG_NL_STD);
193 	dbg_print(lml, MSG_INTL(MSG_MAP_MAPFILE), file);
194 }
195 
196 void
197 Dbg_map_ent(Lm_list *lml, Boolean new, Ent_desc *enp, Ofl_desc *ofl)
198 {
199 	if (DBG_NOTCLASS(DBG_C_MAP))
200 		return;
201 
202 	dbg_print(lml, MSG_INTL(MSG_MAP_MAP_DIR));
203 	Dbg_ent_entry(lml, ofl->ofl_dehdr->e_machine, enp);
204 	if (new)
205 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_3);
206 }
207 
208 void
209 Dbg_map_pipe(Lm_list *lml, Sg_desc *sgp, const char *sec_name, const Word ndx)
210 {
211 	if (DBG_NOTCLASS(DBG_C_MAP))
212 		return;
213 
214 	dbg_print(lml, MSG_INTL(MSG_MAP_SEC_ORDER), sgp->sg_name, sec_name,
215 	    EC_WORD(ndx));
216 }
217 
218 void
219 Dbg_map_seg(Ofl_desc *ofl, int ndx, Sg_desc *sgp)
220 {
221 	Lm_list	*lml = ofl->ofl_lml;
222 
223 	if (DBG_NOTCLASS(DBG_C_MAP))
224 		return;
225 
226 	if (Dbg_decl) {
227 		dbg_print(lml, MSG_ORIG(MSG_FMT_STR), Dbg_decl);
228 		Dbg_seg_desc_entry(ofl->ofl_lml,
229 		    ofl->ofl_dehdr->e_machine, ndx, sgp);
230 		Dbg_util_nl(lml, DBG_NL_STD);
231 		Dbg_decl = NULL;
232 	}
233 }
234