xref: /titanic_50/usr/src/cmd/sgs/liblddbg/common/syms.c (revision 5667185bc023b9742cb2480659d7673fa9ac8050)
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 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include	<stdio.h>
28 #include	<dlfcn.h>
29 #include	"msg.h"
30 #include	"_debug.h"
31 #include	"libld.h"
32 
33 #if	!(defined(_ELF64))
34 
35 void
36 Dbg_syms_lookup_aout(Lm_list *lml, const char *name)
37 {
38 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
39 		return;
40 
41 	dbg_print(lml, MSG_INTL(MSG_SYM_AOUT), Dbg_demangle_name(name));
42 }
43 
44 #endif
45 
46 void
47 Dbg_syms_lookup(Rt_map *lmp, const char *name, const char *type)
48 {
49 	Lm_list	*lml = LIST(lmp);
50 
51 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
52 		return;
53 
54 	dbg_print(lml, MSG_INTL(MSG_SYM_LOOKUP), Dbg_demangle_name(name),
55 	    NAME(lmp), type);
56 }
57 
58 static	const Msg captype[DBG_CAP_MACH + 1] = {
59 	MSG_CAP_SYM_DEFAULT,		/* MSG_INTL(MSG_CAP_SYM_DEFAULT) */
60 	MSG_CAP_SYM_USED,		/* MSG_INTL(MSG_CAP_SYM_USED) */
61 	MSG_CAP_SYM_CANDIDATE,		/* MSG_INTL(MSG_CAP_SYM_CANDIDATE) */
62 	MSG_CAP_SYM_REJECTED,		/* MSG_INTL(MSG_CAP_SYM_REJECTED) */
63 	MSG_CAP_SYM_HW_1,		/* MSG_INTL(MSG_CAP_SYM_HW_1) */
64 	MSG_CAP_SYM_SF_1,		/* MSG_INTL(MSG_CAP_SYM_SF_1) */
65 	MSG_CAP_SYM_HW_2,		/* MSG_INTL(MSG_CAP_SYM_HW_2) */
66 	MSG_CAP_SYM_PLAT,		/* MSG_INTL(MSG_CAP_SYM_PLAT) */
67 	MSG_CAP_SYM_MACH		/* MSG_INTL(MSG_CAP_SYM_MACH) */
68 };
69 
70 void
71 Dbg_syms_cap_lookup(Rt_map *lmp, uint_t type, const char *name, uint_t ndx,
72     Half mach, Syscapset *scapset)
73 {
74 	Lm_list			*lml = LIST(lmp);
75 	const char		*str = NULL;
76 	Conv_cap_val_buf_t	cap_val_buf;
77 
78 	if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_SYMBOLS))
79 		return;
80 
81 	switch (type) {
82 	case DBG_CAP_HW_1:
83 		str = conv_cap_val_hw1(scapset->sc_hw_1, mach, 0,
84 		    &cap_val_buf.cap_val_hw1_buf);
85 		break;
86 	case DBG_CAP_SF_1:
87 		str = conv_cap_val_sf1(scapset->sc_sf_1, mach, 0,
88 		    &cap_val_buf.cap_val_sf1_buf);
89 		break;
90 	case DBG_CAP_HW_2:
91 		str = conv_cap_val_hw2(scapset->sc_hw_2, mach, 0,
92 		    &cap_val_buf.cap_val_hw2_buf);
93 		break;
94 	case DBG_CAP_MACH:
95 		str = scapset->sc_mach;
96 		break;
97 	case DBG_CAP_PLAT:
98 		str = scapset->sc_plat;
99 		break;
100 	}
101 
102 	dbg_print(lml, MSG_INTL(captype[type]), Dbg_demangle_name(name),
103 	    ndx, str);
104 }
105 
106 void
107 Dbg_syms_ignore_gnuver(Rt_map *lmp, const char *name, Word symndx,
108     Versym verndx)
109 {
110 	Lm_list	*lml = LIST(lmp);
111 
112 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
113 		return;
114 
115 	dbg_print(lml, MSG_INTL(MSG_SYM_IGNGNUVER), Dbg_demangle_name(name),
116 	    EC_WORD(symndx), EC_HALF(verndx), NAME(lmp));
117 }
118 
119 void
120 Dbg_syms_dlsym(Rt_map *clmp, const char *sym, int *in_nfavl, const char *next,
121     int flag)
122 {
123 	const char	*str, *retry, *from = NAME(clmp);
124 	Lm_list		*lml = LIST(clmp);
125 
126 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
127 		return;
128 
129 	/*
130 	 * The core functionality of dlsym() can be called twice.  The first
131 	 * attempt can be affected by path names that exist in the "not-found"
132 	 * AVL tree.  Should a "not-found" path name be found, a second attempt
133 	 * is made to locate the required file (in_nfavl is NULL).  This fall-
134 	 * back provides for file system changes while a process executes.
135 	 */
136 	if (in_nfavl)
137 		retry = MSG_ORIG(MSG_STR_EMPTY);
138 	else
139 		retry = MSG_INTL(MSG_STR_RETRY);
140 
141 	switch (flag) {
142 	case DBG_DLSYM_NEXT:
143 		str = MSG_ORIG(MSG_SYM_NEXT);
144 		break;
145 	case DBG_DLSYM_DEFAULT:
146 		str = MSG_ORIG(MSG_SYM_DEFAULT);
147 		break;
148 	case DBG_DLSYM_SELF:
149 		str = MSG_ORIG(MSG_SYM_SELF);
150 		break;
151 	case DBG_DLSYM_PROBE:
152 		str = MSG_ORIG(MSG_SYM_PROBE);
153 		break;
154 	case DBG_DLSYM_SINGLETON:
155 		str = MSG_ORIG(MSG_SYM_SINGLETON);
156 		break;
157 	default:
158 		str = MSG_ORIG(MSG_STR_EMPTY);
159 	}
160 
161 	Dbg_util_nl(lml, DBG_NL_STD);
162 	if (next == 0)
163 		dbg_print(lml, MSG_INTL(MSG_SYM_DLSYM_1),
164 		    Dbg_demangle_name(sym), from, retry, str);
165 	else
166 		dbg_print(lml, MSG_INTL(MSG_SYM_DLSYM_2),
167 		    Dbg_demangle_name(sym), from, next, retry, str);
168 }
169 
170 void
171 Dbg_syms_lazy_rescan(Lm_list *lml, const char *name)
172 {
173 	if (DBG_NOTCLASS(DBG_C_SYMBOLS | DBG_C_FILES))
174 		return;
175 
176 	Dbg_util_nl(lml, DBG_NL_STD);
177 	dbg_print(lml, MSG_INTL(MSG_SYM_LAZY_RESCAN), Dbg_demangle_name(name));
178 }
179 
180 void
181 Dbg_syms_ar_title(Lm_list *lml, const char *file, int again)
182 {
183 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
184 		return;
185 
186 	Dbg_util_nl(lml, DBG_NL_STD);
187 	dbg_print(lml, MSG_INTL(MSG_SYM_AR_FILE), file,
188 	    again ? MSG_INTL(MSG_STR_AGAIN) : MSG_ORIG(MSG_STR_EMPTY));
189 }
190 
191 void
192 Dbg_syms_ar_entry(Lm_list *lml, Xword ndx, Elf_Arsym *arsym)
193 {
194 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
195 		return;
196 
197 	dbg_print(lml, MSG_INTL(MSG_SYM_AR_ENTRY), EC_XWORD(ndx),
198 	    Dbg_demangle_name(arsym->as_name));
199 }
200 
201 void
202 Dbg_syms_ar_checking(Lm_list *lml, Xword ndx, Elf_Arsym *arsym,
203     const char *name)
204 {
205 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
206 		return;
207 
208 	dbg_print(lml, MSG_INTL(MSG_SYM_AR_CHECK), EC_XWORD(ndx),
209 	    Dbg_demangle_name(arsym->as_name), name);
210 }
211 
212 void
213 Dbg_syms_ar_resolve(Lm_list *lml, Xword ndx, Elf_Arsym *arsym,
214     const char *fname, int flag)
215 {
216 	const char	*fmt;
217 
218 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
219 		return;
220 
221 	if (flag)
222 		fmt = MSG_INTL(MSG_SYM_AR_FORCEDEXRT);
223 	else
224 		fmt = MSG_INTL(MSG_SYM_AR_RESOLVE);
225 
226 	dbg_print(lml, fmt, EC_XWORD(ndx), Dbg_demangle_name(arsym->as_name),
227 	    fname);
228 }
229 
230 void
231 Dbg_syms_spec_title(Lm_list *lml)
232 {
233 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
234 		return;
235 
236 	Dbg_util_nl(lml, DBG_NL_STD);
237 	dbg_print(lml, MSG_INTL(MSG_SYM_SPECIAL));
238 }
239 
240 void
241 Dbg_syms_discarded(Lm_list *lml, Sym_desc *sdp)
242 {
243 	dbg_isec_name_buf_t	buf;
244 	char			*alloc_mem;
245 	const char		*file;
246 
247 	if (DBG_NOTCLASS(DBG_C_SYMBOLS | DBG_C_UNUSED))
248 		return;
249 	if (DBG_NOTDETAIL())
250 		return;
251 
252 	if ((sdp->sd_file == NULL) || ((file = sdp->sd_file->ifl_name) == NULL))
253 		file = MSG_INTL(MSG_STR_UNKNOWN);
254 
255 	if (sdp->sd_isc) {
256 		dbg_print(lml, MSG_INTL(MSG_SYM_DISCARD_SEC),
257 		    Dbg_demangle_name(sdp->sd_name),
258 		    dbg_fmt_isec_name(sdp->sd_isc, buf, &alloc_mem), file);
259 		if (alloc_mem != NULL)
260 			free(alloc_mem);
261 	} else
262 		dbg_print(lml, MSG_INTL(MSG_SYM_DISCARD_FILE),
263 		    Dbg_demangle_name(sdp->sd_name), file);
264 }
265 
266 void
267 Dbg_syms_dup_discarded(Lm_list *lml, Word ndx, Sym_desc *sdp)
268 {
269 	const char	*file;
270 
271 	if (DBG_NOTCLASS(DBG_C_SYMBOLS | DBG_C_UNUSED))
272 		return;
273 	if (DBG_NOTDETAIL())
274 		return;
275 
276 	if ((sdp->sd_file == NULL) || ((file = sdp->sd_file->ifl_name) == NULL))
277 		file = MSG_INTL(MSG_STR_UNKNOWN);
278 
279 	dbg_print(lml, MSG_INTL(MSG_SYM_DISCARD_DUP), EC_WORD(ndx),
280 	    Dbg_demangle_name(sdp->sd_name), file);
281 }
282 
283 void
284 Dbg_syms_entered(Ofl_desc *ofl, Sym *sym, Sym_desc *sdp)
285 {
286 	Conv_inv_buf_t	inv_buf;
287 	Lm_list		*lml = ofl->ofl_lml;
288 
289 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
290 		return;
291 	if (DBG_NOTDETAIL())
292 		return;
293 
294 	Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_INTL(MSG_STR_ENTERED),
295 	    ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine, sym,
296 	    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
297 	    conv_def_tag(sdp->sd_ref, &inv_buf));
298 }
299 
300 void
301 Dbg_syms_process(Lm_list *lml, Ifl_desc *ifl)
302 {
303 	Conv_inv_buf_t	inv_buf;
304 
305 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
306 		return;
307 
308 	Dbg_util_nl(lml, DBG_NL_STD);
309 	dbg_print(lml, MSG_INTL(MSG_SYM_PROCESS), ifl->ifl_name,
310 	    conv_ehdr_type(ifl->ifl_ehdr->e_ident[EI_OSABI],
311 	    ifl->ifl_ehdr->e_type, 0, &inv_buf));
312 }
313 
314 void
315 Dbg_syms_entry(Lm_list *lml, Word ndx, Sym_desc *sdp)
316 {
317 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
318 		return;
319 
320 	dbg_print(lml, MSG_INTL(MSG_SYM_BASIC), EC_WORD(ndx),
321 	    Dbg_demangle_name(sdp->sd_name));
322 }
323 
324 void
325 Dbg_syms_global(Lm_list *lml, Word ndx, const char *name)
326 {
327 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
328 		return;
329 
330 	dbg_print(lml, MSG_INTL(MSG_SYM_ADDING), EC_WORD(ndx),
331 	    Dbg_demangle_name(name));
332 }
333 
334 void
335 Dbg_syms_cap_convert(Ofl_desc *ofl, Word ndx, const char *name, Sym *sym)
336 {
337 	if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_SYMBOLS))
338 		return;
339 
340 	dbg_print(ofl->ofl_lml, MSG_INTL(MSG_SYM_CAP_ORIG), EC_WORD(ndx),
341 	    Dbg_demangle_name(name));
342 
343 	if (DBG_NOTDETAIL())
344 		return;
345 
346 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD,
347 	    MSG_INTL(MSG_STR_ORIGINAL), ofl->ofl_dehdr->e_ident[EI_OSABI],
348 	    ofl->ofl_dehdr->e_machine, sym, 0, 0, NULL,
349 	    MSG_ORIG(MSG_STR_EMPTY));
350 }
351 
352 void
353 Dbg_syms_cap_local(Ofl_desc *ofl, Word ndx, const char *name, Sym *sym,
354     Sym_desc *sdp)
355 {
356 	Conv_inv_buf_t	inv_buf;
357 
358 	if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_SYMBOLS))
359 		return;
360 
361 	dbg_print(ofl->ofl_lml, MSG_INTL(MSG_SYM_CAP_LOCAL), EC_WORD(ndx),
362 	    Dbg_demangle_name(name));
363 
364 	if (DBG_NOTDETAIL())
365 		return;
366 
367 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD,
368 	    MSG_INTL(MSG_STR_ENTERED), ofl->ofl_dehdr->e_ident[EI_OSABI],
369 	    ofl->ofl_dehdr->e_machine, sym,
370 	    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
371 	    conv_def_tag(sdp->sd_ref, &inv_buf));
372 }
373 
374 void
375 Dbg_syms_wrap(Lm_list *lml, Word ndx, const char *orig_name, const char *name)
376 {
377 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
378 		return;
379 
380 	dbg_print(lml, MSG_INTL(MSG_SYM_WRAP), EC_WORD(ndx),
381 	    Dbg_demangle_name(orig_name), Dbg_demangle_name(name));
382 }
383 
384 void
385 Dbg_syms_sec_title(Lm_list *lml)
386 {
387 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
388 		return;
389 	if (DBG_NOTDETAIL())
390 		return;
391 
392 	Dbg_util_nl(lml, DBG_NL_STD);
393 	dbg_print(lml, MSG_INTL(MSG_SYM_INDEX));
394 }
395 
396 void
397 Dbg_syms_sec_entry(Lm_list *lml, Word ndx, Sg_desc *sgp, Os_desc *osp)
398 {
399 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
400 		return;
401 	if (DBG_NOTDETAIL())
402 		return;
403 
404 	dbg_print(lml, MSG_INTL(MSG_SYM_SECTION), EC_WORD(ndx), osp->os_name,
405 	    (*sgp->sg_name ? sgp->sg_name : MSG_INTL(MSG_STR_NULL)));
406 }
407 
408 void
409 Dbg_syms_up_title(Lm_list *lml)
410 {
411 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
412 		return;
413 	if (DBG_NOTDETAIL())
414 		return;
415 
416 	Dbg_util_nl(lml, DBG_NL_STD);
417 	dbg_print(lml, MSG_INTL(MSG_SYM_FINAL));
418 	Elf_syms_table_title(lml, ELF_DBG_LD);
419 }
420 
421 void
422 Dbg_syms_ignore(Ofl_desc *ofl, Sym_desc *sdp)
423 {
424 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
425 		return;
426 	if (DBG_NOTDETAIL())
427 		return;
428 
429 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD, MSG_INTL(MSG_STR_IGNORE),
430 	    ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
431 	    sdp->sd_sym, 0, 0, NULL, MSG_INTL(MSG_STR_UNUSED));
432 }
433 
434 void
435 Dbg_syms_old(Ofl_desc *ofl, Sym_desc *sdp)
436 {
437 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
438 		return;
439 	if (DBG_NOTDETAIL())
440 		return;
441 
442 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD, MSG_INTL(MSG_STR_OLD),
443 	    ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
444 	    sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0,
445 	    0, NULL, sdp->sd_name);
446 }
447 
448 void
449 Dbg_syms_new(Ofl_desc *ofl, Sym *sym, Sym_desc *sdp)
450 {
451 	Conv_inv_buf_t	inv_buf;
452 
453 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
454 		return;
455 	if (DBG_NOTDETAIL())
456 		return;
457 
458 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD, MSG_INTL(MSG_STR_NEW),
459 	    ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine, sym,
460 	    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
461 	    conv_def_tag(sdp->sd_ref, &inv_buf));
462 }
463 
464 void
465 Dbg_syms_updated(Ofl_desc *ofl, Sym_desc *sdp, const char *name)
466 {
467 	Conv_inv_buf_t	inv_buf;
468 	Lm_list		*lml = ofl->ofl_lml;
469 
470 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
471 		return;
472 
473 	dbg_print(lml, MSG_INTL(MSG_SYM_UPDATE), name);
474 
475 	if (DBG_NOTDETAIL())
476 		return;
477 
478 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD, MSG_ORIG(MSG_STR_EMPTY),
479 	    ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
480 	    sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
481 	    conv_def_tag(sdp->sd_ref, &inv_buf));
482 }
483 
484 void
485 Dbg_syms_created(Lm_list *lml, const char *name)
486 {
487 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
488 		return;
489 
490 	dbg_print(lml, MSG_INTL(MSG_SYM_CREATE), Dbg_demangle_name(name));
491 }
492 
493 void
494 Dbg_syms_resolving(Ofl_desc *ofl, Word ndx, const char *name, int row,
495     int col, Sym *osym, Sym *nsym, Sym_desc *sdp, Ifl_desc *ifl)
496 {
497 	Lm_list	*lml = ofl->ofl_lml;
498 	uchar_t	osabi = ofl->ofl_dehdr->e_ident[EI_OSABI];
499 	Half	mach = ofl->ofl_dehdr->e_machine;
500 
501 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
502 		return;
503 
504 	dbg_print(lml, MSG_INTL(MSG_SYM_RESOLVING), EC_WORD(ndx),
505 	    Dbg_demangle_name(name), row, col);
506 
507 	if (DBG_NOTDETAIL())
508 		return;
509 
510 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD, MSG_INTL(MSG_STR_OLD),
511 	    osabi, mach, osym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0,
512 	    0, NULL, sdp->sd_file->ifl_name);
513 
514 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD, MSG_INTL(MSG_STR_NEW),
515 	    osabi, mach, nsym, 0, 0, NULL, ifl->ifl_name);
516 }
517 
518 void
519 Dbg_syms_resolved(Ofl_desc *ofl, Sym_desc *sdp)
520 {
521 	Conv_inv_buf_t	inv_buf;
522 
523 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
524 		return;
525 	if (DBG_NOTDETAIL())
526 		return;
527 
528 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD,
529 	    MSG_INTL(MSG_STR_RESOLVED), ofl->ofl_dehdr->e_ident[EI_OSABI],
530 	    ofl->ofl_dehdr->e_machine, sdp->sd_sym,
531 	    sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
532 	    conv_def_tag(sdp->sd_ref, &inv_buf));
533 }
534 
535 void
536 Dbg_syms_reloc(Ofl_desc *ofl, Sym_desc *sdp)
537 {
538 	static Boolean	symbol_title = TRUE;
539 	Conv_inv_buf_t	inv_buf;
540 	Lm_list	*lml = ofl->ofl_lml;
541 
542 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
543 		return;
544 
545 	if (symbol_title) {
546 		Dbg_util_nl(lml, DBG_NL_STD);
547 		dbg_print(lml, MSG_INTL(MSG_SYM_BSS));
548 
549 		symbol_title = FALSE;
550 	}
551 	dbg_print(lml, MSG_INTL(MSG_SYM_UPDATE),
552 	    Dbg_demangle_name(sdp->sd_name));
553 
554 	if (DBG_NOTDETAIL())
555 		return;
556 
557 	Elf_syms_table_entry(lml, ELF_DBG_LD, MSG_ORIG(MSG_SYM_COPY),
558 	    ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
559 	    sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
560 	    conv_def_tag(sdp->sd_ref, &inv_buf));
561 }
562 
563 void
564 Dbg_syms_reduce(Ofl_desc *ofl, int which, Sym_desc *sdp, int idx,
565     const char *sname)
566 {
567 	static Boolean	sym_reduce_title = TRUE;
568 	static Boolean	sym_retain_title = TRUE;
569 	Boolean		isfromglobal = (which == DBG_SYM_REDUCE_GLOBAL);
570 	Boolean		isfromretain = (which == DBG_SYM_REDUCE_RETAIN);
571 	Lm_list		*lml = ofl->ofl_lml;
572 
573 	if (DBG_NOTCLASS(DBG_C_SYMBOLS | DBG_C_VERSIONS))
574 		return;
575 
576 	if (sym_reduce_title && isfromglobal) {
577 		sym_reduce_title = FALSE;
578 		Dbg_util_nl(lml, DBG_NL_STD);
579 		dbg_print(lml, MSG_INTL(MSG_SYM_REDUCED));
580 	} else if (sym_retain_title && isfromretain) {
581 		sym_retain_title = FALSE;
582 		Dbg_util_nl(lml, DBG_NL_STD);
583 		dbg_print(lml, MSG_INTL(MSG_SYM_RETAINING));
584 	}
585 
586 	if ((sdp->sd_flags & FLG_SY_ELIM) && isfromglobal)
587 		dbg_print(lml, MSG_INTL(MSG_SYM_ELIMINATING),
588 		    Dbg_demangle_name(sdp->sd_name));
589 	else if (isfromglobal)
590 		dbg_print(lml, MSG_INTL(MSG_SYM_REDUCING),
591 		    Dbg_demangle_name(sdp->sd_name));
592 	else
593 		dbg_print(lml, MSG_INTL(MSG_SYM_NOTELIMINATE),
594 		    Dbg_demangle_name(sdp->sd_name), sname, idx);
595 
596 	if (DBG_NOTDETAIL())
597 		return;
598 
599 	Elf_syms_table_entry(ofl->ofl_lml, ELF_DBG_LD, MSG_ORIG(MSG_SYM_LOCAL),
600 	    ofl->ofl_dehdr->e_ident[EI_OSABI], ofl->ofl_dehdr->e_machine,
601 	    sdp->sd_sym, sdp->sd_aux ? sdp->sd_aux->sa_overndx : 0, 0, NULL,
602 	    sdp->sd_file->ifl_name);
603 }
604 
605 void
606 Dbg_syms_dup_sort_addr(Lm_list *lml, const char *secname, const char *symname1,
607     const char *symname2, Addr addr)
608 {
609 	if (DBG_NOTCLASS(DBG_C_SYMBOLS) || DBG_NOTDETAIL())
610 		return;
611 
612 	dbg_print(lml, MSG_INTL(MSG_SYM_DUPSORTADDR), secname,
613 	    symname1, symname2, EC_ADDR(addr));
614 }
615 
616 void
617 Dbg_syminfo_title(Lm_list *lml)
618 {
619 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
620 		return;
621 	if (DBG_NOTDETAIL())
622 		return;
623 
624 	Dbg_util_nl(lml, DBG_NL_STD);
625 	dbg_print(lml, MSG_INTL(MSG_SYMINFO_INFO));
626 	Elf_syminfo_title(lml);
627 }
628 
629 void
630 Dbg_syminfo_entry(Lm_list *lml, Word ndx, Syminfo *sip, Sym *sym,
631     const char *strtab, Dyn *dyn)
632 {
633 	const char	*needed;
634 
635 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
636 		return;
637 	if (DBG_NOTDETAIL())
638 		return;
639 
640 	if (sip->si_boundto < SYMINFO_BT_LOWRESERVE)
641 		needed = strtab + dyn[sip->si_boundto].d_un.d_val;
642 	else
643 		needed = 0;
644 
645 	Elf_syminfo_entry(lml, ndx, sip,
646 	    Dbg_demangle_name(strtab + sym->st_name), needed);
647 }
648 
649 /*
650  * Symbol table output can differ slightly depending on the caller.  However,
651  * the final diagnostic is maintained here so hat the various message strings
652  * remain consistent
653  *
654  * elfdump:   index    value       size     type bind oth ver shndx       name
655  * ld:                 value       size     type bind oth ver shndx
656  */
657 void
658 Elf_syms_table_title(Lm_list *lml, int caller)
659 {
660 	if (caller == ELF_DBG_ELFDUMP) {
661 		if (DBG_NOTLONG())
662 			dbg_print(lml, MSG_INTL(MSG_SYM_EFS_TITLE));
663 		else
664 			dbg_print(lml, MSG_INTL(MSG_SYM_EFL_TITLE));
665 		return;
666 	}
667 
668 	if (caller == ELF_DBG_LD) {
669 		if (DBG_NOTLONG())
670 			dbg_print(lml, MSG_INTL(MSG_SYM_LDS_TITLE));
671 		else
672 			dbg_print(lml, MSG_INTL(MSG_SYM_LDL_TITLE));
673 		return;
674 	}
675 }
676 
677 void
678 Elf_syms_table_entry(Lm_list *lml, int caller, const char *prestr,
679     uchar_t osabi, Half mach, Sym *sym, Versym verndx, int gnuver,
680     const char *sec, const char *poststr)
681 {
682 	Conv_inv_buf_t	inv_buf1, inv_buf2, inv_buf3;
683 	Conv_inv_buf_t	inv_buf4, inv_buf5, inv_buf6;
684 	uchar_t		type = ELF_ST_TYPE(sym->st_info);
685 	uchar_t		bind = ELF_ST_BIND(sym->st_info);
686 	const char	*msg;
687 
688 	if ((caller == ELF_DBG_ELFDUMP) ||
689 	    (caller == ELF_DBG_LD)) {
690 		if (DBG_NOTLONG())
691 			msg = MSG_INTL(MSG_SYM_EFS_ENTRY);
692 		else
693 			msg = MSG_INTL(MSG_SYM_EFL_ENTRY);
694 
695 		if (sec == NULL)
696 			sec = conv_sym_shndx(osabi, mach, sym->st_shndx,
697 			    CONV_FMT_DECIMAL, &inv_buf6);
698 
699 		dbg_print(lml, msg, prestr,
700 		    conv_sym_value(mach, type, sym->st_value, &inv_buf1),
701 		    sym->st_size, conv_sym_info_type(mach, type, 0, &inv_buf2),
702 		    conv_sym_info_bind(bind, 0, &inv_buf3),
703 		    conv_sym_other(sym->st_other, &inv_buf4),
704 		    conv_ver_index(verndx, gnuver, &inv_buf5),
705 		    sec, Elf_demangle_name(poststr));
706 	}
707 }
708 
709 void
710 Dbg_syms_cap_title(Ofl_desc *ofl)
711 {
712 	Lm_list	*lml = ofl->ofl_lml;
713 
714 	if (DBG_NOTCLASS(DBG_C_SYMBOLS))
715 		return;
716 	if (DBG_NOTDETAIL())
717 		return;
718 
719 	Dbg_util_nl(lml, DBG_NL_STD);
720 	dbg_print(lml, MSG_INTL(MSG_SYM_CAPABILITIES));
721 	Elf_syms_table_title(lml, ELF_DBG_LD);
722 }
723