dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / sgs / liblddbg / common / map.c
blob77df055954ebfdc4c7e30d99f0b2e97a62f09588
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #include "msg.h"
28 #include "_debug.h"
29 #include "libld.h"
33 * Report change in input enable status caused by evaluating
34 * $if/$elif control directives.
36 void
37 Dbg_map_pass(Lm_list *lml, Boolean enable, const char *file,
38 Lineno lineno, const char *directive)
40 const char *fmt;
42 if (DBG_NOTCLASS(DBG_C_MAP))
43 return;
45 fmt = enable ? MSG_INTL(MSG_MAP_PASS) : MSG_INTL(MSG_MAP_NOPASS);
46 dbg_print(lml, fmt, file, EC_LINENO(lineno), directive);
50 * Report entry/removal of boolean identifier from conditional expression
51 * known values.
53 void
54 Dbg_map_cexp_id(Lm_list *lml, Boolean add, const char *file,
55 Lineno lineno, const char *id)
57 const char *fmt;
59 if (DBG_NOTCLASS(DBG_C_MAP))
60 return;
62 fmt = add ? MSG_INTL(MSG_MAP_ID_ADD) : MSG_INTL(MSG_MAP_ID_CLEAR);
63 dbg_print(lml, fmt, file, EC_LINENO(lineno), id);
66 void
67 Dbg_map_version(Lm_list *lml, const char *version, const char *name, int scope)
69 const char *str, *scp;
71 if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_SYMBOLS))
72 return;
74 str = MSG_INTL(MSG_MAP_SYM_SCOPE);
75 if (scope)
76 scp = MSG_ORIG(MSG_SYM_GLOBAL);
77 else
78 scp = MSG_ORIG(MSG_SYM_LOCAL);
80 if (version)
81 dbg_print(lml, MSG_INTL(MSG_MAP_SYM_VER_1), str, version,
82 Dbg_demangle_name(name), scp);
83 else
84 dbg_print(lml, MSG_INTL(MSG_MAP_SYM_VER_2), str,
85 Dbg_demangle_name(name), scp);
88 void
89 Dbg_map_size_new(Lm_list *lml, const char *symname, const char *segname,
90 Lineno lineno)
92 if (DBG_NOTCLASS(DBG_C_MAP))
93 return;
95 Dbg_util_nl(lml, DBG_NL_STD);
96 dbg_print(lml, MSG_INTL(MSG_MAP_SYM_SIZE), EC_LINENO(lineno), segname,
97 Dbg_demangle_name(symname), MSG_INTL(MSG_STR_ADDING));
100 void
101 Dbg_map_size_old(Ofl_desc *ofl, Sym_desc *sdp, const char *segname,
102 Lineno lineno)
104 Conv_inv_buf_t inv_buf;
105 Lm_list *lml = ofl->ofl_lml;
107 if (DBG_NOTCLASS(DBG_C_MAP))
108 return;
110 Dbg_util_nl(lml, DBG_NL_STD);
111 dbg_print(lml, MSG_INTL(MSG_MAP_SYM_SIZE), EC_LINENO(lineno), segname,
112 sdp->sd_name, MSG_INTL(MSG_STR_UP_1));
114 if (DBG_NOTDETAIL())
115 return;
117 Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_UP_2),
118 ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
119 sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
120 conv_def_tag(sdp->sd_ref, &inv_buf));
123 void
124 Dbg_map_symbol(Ofl_desc *ofl, Sym_desc *sdp)
126 Conv_inv_buf_t inv_buf;
127 Lm_list *lml = ofl->ofl_lml;
129 if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_SYMBOLS))
130 return;
131 if (DBG_NOTDETAIL())
132 return;
134 Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_ENTERED),
135 ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
136 sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
137 conv_def_tag(sdp->sd_ref, &inv_buf));
141 * Object version dependency. In the v1 syntax, this is the 'dash' operator.
142 * In the v2 syntax, the DEPEND_VERSIONS directive.
144 void
145 Dbg_map_dv(Lm_list *lml, const char *obj_name, Lineno lineno)
147 if (DBG_NOTCLASS(DBG_C_MAP))
148 return;
150 dbg_print(lml, MSG_INTL(MSG_MAP_DV), EC_LINENO(lineno), obj_name);
154 * Add a version to an object dependency
156 void
157 Dbg_map_dv_entry(Lm_list *lml, Lineno lineno, int require, const char *version)
159 const char *attr;
161 if (DBG_NOTCLASS(DBG_C_MAP))
162 return;
164 attr = require ? MSG_INTL(MSG_STR_REQUIRE) : MSG_INTL(MSG_STR_ALLOW);
165 dbg_print(lml, MSG_INTL(MSG_MAP_DV_ENTRY), attr, version,
166 EC_LINENO(lineno));
169 void
170 Dbg_map_sort_title(Lm_list *lml, Boolean orig)
172 if (DBG_NOTCLASS(DBG_C_MAP))
173 return;
174 if (DBG_NOTDETAIL())
175 return;
177 if (orig) {
178 Dbg_util_nl(lml, DBG_NL_STD);
179 dbg_print(lml, MSG_INTL(MSG_MAP_SORT_TITLE));
180 dbg_print(lml, MSG_INTL(MSG_MAP_SORT_TITLE_O));
181 } else {
182 dbg_print(lml, MSG_INTL(MSG_MAP_SORT_TITLE_S));
186 void
187 Dbg_map_sort_seg(Lm_list *lml, uchar_t osabi, Half mach, Sg_desc *sgp)
189 const char *type_str;
190 Conv_inv_buf_t inv_buf;
192 if (DBG_NOTCLASS(DBG_C_MAP))
193 return;
194 if (DBG_NOTDETAIL())
195 return;
197 type_str = conv_phdr_type(osabi, mach, sgp->sg_phdr.p_type,
198 0, &inv_buf);
200 if (sgp->sg_name) {
201 if (sgp->sg_flags & FLG_SG_P_VADDR) {
202 dbg_print(lml, MSG_ORIG(MSG_MAP_SORT_SEG_V),
203 type_str, sgp->sg_name,
204 EC_ADDR(sgp->sg_phdr.p_vaddr));
205 } else if (sgp->sg_flags & FLG_SG_ORDERED) {
207 * All FLG_SG_ORDERED have adjacent sg_id values
208 * that start at SGID_TEXT. Subtract out the base
209 * in order to present the order values based at 0.
211 dbg_print(lml, MSG_ORIG(MSG_MAP_SORT_SEG_O),
212 type_str, sgp->sg_name,
213 EC_WORD(sgp->sg_id - SGID_TEXT));
214 } else {
215 dbg_print(lml, MSG_ORIG(MSG_MAP_SORT_SEG_NAME),
216 type_str, sgp->sg_name);
218 } else {
219 dbg_print(lml, MSG_ORIG(MSG_MAP_SORT_SEG), type_str);
223 void
224 Dbg_map_parse(Lm_list *lml, const char *file, int version)
226 Conv_inv_buf_t inv_buf;
228 if (DBG_NOTCLASS(DBG_C_MAP))
229 return;
231 Dbg_util_nl(lml, DBG_NL_STD);
232 dbg_print(lml, MSG_INTL(MSG_MAP_MAPFILE), file, EC_WORD(version),
233 conv_mapfile_version(version, 0, &inv_buf));
236 void
237 Dbg_map_ent(Lm_list *lml, Ent_desc *enp, Ofl_desc *ofl, Lineno lineno)
239 if (DBG_NOTCLASS(DBG_C_MAP))
240 return;
242 Dbg_util_nl(lml, DBG_NL_STD);
243 dbg_print(lml, MSG_INTL(MSG_MAP_EC), EC_LINENO(lineno));
244 Dbg_ent_entry(lml, ofl->ofl_dehdr->e_ident[EI_OSABI],
245 ofl->ofl_dehdr->e_machine, enp);
248 void
249 Dbg_map_ent_ord_title(Lm_list *lml, const char *segname)
251 if (DBG_NOTCLASS(DBG_C_MAP))
252 return;
254 Dbg_util_nl(lml, DBG_NL_STD);
255 dbg_print(lml, MSG_INTL(MSG_MAP_ENT_ORD_TITLE), segname);
258 void
259 Dbg_map_seg_os_order(Lm_list *lml, Sg_desc *sgp, const char *sec_name,
260 Word ndx, Lineno lineno)
262 if (DBG_NOTCLASS(DBG_C_MAP))
263 return;
265 dbg_print(lml, MSG_INTL(MSG_MAP_OS_ORDER), EC_LINENO(lineno),
266 sgp->sg_name, sec_name, EC_WORD(ndx));
269 void
270 Dbg_map_seg(Ofl_desc *ofl, dbg_state_t dbg_state, int ndx, Sg_desc *sgp,
271 Lineno lineno)
273 Lm_list *lml = ofl->ofl_lml;
275 if (DBG_NOTCLASS(DBG_C_MAP))
276 return;
278 Dbg_util_nl(lml, DBG_NL_STD);
279 dbg_print(lml, MSG_INTL(MSG_MAP_SEG), EC_LINENO(lineno),
280 Dbg_state_str(dbg_state));
281 Dbg_seg_desc_entry(ofl->ofl_lml, ofl->ofl_dehdr->e_ident[EI_OSABI],
282 ofl->ofl_dehdr->e_machine, ndx, sgp, FALSE);
283 Dbg_util_nl(lml, DBG_NL_STD);
286 void
287 Dbg_map_seg_order(Ofl_desc *ofl, uchar_t osabi, Half mach,
288 dbg_state_t dbg_state, Lineno lineno)
290 Lm_list *lml = ofl->ofl_lml;
291 Aliste idx;
292 Sg_desc *sgp;
293 Conv_inv_buf_t inv_buf;
294 const char *type_str;
296 if (DBG_NOTCLASS(DBG_C_MAP))
297 return;
299 Dbg_util_nl(lml, DBG_NL_STD);
300 dbg_print(lml, MSG_INTL(MSG_MAP_SEG_ORDER), EC_LINENO(lineno),
301 EC_XWORD(aplist_nitems(ofl->ofl_segs_order)),
302 Dbg_state_str(dbg_state));
303 for (APLIST_TRAVERSE(ofl->ofl_segs_order, idx, sgp)) {
304 type_str = conv_phdr_type(osabi, mach, sgp->sg_phdr.p_type,
305 0, &inv_buf);
306 dbg_print(lml, MSG_ORIG(MSG_MAP_SORT_SEG_NAME), type_str,
307 sgp->sg_name);
309 Dbg_util_nl(lml, DBG_NL_STD);
312 void
313 Dbg_map_post_title(Lm_list *lml)
315 if (DBG_NOTCLASS(DBG_C_MAP))
316 return;
318 Dbg_util_nl(lml, DBG_NL_STD);
319 dbg_print(lml, MSG_INTL(MSG_MAP_POST_TITLE));
322 void
323 Dbg_map_hdr_noalloc(Lm_list *lml, Lineno lineno)
325 if (DBG_NOTCLASS(DBG_C_MAP))
326 return;
328 Dbg_util_nl(lml, DBG_NL_STD);
329 dbg_print(lml, MSG_INTL(MSG_MAP_HDR_NOALLOC), EC_LINENO(lineno));