xref: /titanic_50/usr/src/cmd/sgs/liblddbg/common/version.c (revision 20272c2e66d77f79ef35e7160584b5d098c3287f)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
215aefb655Srie 
227c478bd9Sstevel@tonic-gate /*
23*20272c2eSAli Bahrami  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
27a194faf8Srie #include	<stdio.h>
285aefb655Srie #include	<debug.h>
297c478bd9Sstevel@tonic-gate #include	"msg.h"
307c478bd9Sstevel@tonic-gate #include	"_debug.h"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate void
Dbg_ver_avail_title(Lm_list * lml,const char * file)335aefb655Srie Dbg_ver_avail_title(Lm_list *lml, const char *file)
347c478bd9Sstevel@tonic-gate {
355aefb655Srie 	if (DBG_NOTCLASS(DBG_C_VERSIONS))
365aefb655Srie 		return;
375aefb655Srie 
385aefb655Srie 	Dbg_util_nl(lml, DBG_NL_STD);
395aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_AVAIL_1), file);
405aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_AVAIL_2));
417c478bd9Sstevel@tonic-gate }
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate void
Dbg_ver_def_title(Lm_list * lml,const char * file)445aefb655Srie Dbg_ver_def_title(Lm_list *lml, const char *file)
457c478bd9Sstevel@tonic-gate {
465aefb655Srie 	if (DBG_NOTCLASS(DBG_C_VERSIONS))
475aefb655Srie 		return;
485aefb655Srie 
495aefb655Srie 	Dbg_util_nl(lml, DBG_NL_STD);
505aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_DEF_TITLE), file);
515aefb655Srie 	Elf_ver_def_title(lml);
527c478bd9Sstevel@tonic-gate }
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate void
Dbg_ver_need_title(Lm_list * lml,const char * file)555aefb655Srie Dbg_ver_need_title(Lm_list *lml, const char *file)
567c478bd9Sstevel@tonic-gate {
575aefb655Srie 	if (DBG_NOTCLASS(DBG_C_VERSIONS))
585aefb655Srie 		return;
595aefb655Srie 
605aefb655Srie 	Dbg_util_nl(lml, DBG_NL_STD);
615aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_NEED_TITLE), file);
62d840867fSab196087 	Elf_ver_need_title(lml, 0);
635aefb655Srie }
645aefb655Srie 
655aefb655Srie void
Dbg_ver_need_entry(Lm_list * lml,Half cnt,const char * file,const char * version)665aefb655Srie Dbg_ver_need_entry(Lm_list *lml, Half cnt, const char *file,
675aefb655Srie     const char *version)
685aefb655Srie {
695aefb655Srie 	if (DBG_NOTCLASS(DBG_C_VERSIONS))
705aefb655Srie 		return;
715aefb655Srie 
725aefb655Srie 	if (cnt)
735aefb655Srie 		Elf_ver_line_4(lml, version);
747c478bd9Sstevel@tonic-gate 	else
755aefb655Srie 		Elf_ver_line_5(lml, file, version);
767c478bd9Sstevel@tonic-gate }
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate void
Dbg_ver_symbol(Lm_list * lml,const char * name)795aefb655Srie Dbg_ver_symbol(Lm_list *lml, const char *name)
807c478bd9Sstevel@tonic-gate {
817c478bd9Sstevel@tonic-gate 	static Boolean	ver_symbol_title = TRUE;
827c478bd9Sstevel@tonic-gate 
835aefb655Srie 	if (DBG_NOTCLASS(DBG_C_VERSIONS | DBG_C_SYMBOLS))
847c478bd9Sstevel@tonic-gate 		return;
857c478bd9Sstevel@tonic-gate 
865aefb655Srie 	if (DBG_NOTCLASS(DBG_C_VERSIONS))
877c478bd9Sstevel@tonic-gate 		if (ver_symbol_title) {
887c478bd9Sstevel@tonic-gate 			ver_symbol_title = FALSE;
895aefb655Srie 			Dbg_util_nl(lml, DBG_NL_STD);
905aefb655Srie 			dbg_print(lml, MSG_INTL(MSG_SYM_VERSION));
917c478bd9Sstevel@tonic-gate 		}
927c478bd9Sstevel@tonic-gate 
935aefb655Srie 	Dbg_syms_created(lml, name);
947c478bd9Sstevel@tonic-gate }
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /*
977c478bd9Sstevel@tonic-gate  * This function doesn't test for any specific debugging category, thus it will
987c478bd9Sstevel@tonic-gate  * be generated for any debugging family.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate void
Dbg_ver_nointerface(Lm_list * lml,const char * name)1015aefb655Srie Dbg_ver_nointerface(Lm_list *lml, const char *name)
1027c478bd9Sstevel@tonic-gate {
1035aefb655Srie 	Dbg_util_nl(lml, DBG_NL_STD);
1045aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_NOINTERFACE), name);
1055aefb655Srie 	Dbg_util_nl(lml, DBG_NL_STD);
1067c478bd9Sstevel@tonic-gate }
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate void
Dbg_ver_desc_entry(Lm_list * lml,Ver_desc * vdp)1095aefb655Srie Dbg_ver_desc_entry(Lm_list *lml, Ver_desc *vdp)
1107c478bd9Sstevel@tonic-gate {
111090a8d9eSAli Bahrami 	Conv_ver_flags_buf_t	ver_flags_buf;
1127c478bd9Sstevel@tonic-gate 	const char		*dep;
1137c478bd9Sstevel@tonic-gate 	Ver_desc		*_vdp, *__vdp;
11457ef7aa9SRod Evans 	Aliste 			idx;
1157c478bd9Sstevel@tonic-gate 	char			index[10];
1167c478bd9Sstevel@tonic-gate 
1175aefb655Srie 	if (DBG_NOTCLASS(DBG_C_VERSIONS))
1187c478bd9Sstevel@tonic-gate 		return;
1197c478bd9Sstevel@tonic-gate 
12057ef7aa9SRod Evans 	if (vdp->vd_deps) {
12157ef7aa9SRod Evans 		_vdp = (Ver_desc *)vdp->vd_deps->apl_data[0];
1227c478bd9Sstevel@tonic-gate 		dep = _vdp->vd_name;
1237c478bd9Sstevel@tonic-gate 	} else {
1247c478bd9Sstevel@tonic-gate 		_vdp = 0;
1257c478bd9Sstevel@tonic-gate 		dep = MSG_ORIG(MSG_STR_EMPTY);
1267c478bd9Sstevel@tonic-gate 	}
1277c478bd9Sstevel@tonic-gate 	(void) sprintf(index, MSG_ORIG(MSG_FMT_INDEX), vdp->vd_ndx);
1285aefb655Srie 	Elf_ver_line_1(lml, index, vdp->vd_name, dep,
129090a8d9eSAli Bahrami 	    conv_ver_flags(vdp->vd_flags, 0, &ver_flags_buf));
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	/*
1327c478bd9Sstevel@tonic-gate 	 * Loop through the dependency list in case there are more that one
1337c478bd9Sstevel@tonic-gate 	 * dependency.
1347c478bd9Sstevel@tonic-gate 	 */
13557ef7aa9SRod Evans 	for (APLIST_TRAVERSE(vdp->vd_deps, idx, __vdp)) {
1367c478bd9Sstevel@tonic-gate 		if (_vdp == __vdp)
1377c478bd9Sstevel@tonic-gate 			continue;
1385aefb655Srie 		Elf_ver_line_4(lml, __vdp->vd_name);
1397c478bd9Sstevel@tonic-gate 	}
1407c478bd9Sstevel@tonic-gate }
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate void
Dbg_ver_avail_entry(Lm_list * lml,Ver_index * vip,const char * select)1435aefb655Srie Dbg_ver_avail_entry(Lm_list *lml, Ver_index *vip, const char *select)
1447c478bd9Sstevel@tonic-gate {
1455aefb655Srie 	if (DBG_NOTCLASS(DBG_C_VERSIONS))
1467c478bd9Sstevel@tonic-gate 		return;
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate 	if (select) {
1497c478bd9Sstevel@tonic-gate 		if (DBG_NOTLONG())
1505aefb655Srie 			dbg_print(lml, MSG_ORIG(MSG_VER_SELECTED),
1515aefb655Srie 			    vip->vi_name, select);
1527c478bd9Sstevel@tonic-gate 		else
1535aefb655Srie 			dbg_print(lml, MSG_ORIG(MSG_VER_L_SELECTED),
1547c478bd9Sstevel@tonic-gate 			    vip->vi_name, select);
1557c478bd9Sstevel@tonic-gate 	} else {
1567c478bd9Sstevel@tonic-gate 		if (DBG_NOTLONG())
1575aefb655Srie 			dbg_print(lml, MSG_ORIG(MSG_VER_ALL), vip->vi_name);
1587c478bd9Sstevel@tonic-gate 		else
1595aefb655Srie 			dbg_print(lml, MSG_ORIG(MSG_VER_L_ALL), vip->vi_name);
1607c478bd9Sstevel@tonic-gate 	}
1617c478bd9Sstevel@tonic-gate }
1625aefb655Srie 
1635aefb655Srie void
Elf_ver_def_title(Lm_list * lml)1645aefb655Srie Elf_ver_def_title(Lm_list *lml)
1655aefb655Srie {
1665aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_DEF));
1675aefb655Srie }
1685aefb655Srie 
169d840867fSab196087 /*
170d840867fSab196087  * entry:
171d840867fSab196087  *	gnuver - If True (non-zero), the version rules used by the
172d840867fSab196087  *		GNU ld are assumed. If False (0), Solaris ld rules apply.
173d840867fSab196087  */
1745aefb655Srie void
Elf_ver_need_title(Lm_list * lml,int gnuver)175d840867fSab196087 Elf_ver_need_title(Lm_list *lml, int gnuver)
1765aefb655Srie {
177d840867fSab196087 	if (gnuver)
178d840867fSab196087 		dbg_print(lml, MSG_INTL(MSG_VER_NEED_GNUVER));
179d840867fSab196087 	else
1805aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_VER_NEED));
1815aefb655Srie }
1825aefb655Srie 
1835aefb655Srie void
Elf_ver_line_1(Lm_list * lml,const char * index,const char * name,const char * dep,const char * flags)1845aefb655Srie Elf_ver_line_1(Lm_list *lml, const char *index, const char *name,
1855aefb655Srie     const char *dep, const char *flags)
1865aefb655Srie {
1875aefb655Srie 	if (DBG_NOTLONG())
1885aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_VER_LINE_1), index, name,
1895aefb655Srie 		    dep, flags);
1905aefb655Srie 	else
1915aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_VER_LLINE_1), index, name,
1925aefb655Srie 		    dep, flags);
1935aefb655Srie }
1945aefb655Srie 
1955aefb655Srie void
Elf_ver_line_2(Lm_list * lml,const char * name,const char * dep)1965aefb655Srie Elf_ver_line_2(Lm_list *lml, const char *name, const char *dep)
1975aefb655Srie {
1985aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_LINE_2), name, dep);
1995aefb655Srie }
2005aefb655Srie 
2015aefb655Srie void
Elf_ver_line_3(Lm_list * lml,const char * name,const char * dep,const char * flags)2025aefb655Srie Elf_ver_line_3(Lm_list *lml, const char *name, const char *dep,
2035aefb655Srie     const char *flags)
2045aefb655Srie {
2055aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_LINE_3), name, dep, flags);
2065aefb655Srie }
2075aefb655Srie 
2085aefb655Srie void
Elf_ver_line_4(Lm_list * lml,const char * version)2095aefb655Srie Elf_ver_line_4(Lm_list *lml, const char *version)
2105aefb655Srie {
2115aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_VER_LINE_4), version);
2125aefb655Srie }
2135aefb655Srie 
2145aefb655Srie void
Elf_ver_line_5(Lm_list * lml,const char * file,const char * version)2155aefb655Srie Elf_ver_line_5(Lm_list *lml, const char *file, const char *version)
2165aefb655Srie {
2175aefb655Srie 	if (DBG_NOTLONG())
2185aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_VER_LINE_5), file, version);
2195aefb655Srie 	else
2205aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_VER_LLINE_5), file, version);
2215aefb655Srie }
222*20272c2eSAli Bahrami 
223*20272c2eSAli Bahrami /*
224*20272c2eSAli Bahrami  * Called after final call to Dbg_ver_need() to inject final newline.
225*20272c2eSAli Bahrami  */
226*20272c2eSAli Bahrami void
Dbg_ver_need_done(Lm_list * lml)227*20272c2eSAli Bahrami Dbg_ver_need_done(Lm_list *lml)
228*20272c2eSAli Bahrami {
229*20272c2eSAli Bahrami 	if (DBG_NOTCLASS(DBG_C_VERSIONS))
230*20272c2eSAli Bahrami 		return;
231*20272c2eSAli Bahrami 
232*20272c2eSAli Bahrami 	Dbg_util_nl(lml, DBG_NL_STD);
233*20272c2eSAli Bahrami }
234