xref: /titanic_52/usr/src/cmd/sgs/liblddbg/common/libs.c (revision ea8dc4b6d2251b437950c0056bc626b311c73c27)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 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 static void
33 Dbg_lib_dir_print(List * libdir)
34 {
35 	Listnode	*lnp;
36 	char		*cp;
37 
38 	for (LIST_TRAVERSE(libdir, lnp, cp)) {
39 		dbg_print(MSG_ORIG(MSG_LIB_FILE), cp);
40 	}
41 }
42 
43 void
44 Dbg_libs_init(List * ulibdir, List * dlibdir)
45 {
46 	if (DBG_NOTCLASS(DBG_LIBS))
47 		return;
48 
49 	dbg_print(MSG_INTL(MSG_LIB_INITPATH));
50 	Dbg_lib_dir_print(ulibdir);
51 	Dbg_lib_dir_print(dlibdir);
52 }
53 
54 void
55 Dbg_libs_l(const char *name, const char *path)
56 {
57 	if (DBG_NOTCLASS(DBG_LIBS))
58 		return;
59 	if (DBG_NOTDETAIL())
60 		return;
61 
62 	dbg_print(MSG_INTL(MSG_LIB_LOPT), name, path);
63 }
64 
65 void
66 Dbg_libs_path(const char *path, Half orig, const char *obj)
67 {
68 	const char	*fmt;
69 
70 	if (path == (const char *)0)
71 		return;
72 	if (DBG_NOTCLASS(DBG_LIBS))
73 		return;
74 
75 	if (orig & LA_SER_LIBPATH) {
76 		if (orig & LA_SER_CONFIG)
77 			fmt = MSG_INTL(MSG_LIB_LDLIBPATHC);
78 		else
79 			fmt = MSG_INTL(MSG_LIB_LDLIBPATH);
80 	} else if (orig & LA_SER_RUNPATH) {
81 		fmt = MSG_INTL(MSG_LIB_RPATH);
82 	} else if (orig & LA_SER_DEFAULT) {
83 		if (orig & LA_SER_CONFIG)
84 			fmt = MSG_INTL(MSG_LIB_DEFAULTC);
85 		else
86 			fmt = MSG_INTL(MSG_LIB_DEFAULT);
87 	}
88 	dbg_print(fmt, path, obj);
89 }
90 
91 void
92 Dbg_libs_req(const char *so_name, const char *ref_file, const char *name)
93 {
94 	if (DBG_NOTCLASS(DBG_LIBS))
95 		return;
96 	if (DBG_NOTDETAIL())
97 		return;
98 
99 	dbg_print(MSG_INTL(MSG_LIB_REQUIRED), so_name, name, ref_file);
100 }
101 
102 void
103 Dbg_libs_update(List * ulibdir, List * dlibdir)
104 {
105 	if (DBG_NOTCLASS(DBG_LIBS))
106 		return;
107 
108 	dbg_print(MSG_INTL(MSG_LIB_UPPATH));
109 	Dbg_lib_dir_print(ulibdir);
110 	Dbg_lib_dir_print(dlibdir);
111 }
112 
113 void
114 Dbg_libs_yp(const char *path)
115 {
116 	if (DBG_NOTCLASS(DBG_LIBS))
117 		return;
118 
119 	dbg_print(MSG_INTL(MSG_LIB_LIBPATH), path);
120 }
121 
122 void
123 Dbg_libs_ylu(const char *path, const char *orig, int index)
124 {
125 	if (DBG_NOTCLASS(DBG_LIBS))
126 		return;
127 
128 	dbg_print(MSG_INTL(MSG_LIB_YPATH), path, orig,
129 		(index == YLDIR) ? 'L' : 'U');
130 }
131 
132 void
133 Dbg_libs_find(const char *name)
134 {
135 	if (DBG_NOTCLASS(DBG_LIBS))
136 		return;
137 
138 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
139 	dbg_print(MSG_INTL(MSG_LIB_FIND), name);
140 }
141 
142 void
143 Dbg_libs_found(const char *path, int alter)
144 {
145 	if (DBG_NOTCLASS(DBG_LIBS))
146 		return;
147 
148 	dbg_print(MSG_INTL(MSG_LIB_TRYING), path, alter ?
149 	    MSG_INTL(MSG_STR_ALTER) : MSG_ORIG(MSG_STR_EMPTY));
150 }
151 
152 void
153 Dbg_libs_ignore(const char *path)
154 {
155 	if (DBG_NOTCLASS(DBG_LIBS))
156 		return;
157 
158 	dbg_print(MSG_INTL(MSG_LIB_IGNORE), path);
159 }
160 
161 void
162 Dbg_libs_audit(const char *opath, const char *npath)
163 {
164 	if (DBG_NOTCLASS(DBG_LIBS | DBG_AUDITING))
165 		return;
166 
167 	if (npath == opath)
168 		return;
169 	else if (npath == 0)
170 		dbg_print(MSG_INTL(MSG_LIB_SKIP), opath);
171 	else
172 		dbg_print(MSG_INTL(MSG_LIB_ALTER), npath);
173 }
174