xref: /onnv-gate/usr/src/cmd/sgs/liblddbg/common/libs.c (revision 12877:69001e4756ae)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51618Srie  * Common Development and Distribution License (the "License").
61618Srie  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211618Srie 
220Sstevel@tonic-gate /*
23*12877SRod.Evans@Sun.COM  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate #include	"msg.h"
260Sstevel@tonic-gate #include	"_debug.h"
270Sstevel@tonic-gate #include	"libld.h"
280Sstevel@tonic-gate 
291618Srie void
Dbg_libs_audit(Lm_list * lml,const char * opath,const char * npath)301618Srie Dbg_libs_audit(Lm_list *lml, const char *opath, const char *npath)
311618Srie {
32*12877SRod.Evans@Sun.COM 	if (DBG_NOTCLASS(DBG_C_LIBS))
331618Srie 		return;
341618Srie 
351618Srie 	if (npath == opath)
361618Srie 		return;
37*12877SRod.Evans@Sun.COM 
38*12877SRod.Evans@Sun.COM 	if (npath == NULL)
391618Srie 		dbg_print(lml, MSG_INTL(MSG_LIB_SKIP), opath);
401618Srie 	else
411618Srie 		dbg_print(lml, MSG_INTL(MSG_LIB_ALTER), npath);
421618Srie }
431618Srie 
441618Srie void
Dbg_libs_find(Lm_list * lml,const char * name)451618Srie Dbg_libs_find(Lm_list *lml, const char *name)
461618Srie {
471618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
481618Srie 		return;
491618Srie 
501618Srie 	Dbg_util_nl(lml, DBG_NL_STD);
511618Srie 	dbg_print(lml, MSG_INTL(MSG_LIB_FIND), name);
521618Srie }
531618Srie 
541618Srie void
Dbg_libs_found(Lm_list * lml,const char * path,int alter)551618Srie Dbg_libs_found(Lm_list *lml, const char *path, int alter)
561618Srie {
571618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
581618Srie 		return;
591618Srie 
601618Srie 	dbg_print(lml, MSG_INTL(MSG_LIB_TRYING), path, alter ?
611618Srie 	    MSG_INTL(MSG_STR_ALTER) : MSG_ORIG(MSG_STR_EMPTY));
621618Srie }
631618Srie 
641618Srie void
Dbg_libs_insecure(Lm_list * lml,const char * path,int usable)657668SRod.Evans@Sun.COM Dbg_libs_insecure(Lm_list *lml, const char *path, int usable)
661618Srie {
671618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
681618Srie 		return;
691618Srie 
707668SRod.Evans@Sun.COM 	if (usable)
717668SRod.Evans@Sun.COM 		dbg_print(lml, MSG_INTL(MSG_LIB_INUSE), path);
727668SRod.Evans@Sun.COM 	else
737668SRod.Evans@Sun.COM 		dbg_print(lml, MSG_INTL(MSG_LIB_IGNORE), path);
741618Srie }
751618Srie 
760Sstevel@tonic-gate static void
Dbg_lib_dir_print(Lm_list * lml,APlist * libdir)779131SRod.Evans@Sun.COM Dbg_lib_dir_print(Lm_list *lml, APlist *libdir)
780Sstevel@tonic-gate {
799131SRod.Evans@Sun.COM 	Aliste	idx;
809131SRod.Evans@Sun.COM 	char	*cp;
810Sstevel@tonic-gate 
829131SRod.Evans@Sun.COM 	for (APLIST_TRAVERSE(libdir, idx, cp))
831618Srie 		dbg_print(lml, MSG_ORIG(MSG_LIB_FILE), cp);
840Sstevel@tonic-gate }
850Sstevel@tonic-gate 
860Sstevel@tonic-gate void
Dbg_libs_init(Lm_list * lml,APlist * ulibdir,APlist * dlibdir)879131SRod.Evans@Sun.COM Dbg_libs_init(Lm_list *lml, APlist *ulibdir, APlist *dlibdir)
880Sstevel@tonic-gate {
891618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
900Sstevel@tonic-gate 		return;
910Sstevel@tonic-gate 
921618Srie 	dbg_print(lml, MSG_INTL(MSG_LIB_INITPATH));
931618Srie 	Dbg_lib_dir_print(lml, ulibdir);
941618Srie 	Dbg_lib_dir_print(lml, dlibdir);
950Sstevel@tonic-gate }
960Sstevel@tonic-gate 
970Sstevel@tonic-gate void
Dbg_libs_l(Lm_list * lml,const char * name,const char * path)981618Srie Dbg_libs_l(Lm_list *lml, const char *name, const char *path)
990Sstevel@tonic-gate {
1001618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
1010Sstevel@tonic-gate 		return;
1020Sstevel@tonic-gate 	if (DBG_NOTDETAIL())
1030Sstevel@tonic-gate 		return;
1040Sstevel@tonic-gate 
1051618Srie 	dbg_print(lml, MSG_INTL(MSG_LIB_LOPT), name, path);
1060Sstevel@tonic-gate }
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate void
Dbg_libs_path(Lm_list * lml,const char * path,uint_t orig,const char * obj)1096387Srie Dbg_libs_path(Lm_list *lml, const char *path, uint_t orig, const char *obj)
1100Sstevel@tonic-gate {
1110Sstevel@tonic-gate 	const char	*fmt;
1127785SRod.Evans@Sun.COM 	uint_t		search;
1130Sstevel@tonic-gate 
1147785SRod.Evans@Sun.COM 	if (path == NULL)
1150Sstevel@tonic-gate 		return;
1161618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
1170Sstevel@tonic-gate 		return;
1180Sstevel@tonic-gate 
1197785SRod.Evans@Sun.COM 	search = orig &
1207785SRod.Evans@Sun.COM 	    (LA_SER_LIBPATH | LA_SER_RUNPATH | LA_SER_DEFAULT | LA_SER_SECURE);
1217785SRod.Evans@Sun.COM 
1227785SRod.Evans@Sun.COM 	switch (search) {
1237785SRod.Evans@Sun.COM 	case LA_SER_LIBPATH:
1240Sstevel@tonic-gate 		if (orig & LA_SER_CONFIG)
1250Sstevel@tonic-gate 			fmt = MSG_INTL(MSG_LIB_LDLIBPATHC);
1260Sstevel@tonic-gate 		else
1270Sstevel@tonic-gate 			fmt = MSG_INTL(MSG_LIB_LDLIBPATH);
1287785SRod.Evans@Sun.COM 		break;
1297785SRod.Evans@Sun.COM 
1307785SRod.Evans@Sun.COM 	case LA_SER_RUNPATH:
1313511Srie 		fmt = MSG_INTL(MSG_LIB_RUNPATH);
1327785SRod.Evans@Sun.COM 		break;
1337785SRod.Evans@Sun.COM 
1347785SRod.Evans@Sun.COM 	case LA_SER_DEFAULT:
1350Sstevel@tonic-gate 		if (orig & LA_SER_CONFIG)
1360Sstevel@tonic-gate 			fmt = MSG_INTL(MSG_LIB_DEFAULTC);
1370Sstevel@tonic-gate 		else
1380Sstevel@tonic-gate 			fmt = MSG_INTL(MSG_LIB_DEFAULT);
1397785SRod.Evans@Sun.COM 		break;
1407785SRod.Evans@Sun.COM 
1417785SRod.Evans@Sun.COM 	case LA_SER_SECURE:
1427785SRod.Evans@Sun.COM 		if (orig & LA_SER_CONFIG)
1437785SRod.Evans@Sun.COM 			fmt = MSG_INTL(MSG_LIB_TDEFAULTC);
1447785SRod.Evans@Sun.COM 		else
1457785SRod.Evans@Sun.COM 			fmt = MSG_INTL(MSG_LIB_TDEFAULT);
1467785SRod.Evans@Sun.COM 		break;
1477785SRod.Evans@Sun.COM 
1487785SRod.Evans@Sun.COM 	default:
1497785SRod.Evans@Sun.COM 		return;
1500Sstevel@tonic-gate 	}
1517785SRod.Evans@Sun.COM 
1521618Srie 	dbg_print(lml, fmt, path, obj);
1530Sstevel@tonic-gate }
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate void
Dbg_libs_req(Lm_list * lml,const char * so_name,const char * ref_file,const char * name)1561618Srie Dbg_libs_req(Lm_list *lml, const char *so_name, const char *ref_file,
1571618Srie     const char *name)
1580Sstevel@tonic-gate {
1591618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
1600Sstevel@tonic-gate 		return;
1610Sstevel@tonic-gate 	if (DBG_NOTDETAIL())
1620Sstevel@tonic-gate 		return;
1630Sstevel@tonic-gate 
1641618Srie 	dbg_print(lml, MSG_INTL(MSG_LIB_REQUIRED), so_name, name, ref_file);
1650Sstevel@tonic-gate }
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate void
Dbg_libs_update(Lm_list * lml,APlist * ulibdir,APlist * dlibdir)1689131SRod.Evans@Sun.COM Dbg_libs_update(Lm_list *lml, APlist *ulibdir, APlist *dlibdir)
1690Sstevel@tonic-gate {
1701618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
1710Sstevel@tonic-gate 		return;
1720Sstevel@tonic-gate 
1731618Srie 	dbg_print(lml, MSG_INTL(MSG_LIB_UPPATH));
1741618Srie 	Dbg_lib_dir_print(lml, ulibdir);
1751618Srie 	Dbg_lib_dir_print(lml, dlibdir);
1760Sstevel@tonic-gate }
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate void
Dbg_libs_yp(Lm_list * lml,const char * path)1791618Srie Dbg_libs_yp(Lm_list *lml, const char *path)
1800Sstevel@tonic-gate {
1811618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
1820Sstevel@tonic-gate 		return;
1830Sstevel@tonic-gate 
1841618Srie 	dbg_print(lml, MSG_INTL(MSG_LIB_LIBPATH), path);
1850Sstevel@tonic-gate }
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate void
Dbg_libs_ylu(Lm_list * lml,const char * path,const char * orig,int index)1881618Srie Dbg_libs_ylu(Lm_list *lml, const char *path, const char *orig, int index)
1890Sstevel@tonic-gate {
1901618Srie 	if (DBG_NOTCLASS(DBG_C_LIBS))
1910Sstevel@tonic-gate 		return;
1920Sstevel@tonic-gate 
1931618Srie 	dbg_print(lml, MSG_INTL(MSG_LIB_YPATH), path, orig,
1941618Srie 	    (index == YLDIR) ? 'L' : 'U');
1950Sstevel@tonic-gate }
196