xref: /titanic_41/usr/src/cmd/sgs/liblddbg/common/shdr.c (revision e23c41c9edb2294649cde3d370ae755701f3f140)
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 /*
234f680cc6SAli 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>
285aefb655Srie #include	<_debug.h>
295aefb655Srie #include	<conv.h>
305aefb655Srie #include	<msg.h>
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate void
Elf_shdr(Lm_list * lml,uchar_t osabi,Half mach,Shdr * shdr)334f680cc6SAli Bahrami Elf_shdr(Lm_list *lml, uchar_t osabi, Half mach, Shdr *shdr)
347c478bd9Sstevel@tonic-gate {
35de777a60Sab196087 	Conv_inv_buf_t		inv_buf1, inv_buf2;
36de777a60Sab196087 	Conv_sec_flags_buf_t	sec_flags_buf;
372926dd2eSrie 
385aefb655Srie 	dbg_print(lml, MSG_ORIG(MSG_SHD_ADDR), EC_ADDR(shdr->sh_addr),
394f680cc6SAli Bahrami 	    conv_sec_flags(osabi, mach, shdr->sh_flags, 0, &sec_flags_buf));
405aefb655Srie 	dbg_print(lml, MSG_ORIG(MSG_SHD_SIZE), EC_XWORD(shdr->sh_size),
414f680cc6SAli Bahrami 	    conv_sec_type(osabi, mach, shdr->sh_type, 0, &inv_buf1));
42d579eb63Sab196087 	if (shdr->sh_entsize == 0) {
43d579eb63Sab196087 		dbg_print(lml, MSG_ORIG(MSG_SHD_OFFSET),
44d579eb63Sab196087 		    EC_OFF(shdr->sh_offset), EC_XWORD(shdr->sh_entsize));
45d579eb63Sab196087 	} else {		/* Provide an entry count */
46d579eb63Sab196087 		Xword nelts = shdr->sh_size / shdr->sh_entsize;
47d579eb63Sab196087 		const char *entstr = (nelts == 1) ? MSG_INTL(MSG_SHD_ENTRY_1) :
48d579eb63Sab196087 		    MSG_INTL(MSG_SHD_ENTRY_N);
49d579eb63Sab196087 
50d579eb63Sab196087 		dbg_print(lml, MSG_ORIG(MSG_SHD_OFFSET_ENT),
51d579eb63Sab196087 		    EC_OFF(shdr->sh_offset), EC_XWORD(shdr->sh_entsize),
52d579eb63Sab196087 		    EC_XWORD(nelts), entstr);
53d579eb63Sab196087 	}
547010c12aSrie 	dbg_print(lml, MSG_ORIG(MSG_SHD_LINK),
55de777a60Sab196087 	    conv_sec_linkinfo(shdr->sh_link, shdr->sh_flags, &inv_buf1),
56de777a60Sab196087 	    conv_sec_linkinfo(shdr->sh_info, shdr->sh_flags, &inv_buf2));
575aefb655Srie 	dbg_print(lml, MSG_ORIG(MSG_SHD_ALIGN), EC_XWORD(shdr->sh_addralign));
587c478bd9Sstevel@tonic-gate }
597010c12aSrie 
607010c12aSrie void
Dbg_shdr_modified(Lm_list * lml,const char * obj,uchar_t osabi,Half mach,Word ndx,Shdr * oshdr,Shdr * nshdr,const char * name)614f680cc6SAli Bahrami Dbg_shdr_modified(Lm_list *lml, const char *obj, uchar_t osabi, Half mach,
62*e23c41c9SAli Bahrami     Word ndx, Shdr *oshdr, Shdr *nshdr, const char *name)
637010c12aSrie {
64*e23c41c9SAli Bahrami 	dbg_isec_name_buf_t	buf;
65*e23c41c9SAli Bahrami 	char			*alloc_mem;
66*e23c41c9SAli Bahrami 
673906e0c2Srie 	if (DBG_NOTCLASS(DBG_C_SECTIONS | DBG_C_SUPPORT))
687010c12aSrie 		return;
697010c12aSrie 	if (DBG_NOTDETAIL())
707010c12aSrie 		return;
717010c12aSrie 
727010c12aSrie 	Dbg_util_nl(lml, DBG_NL_STD);
73*e23c41c9SAli Bahrami 	dbg_print(lml, MSG_INTL(MSG_SHD_MODIFIED),
74*e23c41c9SAli Bahrami 	    dbg_fmt_isec_name2(name, ndx, buf, &alloc_mem), obj);
75*e23c41c9SAli Bahrami 	if (alloc_mem != NULL)
76*e23c41c9SAli Bahrami 		free(alloc_mem);
777010c12aSrie 
787010c12aSrie 	dbg_print(lml, MSG_INTL(MSG_SHD_ORIG));
794f680cc6SAli Bahrami 	Elf_shdr(lml, osabi, mach, oshdr);
807010c12aSrie 
817010c12aSrie 	dbg_print(lml, MSG_INTL(MSG_SHD_NEW));
824f680cc6SAli Bahrami 	Elf_shdr(lml, osabi, mach, nshdr);
837010c12aSrie 
847010c12aSrie 	Dbg_util_nl(lml, DBG_NL_STD);
857010c12aSrie }
86