xref: /illumos-gate/usr/src/cmd/sgs/liblddbg/common/map.c (revision 734b6a94890be549309b21156f8ed6d4561cac51)
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 #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 	Lm_list	*lml = ofl->ofl_lml;
95 
96 	if (DBG_NOTCLASS(DBG_C_MAP))
97 		return;
98 
99 	dbg_print(lml, MSG_INTL(MSG_MAP_SYM_SIZE), sdp->sd_name,
100 	    MSG_INTL(MSG_STR_UP_1));
101 
102 	if (DBG_NOTDETAIL())
103 		return;
104 
105 	Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_UP_2),
106 	    ofl->ofl_dehdr->e_machine, sdp->sd_sym,
107 	    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, NULL,
108 	    conv_def_tag(sdp->sd_ref));
109 }
110 
111 void
112 Dbg_map_symbol(Ofl_desc *ofl, Sym_desc *sdp)
113 {
114 	Lm_list	*lml = ofl->ofl_lml;
115 
116 	if (DBG_NOTCLASS(DBG_C_MAP))
117 		return;
118 	if (DBG_NOTDETAIL())
119 		return;
120 
121 	/*
122 	 * Provide for printing mapfile entered symbols when symbol debugging
123 	 * hasn't been enabled.
124 	 */
125 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
126 		Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_ENTERED),
127 		    ofl->ofl_dehdr->e_machine, sdp->sd_sym,
128 		    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, NULL,
129 		    conv_def_tag(sdp->sd_ref));
130 }
131 
132 void
133 Dbg_map_dash(Lm_list *lml, const char *name, Sdf_desc *sdf)
134 {
135 	const char	*str;
136 
137 	if (DBG_NOTCLASS(DBG_C_MAP))
138 		return;
139 
140 	if (sdf->sdf_flags & FLG_SDF_SONAME)
141 		str = MSG_INTL(MSG_MAP_CNT_DEF_1);
142 	else
143 		str = MSG_INTL(MSG_MAP_CNT_DEF_2);
144 
145 	dbg_print(lml, str, name, sdf->sdf_soname);
146 }
147 
148 void
149 Dbg_map_sort_orig(Lm_list *lml, Sg_desc *sgp)
150 {
151 	const char	*str;
152 
153 	if (DBG_NOTCLASS(DBG_C_MAP))
154 		return;
155 	if (DBG_NOTDETAIL())
156 		return;
157 
158 	if (sgp->sg_name && *sgp->sg_name)
159 		str = sgp->sg_name;
160 	else
161 		str = MSG_INTL(MSG_STR_NULL);
162 
163 	dbg_print(lml, MSG_INTL(MSG_MAP_SORTSEG), str);
164 }
165 
166 void
167 Dbg_map_sort_fini(Lm_list *lml, Sg_desc *sgp)
168 {
169 	const char	*str;
170 
171 	if (DBG_NOTCLASS(DBG_C_MAP))
172 		return;
173 	if (DBG_NOTDETAIL())
174 		return;
175 
176 	if (sgp->sg_name && *sgp->sg_name)
177 		str = sgp->sg_name;
178 	else
179 		str = MSG_INTL(MSG_STR_NULL);
180 
181 	dbg_print(lml, MSG_INTL(MSG_MAP_SEGSORT), str);
182 }
183 
184 void
185 Dbg_map_parse(Lm_list *lml, const char *file)
186 {
187 	if (DBG_NOTCLASS(DBG_C_MAP))
188 		return;
189 
190 	Dbg_util_nl(lml, DBG_NL_STD);
191 	dbg_print(lml, MSG_INTL(MSG_MAP_MAPFILE), file);
192 }
193 
194 void
195 Dbg_map_ent(Lm_list *lml, Boolean new, Ent_desc *enp, Ofl_desc *ofl)
196 {
197 	if (DBG_NOTCLASS(DBG_C_MAP))
198 		return;
199 
200 	dbg_print(lml, MSG_INTL(MSG_MAP_MAP_DIR));
201 	Dbg_ent_entry(lml, ofl->ofl_dehdr->e_machine, enp);
202 	if (new)
203 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_3);
204 }
205 
206 void
207 Dbg_map_pipe(Lm_list *lml, Sg_desc *sgp, const char *sec_name, const Word ndx)
208 {
209 	if (DBG_NOTCLASS(DBG_C_MAP))
210 		return;
211 
212 	dbg_print(lml, MSG_INTL(MSG_MAP_SEC_ORDER), sgp->sg_name, sec_name,
213 	    EC_WORD(ndx));
214 }
215 
216 void
217 Dbg_map_seg(Ofl_desc *ofl, int ndx, Sg_desc *sgp)
218 {
219 	Lm_list	*lml = ofl->ofl_lml;
220 
221 	if (DBG_NOTCLASS(DBG_C_MAP))
222 		return;
223 
224 	if (Dbg_decl) {
225 		dbg_print(lml, MSG_ORIG(MSG_FMT_STR), Dbg_decl);
226 		Dbg_seg_desc_entry(ofl->ofl_lml,
227 		    ofl->ofl_dehdr->e_machine, ndx, sgp);
228 		Dbg_util_nl(lml, DBG_NL_STD);
229 		Dbg_decl = NULL;
230 	}
231 }
232