xref: /titanic_52/usr/src/cmd/sgs/liblddbg/common/unused.c (revision 8d96d5b3a759119baa5937624b8716c8abb4d572)
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 /*
24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include	"msg.h"
30 #include	"_debug.h"
31 #include	"libld.h"
32 
33 void
34 Dbg_unused_sec(Is_desc *isp)
35 {
36 	const char	*str;
37 
38 	if (DBG_NOTCLASS(DBG_UNUSED))
39 		return;
40 	if (DBG_NOTDETAIL())
41 		return;
42 
43 	/*
44 	 * If the file from which this section originates hasn't been referenced
45 	 * at all, skip this diagnostic, as it would have been covered under
46 	 * Dbg_unused_file() called from ignore_section_processing().
47 	 */
48 	if (isp->is_file &&
49 	    ((isp->is_file->ifl_flags & FLG_IF_FILEREF) == 0))
50 		return;
51 
52 	if (isp->is_flags & FLG_IS_DISCARD)
53 		str = MSG_INTL(MSG_USD_SECDISCARD);
54 	else
55 		str = MSG_ORIG(MSG_STR_EMPTY);
56 
57 	dbg_print(MSG_INTL(MSG_USD_SEC), isp->is_basename,
58 	    EC_XWORD(isp->is_shdr->sh_size), isp->is_file->ifl_name, str);
59 }
60 
61 /*
62  * There are no ELF32/ELF64 data structures in these functions - only define
63  * one copy in liblddbg.
64  */
65 #if	!defined(_ELF64)
66 
67 void
68 Dbg_unused_file(const char *name, int needstr, int cycle)
69 {
70 	if (DBG_NOTCLASS(DBG_UNUSED))
71 		return;
72 
73 	if (needstr)
74 		dbg_print(MSG_INTL(MSG_USD_NEEDSTR), name);
75 	else if (cycle)
76 		dbg_print(MSG_INTL(MSG_USD_FILECYCLIC), name, cycle);
77 	else
78 		dbg_print(MSG_INTL(MSG_USD_FILE), name);
79 }
80 
81 void
82 Dbg_unused_unref(const char *caller, const char *depend)
83 {
84 	if (DBG_NOTCLASS(DBG_UNUSED))
85 		return;
86 	if (DBG_NOTDETAIL())
87 		return;
88 
89 	dbg_print(MSG_INTL(MSG_USD_UNREF), caller, depend);
90 }
91 
92 void
93 Dbg_unused_rtldinfo(const char *fname1, const char *fname2)
94 {
95 	if (DBG_NOTCLASS(DBG_UNUSED))
96 		return;
97 
98 	dbg_print(MSG_INTL(MSG_USD_RTLDINFO), fname1, fname2);
99 }
100 #endif
101