xref: /titanic_50/usr/src/cmd/sgs/liblddbg/common/dynamic.c (revision 4f680cc668fa6cf678c531083400ade9a9c7934c)
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  */
215aefb655Srie 
227c478bd9Sstevel@tonic-gate /*
23*4f680cc6SAli Bahrami  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
245aefb655Srie  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
275aefb655Srie #include	<sgs.h>
287c478bd9Sstevel@tonic-gate #include	<stdio.h>
295aefb655Srie #include	<debug.h>
305aefb655Srie #include	<conv.h>
315aefb655Srie #include	<_debug.h>
325aefb655Srie #include	<msg.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * Print out the dynamic section entries.
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate void
Elf_dyn_title(Lm_list * lml)385aefb655Srie Elf_dyn_title(Lm_list *lml)
397c478bd9Sstevel@tonic-gate {
405aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_DYN_TITLE));
417c478bd9Sstevel@tonic-gate }
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate void
Elf_dyn_entry(Lm_list * lml,Dyn * dyn,int ndx,const char * name,uchar_t osabi,Half mach)44*4f680cc6SAli Bahrami Elf_dyn_entry(Lm_list *lml, Dyn *dyn, int ndx, const char *name,
45*4f680cc6SAli Bahrami     uchar_t osabi, Half mach)
467c478bd9Sstevel@tonic-gate {
47de777a60Sab196087 	Conv_inv_buf_t	inv_buf;
485aefb655Srie 	char		index[INDEX_STR_SIZE];
497c478bd9Sstevel@tonic-gate 
503244bcaaSab196087 	(void) snprintf(index, sizeof (index), MSG_ORIG(MSG_FMT_INDEX), ndx);
515aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_DYN_ENTRY), index,
52*4f680cc6SAli Bahrami 	    conv_dyn_tag(dyn->d_tag, osabi, mach, 0, &inv_buf),
53de777a60Sab196087 	    EC_XWORD(dyn->d_un.d_val), name);
547c478bd9Sstevel@tonic-gate }
553244bcaaSab196087 
563244bcaaSab196087 /*
573244bcaaSab196087  * Variant of Elf_dyn_entry() specifically for DT_NULL. Handles the
583244bcaaSab196087  * case of multiple adjacent DT_NULL entries by displaying them on
593244bcaaSab196087  * a single line using an index range instead of a single index.
603244bcaaSab196087  */
613244bcaaSab196087 void
Elf_dyn_null_entry(Lm_list * lml,Dyn * dyn,int start_ndx,int end_ndx)623244bcaaSab196087 Elf_dyn_null_entry(Lm_list *lml, Dyn *dyn, int start_ndx, int end_ndx)
633244bcaaSab196087 {
64de777a60Sab196087 	Conv_inv_buf_t	inv_buf;
653244bcaaSab196087 	char		index[2 * INDEX_STR_SIZE];
663244bcaaSab196087 
673244bcaaSab196087 	if (start_ndx == end_ndx) {
68*4f680cc6SAli Bahrami 		Elf_dyn_entry(lml, dyn, start_ndx, MSG_ORIG(MSG_STR_EMPTY),
69*4f680cc6SAli Bahrami 		    ELFOSABI_NONE, 0);
703244bcaaSab196087 	} else {
713244bcaaSab196087 		(void) snprintf(index, sizeof (index),
723244bcaaSab196087 		    MSG_ORIG(MSG_FMT_INDEX_RANGE), start_ndx, end_ndx);
733244bcaaSab196087 		dbg_print(lml, MSG_INTL(MSG_DYN_ENTRY), index,
74*4f680cc6SAli Bahrami 		    conv_dyn_tag(DT_NULL, ELFOSABI_NONE, 0, 0, &inv_buf),
75de777a60Sab196087 		    EC_XWORD(dyn->d_un.d_val), MSG_ORIG(MSG_STR_EMPTY));
763244bcaaSab196087 	}
773244bcaaSab196087 }
78