xref: /titanic_52/usr/src/cmd/sgs/liblddbg/common/map.c (revision 8fe960854f0d52e2e8a80ba68e8621a5ac6a866d)
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	"msg.h"
28 #include	"_debug.h"
29 #include	"libld.h"
30 
31 static const char
32 	*Dbg_decl =	NULL;
33 
34 void
35 Dbg_map_set_atsign(Boolean new)
36 {
37 	if (DBG_NOTCLASS(DBG_C_MAP))
38 		return;
39 
40 	if (new)
41 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_4);
42 	else
43 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_5);
44 }
45 
46 void
47 Dbg_map_set_equal(Boolean new)
48 {
49 	if (DBG_NOTCLASS(DBG_C_MAP))
50 		return;
51 
52 	if (new)
53 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_1);
54 	else
55 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_2);
56 }
57 
58 void
59 Dbg_map_version(Lm_list *lml, const char *version, const char *name, int scope)
60 {
61 	const char	*str, *scp;
62 
63 	if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_SYMBOLS))
64 		return;
65 
66 	str = MSG_INTL(MSG_MAP_SYM_SCOPE);
67 	if (scope)
68 		scp = MSG_ORIG(MSG_SYM_GLOBAL);
69 	else
70 		scp = MSG_ORIG(MSG_SYM_LOCAL);
71 
72 	if (version)
73 		dbg_print(lml, MSG_INTL(MSG_MAP_SYM_VER_1), str, version,
74 		    Dbg_demangle_name(name), scp);
75 	else
76 		dbg_print(lml, MSG_INTL(MSG_MAP_SYM_VER_2), str,
77 		    Dbg_demangle_name(name), scp);
78 }
79 
80 void
81 Dbg_map_size_new(Lm_list *lml, const char *name)
82 {
83 	if (DBG_NOTCLASS(DBG_C_MAP))
84 		return;
85 
86 	dbg_print(lml, MSG_INTL(MSG_MAP_SYM_SIZE), Dbg_demangle_name(name),
87 	    MSG_INTL(MSG_STR_ADD));
88 }
89 
90 void
91 Dbg_map_size_old(Ofl_desc *ofl, Sym_desc *sdp)
92 {
93 	Conv_inv_buf_t	inv_buf;
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_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
107 	    sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
108 	    conv_def_tag(sdp->sd_ref, &inv_buf));
109 }
110 
111 void
112 Dbg_map_symbol(Ofl_desc *ofl, Sym_desc *sdp)
113 {
114 	Conv_inv_buf_t	inv_buf;
115 	Lm_list		*lml = ofl->ofl_lml;
116 
117 	if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_SYMBOLS))
118 		return;
119 	if (DBG_NOTDETAIL())
120 		return;
121 
122 	Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_ENTERED),
123 	    ofl->ofl_dehdr->e_ident[EI_OSABI],  ofl->ofl_dehdr->e_machine,
124 	    sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
125 	    conv_def_tag(sdp->sd_ref, &inv_buf));
126 }
127 
128 void
129 Dbg_map_dash(Lm_list *lml, const char *name, Sdf_desc *sdf)
130 {
131 	const char	*str;
132 
133 	if (DBG_NOTCLASS(DBG_C_MAP))
134 		return;
135 
136 	if (sdf->sdf_flags & FLG_SDF_SONAME)
137 		str = MSG_INTL(MSG_MAP_CNT_DEF_1);
138 	else
139 		str = MSG_INTL(MSG_MAP_CNT_DEF_2);
140 
141 	dbg_print(lml, str, name, sdf->sdf_soname);
142 }
143 
144 void
145 Dbg_map_sort(Lm_list *lml)
146 {
147 	if (DBG_NOTCLASS(DBG_C_MAP))
148 		return;
149 	if (DBG_NOTDETAIL())
150 		return;
151 
152 	Dbg_util_nl(lml, DBG_NL_STD);
153 	dbg_print(lml, MSG_INTL(MSG_MAP_SORT_TITLE));
154 }
155 
156 void
157 Dbg_map_sort_seg(Lm_list *lml, Sg_desc *sgp, int orig)
158 {
159 	const char	*str;
160 
161 	if (DBG_NOTCLASS(DBG_C_MAP))
162 		return;
163 	if (DBG_NOTDETAIL())
164 		return;
165 
166 	if (sgp->sg_name && *sgp->sg_name)
167 		str = sgp->sg_name;
168 	else
169 		str = MSG_INTL(MSG_STR_NULL);
170 
171 	if (orig)
172 		dbg_print(lml, MSG_INTL(MSG_MAP_SORT_ORIG), str);
173 	else
174 		dbg_print(lml, MSG_INTL(MSG_MAP_SORT_FINAL), str);
175 }
176 
177 void
178 Dbg_map_parse(Lm_list *lml, const char *file)
179 {
180 	if (DBG_NOTCLASS(DBG_C_MAP))
181 		return;
182 
183 	Dbg_util_nl(lml, DBG_NL_STD);
184 	dbg_print(lml, MSG_INTL(MSG_MAP_MAPFILE), file);
185 }
186 
187 void
188 Dbg_map_ent(Lm_list *lml, Boolean new, Ent_desc *enp, Ofl_desc *ofl)
189 {
190 	if (DBG_NOTCLASS(DBG_C_MAP))
191 		return;
192 
193 	dbg_print(lml, MSG_INTL(MSG_MAP_MAP_DIR));
194 	Dbg_ent_entry(lml, ofl->ofl_dehdr->e_ident[EI_OSABI],
195 	    ofl->ofl_dehdr->e_machine, enp);
196 	if (new)
197 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_3);
198 }
199 
200 void
201 Dbg_map_pipe(Lm_list *lml, Sg_desc *sgp, const char *sec_name, const Word ndx)
202 {
203 	if (DBG_NOTCLASS(DBG_C_MAP))
204 		return;
205 
206 	dbg_print(lml, MSG_INTL(MSG_MAP_SEC_ORDER), sgp->sg_name, sec_name,
207 	    EC_WORD(ndx));
208 }
209 
210 void
211 Dbg_map_seg(Ofl_desc *ofl, int ndx, Sg_desc *sgp)
212 {
213 	Lm_list	*lml = ofl->ofl_lml;
214 
215 	if (DBG_NOTCLASS(DBG_C_MAP))
216 		return;
217 
218 	if (Dbg_decl) {
219 		dbg_print(lml, MSG_ORIG(MSG_FMT_STR), Dbg_decl);
220 		Dbg_seg_desc_entry(ofl->ofl_lml,
221 		    ofl->ofl_dehdr->e_ident[EI_OSABI],
222 		    ofl->ofl_dehdr->e_machine, ndx, sgp);
223 		Dbg_util_nl(lml, DBG_NL_STD);
224 		Dbg_decl = NULL;
225 	}
226 }
227