xref: /titanic_51/usr/src/cmd/sgs/liblddbg/common/unused.c (revision c69906bdd99a073749de104d2fa9cd6bf889f3c5)
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 2005 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_sec(Is_desc *isp)
34 {
35 	const char	*str;
36 
37 	if (DBG_NOTCLASS(DBG_UNUSED))
38 		return;
39 	if (DBG_NOTDETAIL())
40 		return;
41 
42 	/*
43 	 * If the file from which this section originates hasn't been referenced
44 	 * at all, skip this diagnostic, as it would have been covered under
45 	 * Dbg_unused_file() called from ignore_section_processing().
46 	 */
47 	if (isp->is_file &&
48 	    ((isp->is_file->ifl_flags & FLG_IF_FILEREF) == 0))
49 		return;
50 
51 	if (isp->is_flags & FLG_IS_DISCARD)
52 		str = MSG_INTL(MSG_USD_SECDISCARD);
53 	else
54 		str = MSG_ORIG(MSG_STR_EMPTY);
55 
56 	dbg_print(MSG_INTL(MSG_USD_SEC), isp->is_basename,
57 	    EC_XWORD(isp->is_shdr->sh_size), isp->is_file->ifl_name, str);
58 }
59 
60 /*
61  * There are no ELF32/ELF64 data structures in these functions - only define
62  * one copy in liblddbg.
63  */
64 #if	!defined(_ELF64)
65 
66 void
67 Dbg_unused_file(const char *name, int cycle)
68 {
69 	if (DBG_NOTCLASS(DBG_UNUSED))
70 		return;
71 
72 	if (cycle)
73 		dbg_print(MSG_INTL(MSG_USD_FILECYCLIC), name, cycle);
74 	else
75 		dbg_print(MSG_INTL(MSG_USD_FILE), name);
76 }
77 
78 void
79 Dbg_unused_unref(const char *caller, const char *depend)
80 {
81 	if (DBG_NOTCLASS(DBG_UNUSED))
82 		return;
83 	if (DBG_NOTDETAIL())
84 		return;
85 
86 	dbg_print(MSG_INTL(MSG_USD_UNREF), caller, depend);
87 }
88 
89 void
90 Dbg_unused_rtldinfo(const char *fname1, const char *fname2)
91 {
92 	if (DBG_NOTCLASS(DBG_UNUSED))
93 		return;
94 
95 	dbg_print(MSG_INTL(MSG_USD_RTLDINFO), fname1, fname2);
96 }
97 #endif
98