xref: /titanic_41/usr/src/cmd/sgs/liblddbg/common/unused.c (revision 69bbc66400b6af121ee9f95667811cc0acd84d6e)
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 2006 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_unused_rtldinfo(Rt_map *lmp)
34 {
35 	Lm_list	*lml = LIST(lmp);
36 
37 	if (DBG_NOTCLASS(DBG_C_UNUSED))
38 		return;
39 
40 	dbg_print(lml, MSG_INTL(MSG_USD_RTLDINFO), NAME(lmp),
41 	    NAME(lml->lm_info_lmp));
42 }
43 
44 void
45 Dbg_unused_unref(Rt_map *lmp, const char *depend)
46 {
47 	if (DBG_NOTCLASS(DBG_C_UNUSED))
48 		return;
49 	if (DBG_NOTDETAIL())
50 		return;
51 
52 	dbg_print(LIST(lmp), MSG_INTL(MSG_USD_UNREF), NAME(lmp), depend);
53 }
54 
55 void
56 Dbg_unused_sec(Lm_list *lml, Is_desc *isp)
57 {
58 	const char	*str;
59 
60 	if (DBG_NOTCLASS(DBG_C_UNUSED))
61 		return;
62 	if (DBG_NOTDETAIL())
63 		return;
64 
65 	/*
66 	 * If the file from which this section originates hasn't been referenced
67 	 * at all, skip this diagnostic, as it would have been covered under
68 	 * Dbg_unused_file() called from ignore_section_processing().
69 	 */
70 	if (isp->is_file &&
71 	    ((isp->is_file->ifl_flags & FLG_IF_FILEREF) == 0))
72 		return;
73 
74 	if (isp->is_flags & FLG_IS_DISCARD)
75 		str = MSG_INTL(MSG_USD_SECDISCARD);
76 	else
77 		str = MSG_ORIG(MSG_STR_EMPTY);
78 
79 	dbg_print(lml, MSG_INTL(MSG_USD_SEC), isp->is_basename,
80 	    EC_XWORD(isp->is_shdr->sh_size), isp->is_file->ifl_name, str);
81 }
82 
83 void
84 Dbg_unused_file(Lm_list *lml, const char *name, int needstr, uint_t cycle)
85 {
86 	if (DBG_NOTCLASS(DBG_C_UNUSED))
87 		return;
88 
89 	if (needstr)
90 		dbg_print(lml, MSG_INTL(MSG_USD_NEEDSTR), name);
91 	else if (cycle)
92 		dbg_print(lml, MSG_INTL(MSG_USD_FILECYCLIC), name, cycle);
93 	else
94 		dbg_print(lml, MSG_INTL(MSG_USD_FILE), name);
95 }
96