xref: /illumos-gate/usr/src/cmd/sgs/liblddbg/common/map.c (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
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 (c) 2000 by Sun Microsystems, Inc.
24  *	All rights reserved.
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_version(const char *version, const char *name, int scope)
37 {
38 	const char	*str, *scp;
39 
40 	if (DBG_NOTCLASS(DBG_MAP | DBG_SYMBOLS))
41 		return;
42 
43 	str = MSG_INTL(MSG_MAP_SYM_SCOPE);
44 	if (scope)
45 		scp = MSG_ORIG(MSG_SYM_GLOBAL);
46 	else
47 		scp = MSG_ORIG(MSG_SYM_LOCAL);
48 
49 	if (version)
50 		dbg_print(MSG_INTL(MSG_MAP_SYM_VER_1), str, version,
51 		    _Dbg_sym_dem(name), scp);
52 	else
53 		dbg_print(MSG_INTL(MSG_MAP_SYM_VER_2), str,
54 		    _Dbg_sym_dem(name), scp);
55 }
56 
57 void
58 Dbg_map_size_new(const char *name)
59 {
60 	if (DBG_NOTCLASS(DBG_MAP))
61 		return;
62 
63 	dbg_print(MSG_INTL(MSG_MAP_SYM_SIZE), _Dbg_sym_dem(name),
64 	    MSG_INTL(MSG_STR_ADD));
65 }
66 
67 void
68 Dbg_map_size_old(Ehdr *ehdr, Sym_desc *sdp)
69 {
70 	if (DBG_NOTCLASS(DBG_MAP))
71 		return;
72 
73 	dbg_print(MSG_INTL(MSG_MAP_SYM_SIZE), sdp->sd_name,
74 	    MSG_INTL(MSG_STR_UP_1));
75 
76 	if (DBG_NOTDETAIL())
77 		return;
78 
79 	Elf_sym_table_entry(MSG_INTL(MSG_STR_UP_2), ehdr, sdp->sd_sym,
80 	    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, NULL,
81 	    conv_deftag_str(sdp->sd_ref));
82 }
83 
84 /*
85  * Provide for printing mapfile entered symbols when symbol debugging hasn't
86  * been enabled.
87  */
88 void
89 Dbg_map_symbol(Ehdr *ehdr, Sym_desc *sdp)
90 {
91 	if (DBG_NOTCLASS(DBG_MAP))
92 		return;
93 	if (DBG_NOTDETAIL())
94 		return;
95 
96 	if (DBG_NOTCLASS(DBG_SYMBOLS))
97 		Elf_sym_table_entry(MSG_INTL(MSG_STR_ENTERED), ehdr,
98 		    sdp->sd_sym,
99 		    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, NULL,
100 		    conv_deftag_str(sdp->sd_ref));
101 }
102 
103 void
104 Dbg_map_dash(const char *name, Sdf_desc *sdf)
105 {
106 	const char	*str;
107 
108 	if (DBG_NOTCLASS(DBG_MAP))
109 		return;
110 
111 	if (sdf->sdf_flags & FLG_SDF_SONAME)
112 		str = MSG_INTL(MSG_MAP_CNT_DEF_1);
113 	else
114 		str = MSG_INTL(MSG_MAP_CNT_DEF_2);
115 
116 	dbg_print(str, name, sdf->sdf_soname);
117 }
118 
119 void
120 Dbg_map_sort_orig(Sg_desc *sgp)
121 {
122 	const char	*str;
123 
124 	if (DBG_NOTCLASS(DBG_MAP))
125 		return;
126 	if (DBG_NOTDETAIL())
127 		return;
128 
129 	if (sgp->sg_name && *sgp->sg_name)
130 		str = sgp->sg_name;
131 	else
132 		str = MSG_INTL(MSG_STR_NULL);
133 
134 	dbg_print(MSG_INTL(MSG_MAP_SORTSEG), str);
135 }
136 
137 void
138 Dbg_map_sort_fini(Sg_desc *sgp)
139 {
140 	const char	*str;
141 
142 	if (DBG_NOTCLASS(DBG_MAP))
143 		return;
144 	if (DBG_NOTDETAIL())
145 		return;
146 
147 	if (sgp->sg_name && *sgp->sg_name)
148 		str = sgp->sg_name;
149 	else
150 		str = MSG_INTL(MSG_STR_NULL);
151 
152 	dbg_print(MSG_INTL(MSG_MAP_SEGSORT), str);
153 }
154 
155 void
156 Dbg_map_parse(const char *file)
157 {
158 	if (DBG_NOTCLASS(DBG_MAP))
159 		return;
160 
161 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
162 	dbg_print(MSG_INTL(MSG_MAP_MAPFILE), file);
163 }
164 
165 void
166 Dbg_map_equal(Boolean new)
167 {
168 	if (DBG_NOTCLASS(DBG_MAP))
169 		return;
170 
171 	if (new)
172 		_Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_1);
173 	else
174 		_Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_2);
175 }
176 
177 void
178 Dbg_map_ent(Boolean new, Ent_desc *enp, Ofl_desc *ofl)
179 {
180 	if (DBG_NOTCLASS(DBG_MAP))
181 		return;
182 
183 	dbg_print(MSG_INTL(MSG_MAP_MAP_DIR));
184 	_Dbg_ent_entry(ofl->ofl_e_machine, enp);
185 	if (new)
186 		_Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_3);
187 }
188 
189 void
190 Dbg_map_atsign(Boolean new)
191 {
192 	if (DBG_NOTCLASS(DBG_MAP))
193 		return;
194 
195 	if (new)
196 		_Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_4);
197 	else
198 		_Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_5);
199 }
200 
201 void
202 Dbg_map_pipe(Sg_desc *sgp, const char *sec_name, const Word ndx)
203 {
204 	if (DBG_NOTCLASS(DBG_MAP))
205 		return;
206 
207 	dbg_print(MSG_INTL(MSG_MAP_SEC_ORDER), sgp->sg_name, sec_name,
208 	    EC_WORD(ndx));
209 }
210 
211 void
212 Dbg_map_seg(Half mach, int ndx, Sg_desc *sgp)
213 {
214 	if (DBG_NOTCLASS(DBG_MAP))
215 		return;
216 
217 	if (_Dbg_decl) {
218 		dbg_print(MSG_ORIG(MSG_FMT_STR), _Dbg_decl);
219 		_Dbg_seg_desc_entry(mach, ndx, sgp);
220 		dbg_print(MSG_ORIG(MSG_STR_EMPTY));
221 		_Dbg_decl = NULL;
222 	}
223 }
224