shdr.c revision d29b2c4438482eb00488be49a1f5d6835f455546
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER START
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Common Development and Distribution License (the "License").
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You may not use this file except in compliance with the License.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * or http://www.opensolaris.org/os/licensing.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#pragma ident "%Z%%M% %I% %E% SMI"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <sgs.h>
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz#include <_debug.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <conv.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <msg.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinvoid
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinElf_shdr(Lm_list *lml, Half mach, Shdr *shdr)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Conv_inv_buf_t inv_buf1, inv_buf2;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Conv_sec_flags_buf_t sec_flags_buf;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dbg_print(lml, MSG_ORIG(MSG_SHD_ADDR), EC_ADDR(shdr->sh_addr),
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin conv_sec_flags(shdr->sh_flags, 0, &sec_flags_buf));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dbg_print(lml, MSG_ORIG(MSG_SHD_SIZE), EC_XWORD(shdr->sh_size),
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin conv_sec_type(mach, shdr->sh_type, 0, &inv_buf1));
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz if (shdr->sh_entsize == 0) {
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz dbg_print(lml, MSG_ORIG(MSG_SHD_OFFSET),
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz EC_OFF(shdr->sh_offset), EC_XWORD(shdr->sh_entsize));
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz } else { /* Provide an entry count */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Xword nelts = shdr->sh_size / shdr->sh_entsize;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin const char *entstr = (nelts == 1) ? MSG_INTL(MSG_SHD_ENTRY_1) :
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin MSG_INTL(MSG_SHD_ENTRY_N);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dbg_print(lml, MSG_ORIG(MSG_SHD_OFFSET_ENT),
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin EC_OFF(shdr->sh_offset), EC_XWORD(shdr->sh_entsize),
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin EC_XWORD(nelts), entstr);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dbg_print(lml, MSG_ORIG(MSG_SHD_LINK),
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin conv_sec_linkinfo(shdr->sh_link, shdr->sh_flags, &inv_buf1),
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin conv_sec_linkinfo(shdr->sh_info, shdr->sh_flags, &inv_buf2));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dbg_print(lml, MSG_ORIG(MSG_SHD_ALIGN), EC_XWORD(shdr->sh_addralign));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinvoid
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinDbg_shdr_modified(Lm_list *lml, const char *obj, Half mach, Shdr *oshdr,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Shdr *nshdr, const char *name)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (DBG_NOTCLASS(DBG_C_SECTIONS | DBG_C_SUPPORT))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (DBG_NOTDETAIL())
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Dbg_util_nl(lml, DBG_NL_STD);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dbg_print(lml, MSG_INTL(MSG_SHD_MODIFIED), name, obj);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin dbg_print(lml, MSG_INTL(MSG_SHD_ORIG));
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin Elf_shdr(lml, mach, oshdr);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz dbg_print(lml, MSG_INTL(MSG_SHD_NEW));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Elf_shdr(lml, mach, nshdr);
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Dbg_util_nl(lml, DBG_NL_STD);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin