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