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