xref: /titanic_44/usr/src/cmd/sgs/liblddbg/common/libs.c (revision 55553f719b521a0bb4deab6efc944cd30c1a56aa)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include	"msg.h"
29 #include	"_debug.h"
30 #include	"libld.h"
31 
32 void
33 Dbg_libs_audit(Lm_list *lml, const char *opath, const char *npath)
34 {
35 	if (DBG_NOTCLASS(DBG_C_LIBS | DBG_C_AUDITING))
36 		return;
37 
38 	if (npath == opath)
39 		return;
40 	else if (npath == 0)
41 		dbg_print(lml, MSG_INTL(MSG_LIB_SKIP), opath);
42 	else
43 		dbg_print(lml, MSG_INTL(MSG_LIB_ALTER), npath);
44 }
45 
46 void
47 Dbg_libs_find(Lm_list *lml, const char *name)
48 {
49 	if (DBG_NOTCLASS(DBG_C_LIBS))
50 		return;
51 
52 	Dbg_util_nl(lml, DBG_NL_STD);
53 	dbg_print(lml, MSG_INTL(MSG_LIB_FIND), name);
54 }
55 
56 void
57 Dbg_libs_found(Lm_list *lml, const char *path, int alter)
58 {
59 	if (DBG_NOTCLASS(DBG_C_LIBS))
60 		return;
61 
62 	dbg_print(lml, MSG_INTL(MSG_LIB_TRYING), path, alter ?
63 	    MSG_INTL(MSG_STR_ALTER) : MSG_ORIG(MSG_STR_EMPTY));
64 }
65 
66 void
67 Dbg_libs_ignore(Lm_list *lml, const char *path)
68 {
69 	if (DBG_NOTCLASS(DBG_C_LIBS))
70 		return;
71 
72 	dbg_print(lml, MSG_INTL(MSG_LIB_IGNORE), path);
73 }
74 
75 static void
76 Dbg_lib_dir_print(Lm_list *lml, List *libdir)
77 {
78 	Listnode	*lnp;
79 	char		*cp;
80 
81 	for (LIST_TRAVERSE(libdir, lnp, cp))
82 		dbg_print(lml, MSG_ORIG(MSG_LIB_FILE), cp);
83 }
84 
85 void
86 Dbg_libs_init(Lm_list *lml, List *ulibdir, List *dlibdir)
87 {
88 	if (DBG_NOTCLASS(DBG_C_LIBS))
89 		return;
90 
91 	dbg_print(lml, MSG_INTL(MSG_LIB_INITPATH));
92 	Dbg_lib_dir_print(lml, ulibdir);
93 	Dbg_lib_dir_print(lml, dlibdir);
94 }
95 
96 void
97 Dbg_libs_l(Lm_list *lml, const char *name, const char *path)
98 {
99 	if (DBG_NOTCLASS(DBG_C_LIBS))
100 		return;
101 	if (DBG_NOTDETAIL())
102 		return;
103 
104 	dbg_print(lml, MSG_INTL(MSG_LIB_LOPT), name, path);
105 }
106 
107 void
108 Dbg_libs_path(Lm_list *lml, const char *path, Half orig, const char *obj)
109 {
110 	const char	*fmt;
111 
112 	if (path == (const char *)0)
113 		return;
114 	if (DBG_NOTCLASS(DBG_C_LIBS))
115 		return;
116 
117 	if (orig & LA_SER_LIBPATH) {
118 		if (orig & LA_SER_CONFIG)
119 			fmt = MSG_INTL(MSG_LIB_LDLIBPATHC);
120 		else
121 			fmt = MSG_INTL(MSG_LIB_LDLIBPATH);
122 	} else if (orig & LA_SER_RUNPATH) {
123 		fmt = MSG_INTL(MSG_LIB_RUNPATH);
124 	} else if (orig & LA_SER_DEFAULT) {
125 		if (orig & LA_SER_CONFIG)
126 			fmt = MSG_INTL(MSG_LIB_DEFAULTC);
127 		else
128 			fmt = MSG_INTL(MSG_LIB_DEFAULT);
129 	}
130 	dbg_print(lml, fmt, path, obj);
131 }
132 
133 void
134 Dbg_libs_req(Lm_list *lml, const char *so_name, const char *ref_file,
135     const char *name)
136 {
137 	if (DBG_NOTCLASS(DBG_C_LIBS))
138 		return;
139 	if (DBG_NOTDETAIL())
140 		return;
141 
142 	dbg_print(lml, MSG_INTL(MSG_LIB_REQUIRED), so_name, name, ref_file);
143 }
144 
145 void
146 Dbg_libs_update(Lm_list *lml, List *ulibdir, List *dlibdir)
147 {
148 	if (DBG_NOTCLASS(DBG_C_LIBS))
149 		return;
150 
151 	dbg_print(lml, MSG_INTL(MSG_LIB_UPPATH));
152 	Dbg_lib_dir_print(lml, ulibdir);
153 	Dbg_lib_dir_print(lml, dlibdir);
154 }
155 
156 void
157 Dbg_libs_yp(Lm_list *lml, const char *path)
158 {
159 	if (DBG_NOTCLASS(DBG_C_LIBS))
160 		return;
161 
162 	dbg_print(lml, MSG_INTL(MSG_LIB_LIBPATH), path);
163 }
164 
165 void
166 Dbg_libs_ylu(Lm_list *lml, const char *path, const char *orig, int index)
167 {
168 	if (DBG_NOTCLASS(DBG_C_LIBS))
169 		return;
170 
171 	dbg_print(lml, MSG_INTL(MSG_LIB_YPATH), path, orig,
172 	    (index == YLDIR) ? 'L' : 'U');
173 }
174