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