xref: /titanic_52/usr/src/cmd/sgs/liblddbg/common/unused.c (revision db2bae3047e71d795bde12e3baa621f4b6cc8930)
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 
27 #include	"msg.h"
28 #include	"_debug.h"
29 #include	"libld.h"
30 
31 void
32 Dbg_unused_unref(Rt_map *lmp, const char *depend)
33 {
34 	if (DBG_NOTCLASS(DBG_C_UNUSED))
35 		return;
36 	if (DBG_NOTDETAIL())
37 		return;
38 
39 	dbg_print(LIST(lmp), MSG_INTL(MSG_USD_UNREF), NAME(lmp), depend);
40 }
41 
42 void
43 Dbg_unused_sec(Lm_list *lml, Is_desc *isp)
44 {
45 	const char	*str;
46 
47 	if (DBG_NOTCLASS(DBG_C_UNUSED))
48 		return;
49 	if (DBG_NOTDETAIL())
50 		return;
51 
52 	/*
53 	 * If the file from which this section originates hasn't been referenced
54 	 * at all, skip this diagnostic, as it would have been covered under
55 	 * Dbg_unused_file() called from ignore_section_processing().
56 	 */
57 	if (isp->is_file &&
58 	    ((isp->is_file->ifl_flags & FLG_IF_FILEREF) == 0))
59 		return;
60 
61 	if (isp->is_flags & FLG_IS_DISCARD)
62 		str = MSG_INTL(MSG_USD_SECDISCARD);
63 	else
64 		str = MSG_ORIG(MSG_STR_EMPTY);
65 
66 	dbg_print(lml, MSG_INTL(MSG_USD_SEC), isp->is_name,
67 	    EC_XWORD(isp->is_shdr->sh_size), isp->is_file->ifl_name, str);
68 }
69 
70 void
71 Dbg_unused_file(Lm_list *lml, const char *name, int needstr, uint_t cycle)
72 {
73 	if (DBG_NOTCLASS(DBG_C_UNUSED))
74 		return;
75 
76 	if (needstr)
77 		dbg_print(lml, MSG_INTL(MSG_USD_NEEDSTR), name);
78 	else if (cycle)
79 		dbg_print(lml, MSG_INTL(MSG_USD_FILECYCLIC), name, cycle);
80 	else
81 		dbg_print(lml, MSG_INTL(MSG_USD_FILE), name);
82 }
83 
84 void
85 Dbg_unused_path(Lm_list *lml, const char *path, uint_t orig, uint_t dup,
86     const char *obj)
87 {
88 	const char	*fmt;
89 
90 	if (DBG_NOTCLASS(DBG_C_UNUSED))
91 		return;
92 	if (DBG_NOTDETAIL())
93 		return;
94 
95 	if (orig & LA_SER_LIBPATH) {
96 		if (orig & LA_SER_CONFIG) {
97 			if (dup)
98 				fmt = MSG_INTL(MSG_DUP_LDLIBPATHC);
99 			else
100 				fmt = MSG_INTL(MSG_USD_LDLIBPATHC);
101 		} else {
102 			if (dup)
103 				fmt = MSG_INTL(MSG_DUP_LDLIBPATH);
104 			else
105 				fmt = MSG_INTL(MSG_USD_LDLIBPATH);
106 		}
107 	} else if (orig & LA_SER_RUNPATH) {
108 		fmt = MSG_INTL(MSG_USD_RUNPATH);
109 	} else
110 		return;
111 
112 	dbg_print(lml, fmt, path, obj);
113 }
114