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