xref: /illumos-gate/usr/src/cmd/sgs/liblddbg/common/map.c (revision 9f13099ee87ac8676c4175f88f52b3a34bd5990b)
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)
130 {
131 	if (DBG_NOTCLASS(DBG_C_MAP))
132 		return;
133 
134 	dbg_print(lml, MSG_INTL(MSG_MAP_CNT_DEF), name);
135 }
136 
137 void
138 Dbg_map_sort(Lm_list *lml)
139 {
140 	if (DBG_NOTCLASS(DBG_C_MAP))
141 		return;
142 	if (DBG_NOTDETAIL())
143 		return;
144 
145 	Dbg_util_nl(lml, DBG_NL_STD);
146 	dbg_print(lml, MSG_INTL(MSG_MAP_SORT_TITLE));
147 }
148 
149 void
150 Dbg_map_sort_seg(Lm_list *lml, Sg_desc *sgp, int orig)
151 {
152 	const char	*str;
153 
154 	if (DBG_NOTCLASS(DBG_C_MAP))
155 		return;
156 	if (DBG_NOTDETAIL())
157 		return;
158 
159 	if (sgp->sg_name && *sgp->sg_name)
160 		str = sgp->sg_name;
161 	else
162 		str = MSG_INTL(MSG_STR_NULL);
163 
164 	if (orig)
165 		dbg_print(lml, MSG_INTL(MSG_MAP_SORT_ORIG), str);
166 	else
167 		dbg_print(lml, MSG_INTL(MSG_MAP_SORT_FINAL), str);
168 }
169 
170 void
171 Dbg_map_parse(Lm_list *lml, const char *file)
172 {
173 	if (DBG_NOTCLASS(DBG_C_MAP))
174 		return;
175 
176 	Dbg_util_nl(lml, DBG_NL_STD);
177 	dbg_print(lml, MSG_INTL(MSG_MAP_MAPFILE), file);
178 }
179 
180 void
181 Dbg_map_ent(Lm_list *lml, Boolean new, Ent_desc *enp, Ofl_desc *ofl)
182 {
183 	if (DBG_NOTCLASS(DBG_C_MAP))
184 		return;
185 
186 	dbg_print(lml, MSG_INTL(MSG_MAP_MAP_DIR));
187 	Dbg_ent_entry(lml, ofl->ofl_dehdr->e_ident[EI_OSABI],
188 	    ofl->ofl_dehdr->e_machine, enp);
189 	if (new)
190 		Dbg_decl = MSG_INTL(MSG_MAP_SEG_DECL_3);
191 }
192 
193 void
194 Dbg_map_pipe(Lm_list *lml, Sg_desc *sgp, const char *sec_name, const Word ndx)
195 {
196 	if (DBG_NOTCLASS(DBG_C_MAP))
197 		return;
198 
199 	dbg_print(lml, MSG_INTL(MSG_MAP_SEC_ORDER), sgp->sg_name, sec_name,
200 	    EC_WORD(ndx));
201 }
202 
203 void
204 Dbg_map_seg(Ofl_desc *ofl, int ndx, Sg_desc *sgp)
205 {
206 	Lm_list	*lml = ofl->ofl_lml;
207 
208 	if (DBG_NOTCLASS(DBG_C_MAP))
209 		return;
210 
211 	if (Dbg_decl) {
212 		dbg_print(lml, MSG_ORIG(MSG_FMT_STR), Dbg_decl);
213 		Dbg_seg_desc_entry(ofl->ofl_lml,
214 		    ofl->ofl_dehdr->e_ident[EI_OSABI],
215 		    ofl->ofl_dehdr->e_machine, ndx, sgp);
216 		Dbg_util_nl(lml, DBG_NL_STD);
217 		Dbg_decl = NULL;
218 	}
219 }
220