17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*5aefb655Srie  * Common Development and Distribution License (the "License").
6*5aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21fb1354edSrie 
227c478bd9Sstevel@tonic-gate /*
23*5aefb655Srie  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24fb1354edSrie  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include	"msg.h"
297c478bd9Sstevel@tonic-gate #include	"_debug.h"
307c478bd9Sstevel@tonic-gate #include	"libld.h"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate void
33*5aefb655Srie Dbg_unused_rtldinfo(Rt_map *lmp)
34*5aefb655Srie {
35*5aefb655Srie 	Lm_list	*lml = LIST(lmp);
36*5aefb655Srie 
37*5aefb655Srie 	if (DBG_NOTCLASS(DBG_C_UNUSED))
38*5aefb655Srie 		return;
39*5aefb655Srie 
40*5aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_USD_RTLDINFO), NAME(lmp),
41*5aefb655Srie 	    NAME(lml->lm_info_lmp));
42*5aefb655Srie }
43*5aefb655Srie 
44*5aefb655Srie void
45*5aefb655Srie Dbg_unused_unref(Rt_map *lmp, const char *depend)
46*5aefb655Srie {
47*5aefb655Srie 	if (DBG_NOTCLASS(DBG_C_UNUSED))
48*5aefb655Srie 		return;
49*5aefb655Srie 	if (DBG_NOTDETAIL())
50*5aefb655Srie 		return;
51*5aefb655Srie 
52*5aefb655Srie 	dbg_print(LIST(lmp), MSG_INTL(MSG_USD_UNREF), NAME(lmp), depend);
53*5aefb655Srie }
54*5aefb655Srie 
55*5aefb655Srie void
56*5aefb655Srie Dbg_unused_sec(Lm_list *lml, Is_desc *isp)
577c478bd9Sstevel@tonic-gate {
587c478bd9Sstevel@tonic-gate 	const char	*str;
597c478bd9Sstevel@tonic-gate 
60*5aefb655Srie 	if (DBG_NOTCLASS(DBG_C_UNUSED))
617c478bd9Sstevel@tonic-gate 		return;
627c478bd9Sstevel@tonic-gate 	if (DBG_NOTDETAIL())
637c478bd9Sstevel@tonic-gate 		return;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 	/*
667c478bd9Sstevel@tonic-gate 	 * If the file from which this section originates hasn't been referenced
677c478bd9Sstevel@tonic-gate 	 * at all, skip this diagnostic, as it would have been covered under
687c478bd9Sstevel@tonic-gate 	 * Dbg_unused_file() called from ignore_section_processing().
697c478bd9Sstevel@tonic-gate 	 */
707c478bd9Sstevel@tonic-gate 	if (isp->is_file &&
717c478bd9Sstevel@tonic-gate 	    ((isp->is_file->ifl_flags & FLG_IF_FILEREF) == 0))
727c478bd9Sstevel@tonic-gate 		return;
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate 	if (isp->is_flags & FLG_IS_DISCARD)
757c478bd9Sstevel@tonic-gate 		str = MSG_INTL(MSG_USD_SECDISCARD);
767c478bd9Sstevel@tonic-gate 	else
777c478bd9Sstevel@tonic-gate 		str = MSG_ORIG(MSG_STR_EMPTY);
787c478bd9Sstevel@tonic-gate 
79*5aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_USD_SEC), isp->is_basename,
807c478bd9Sstevel@tonic-gate 	    EC_XWORD(isp->is_shdr->sh_size), isp->is_file->ifl_name, str);
817c478bd9Sstevel@tonic-gate }
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate void
84*5aefb655Srie Dbg_unused_file(Lm_list *lml, const char *name, int needstr, uint_t cycle)
857c478bd9Sstevel@tonic-gate {
86*5aefb655Srie 	if (DBG_NOTCLASS(DBG_C_UNUSED))
877c478bd9Sstevel@tonic-gate 		return;
887c478bd9Sstevel@tonic-gate 
89fb1354edSrie 	if (needstr)
90*5aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_USD_NEEDSTR), name);
91fb1354edSrie 	else if (cycle)
92*5aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_USD_FILECYCLIC), name, cycle);
937c478bd9Sstevel@tonic-gate 	else
94*5aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_USD_FILE), name);
957c478bd9Sstevel@tonic-gate }
96