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
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * 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*9aa23310Srie  * Copyright 2008 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 
325aefb655Srie void
335aefb655Srie Dbg_unused_unref(Rt_map *lmp, const char *depend)
345aefb655Srie {
355aefb655Srie 	if (DBG_NOTCLASS(DBG_C_UNUSED))
365aefb655Srie 		return;
375aefb655Srie 	if (DBG_NOTDETAIL())
385aefb655Srie 		return;
395aefb655Srie 
405aefb655Srie 	dbg_print(LIST(lmp), MSG_INTL(MSG_USD_UNREF), NAME(lmp), depend);
415aefb655Srie }
425aefb655Srie 
435aefb655Srie void
445aefb655Srie Dbg_unused_sec(Lm_list *lml, Is_desc *isp)
457c478bd9Sstevel@tonic-gate {
467c478bd9Sstevel@tonic-gate 	const char	*str;
477c478bd9Sstevel@tonic-gate 
485aefb655Srie 	if (DBG_NOTCLASS(DBG_C_UNUSED))
497c478bd9Sstevel@tonic-gate 		return;
507c478bd9Sstevel@tonic-gate 	if (DBG_NOTDETAIL())
517c478bd9Sstevel@tonic-gate 		return;
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate 	/*
547c478bd9Sstevel@tonic-gate 	 * If the file from which this section originates hasn't been referenced
557c478bd9Sstevel@tonic-gate 	 * at all, skip this diagnostic, as it would have been covered under
567c478bd9Sstevel@tonic-gate 	 * Dbg_unused_file() called from ignore_section_processing().
577c478bd9Sstevel@tonic-gate 	 */
587c478bd9Sstevel@tonic-gate 	if (isp->is_file &&
597c478bd9Sstevel@tonic-gate 	    ((isp->is_file->ifl_flags & FLG_IF_FILEREF) == 0))
607c478bd9Sstevel@tonic-gate 		return;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	if (isp->is_flags & FLG_IS_DISCARD)
637c478bd9Sstevel@tonic-gate 		str = MSG_INTL(MSG_USD_SECDISCARD);
647c478bd9Sstevel@tonic-gate 	else
657c478bd9Sstevel@tonic-gate 		str = MSG_ORIG(MSG_STR_EMPTY);
667c478bd9Sstevel@tonic-gate 
675aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_USD_SEC), isp->is_basename,
687c478bd9Sstevel@tonic-gate 	    EC_XWORD(isp->is_shdr->sh_size), isp->is_file->ifl_name, str);
697c478bd9Sstevel@tonic-gate }
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate void
725aefb655Srie Dbg_unused_file(Lm_list *lml, const char *name, int needstr, uint_t cycle)
737c478bd9Sstevel@tonic-gate {
745aefb655Srie 	if (DBG_NOTCLASS(DBG_C_UNUSED))
757c478bd9Sstevel@tonic-gate 		return;
767c478bd9Sstevel@tonic-gate 
77fb1354edSrie 	if (needstr)
785aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_USD_NEEDSTR), name);
79fb1354edSrie 	else if (cycle)
805aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_USD_FILECYCLIC), name, cycle);
817c478bd9Sstevel@tonic-gate 	else
825aefb655Srie 		dbg_print(lml, MSG_INTL(MSG_USD_FILE), name);
837c478bd9Sstevel@tonic-gate }
84*9aa23310Srie 
85*9aa23310Srie void
86*9aa23310Srie Dbg_unused_path(Lm_list *lml, const char *path, uint_t orig, uint_t dup,
87*9aa23310Srie     const char *obj)
88*9aa23310Srie {
89*9aa23310Srie 	const char	*fmt;
90*9aa23310Srie 
91*9aa23310Srie 	if (DBG_NOTCLASS(DBG_C_UNUSED))
92*9aa23310Srie 		return;
93*9aa23310Srie 	if (DBG_NOTDETAIL())
94*9aa23310Srie 		return;
95*9aa23310Srie 
96*9aa23310Srie 	if (orig & LA_SER_LIBPATH) {
97*9aa23310Srie 		if (orig & LA_SER_CONFIG) {
98*9aa23310Srie 			if (dup)
99*9aa23310Srie 				fmt = MSG_INTL(MSG_DUP_LDLIBPATHC);
100*9aa23310Srie 			else
101*9aa23310Srie 				fmt = MSG_INTL(MSG_USD_LDLIBPATHC);
102*9aa23310Srie 		} else {
103*9aa23310Srie 			if (dup)
104*9aa23310Srie 				fmt = MSG_INTL(MSG_DUP_LDLIBPATH);
105*9aa23310Srie 			else
106*9aa23310Srie 				fmt = MSG_INTL(MSG_USD_LDLIBPATH);
107*9aa23310Srie 		}
108*9aa23310Srie 	} else if (orig & LA_SER_RUNPATH) {
109*9aa23310Srie 		fmt = MSG_INTL(MSG_USD_RUNPATH);
110*9aa23310Srie 	} else
111*9aa23310Srie 		return;
112*9aa23310Srie 
113*9aa23310Srie 	dbg_print(lml, fmt, path, obj);
114*9aa23310Srie }
115