10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1618Srie * Common Development and Distribution License (the "License"). 6*1618Srie * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*1618Srie 220Sstevel@tonic-gate /* 23*1618Srie * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * String conversion routines for program header attributes. 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate #include <string.h> 330Sstevel@tonic-gate #include <_conv.h> 340Sstevel@tonic-gate #include <phdr_msg.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate static const Msg uphdrs[] = { 370Sstevel@tonic-gate MSG_PT_SUNWBSS, MSG_PT_SUNWSTACK, MSG_PT_SUNWDTRACE, 380Sstevel@tonic-gate MSG_PT_SUNWCAP 390Sstevel@tonic-gate }; 400Sstevel@tonic-gate 410Sstevel@tonic-gate const char * 42*1618Srie conv_phdr_type(Half mach, Word type) 430Sstevel@tonic-gate { 44*1618Srie static char string[CONV_INV_STRSIZE]; 45*1618Srie static const Msg phdrs[] = { 46*1618Srie MSG_PT_NULL, MSG_PT_LOAD, MSG_PT_DYNAMIC, 47*1618Srie MSG_PT_INTERP, MSG_PT_NOTE, MSG_PT_SHLIB, 48*1618Srie MSG_PT_PHDR, MSG_PT_TLS 49*1618Srie }; 500Sstevel@tonic-gate 51*1618Srie if (type < PT_NUM) 52*1618Srie return (MSG_ORIG(phdrs[type])); 53*1618Srie else if ((type >= PT_SUNWBSS) && (type <= PT_HISUNW)) 54*1618Srie return (MSG_ORIG(uphdrs[type - PT_SUNWBSS])); 55*1618Srie else if ((type == PT_SUNW_UNWIND) && (mach == EM_AMD64)) 560Sstevel@tonic-gate return (MSG_ORIG(MSG_PT_SUNW_UNWIND)); 570Sstevel@tonic-gate else 58*1618Srie return (conv_invalid_val(string, CONV_INV_STRSIZE, type, 0)); 590Sstevel@tonic-gate } 600Sstevel@tonic-gate 610Sstevel@tonic-gate #define PHDRSZ MSG_GBL_OSQBRKT_SIZE + \ 620Sstevel@tonic-gate MSG_PF_X_SIZE + \ 630Sstevel@tonic-gate MSG_PF_W_SIZE + \ 640Sstevel@tonic-gate MSG_PF_R_SIZE + \ 65*1618Srie MSG_PF_SUNW_FAILURE_SIZE + \ 66*1618Srie CONV_INV_STRSIZE + MSG_GBL_CSQBRKT_SIZE 670Sstevel@tonic-gate 680Sstevel@tonic-gate const char * 69*1618Srie conv_phdr_flags(Word flags) 700Sstevel@tonic-gate { 71*1618Srie static char string[PHDRSZ]; 72*1618Srie static Val_desc vda[] = { 73*1618Srie { PF_X, MSG_ORIG(MSG_PF_X) }, 74*1618Srie { PF_W, MSG_ORIG(MSG_PF_W) }, 75*1618Srie { PF_R, MSG_ORIG(MSG_PF_R) }, 76*1618Srie { PF_SUNW_FAILURE, MSG_ORIG(MSG_PF_SUNW_FAILURE) }, 77*1618Srie { 0, 0 } 78*1618Srie }; 790Sstevel@tonic-gate 800Sstevel@tonic-gate if (flags == 0) 810Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 820Sstevel@tonic-gate 83*1618Srie (void) strlcpy(string, MSG_ORIG(MSG_GBL_OSQBRKT), PHDRSZ); 84*1618Srie if (conv_expn_field(string, PHDRSZ, vda, flags, flags, 0, 0)) 85*1618Srie (void) strlcat(string, MSG_ORIG(MSG_GBL_CSQBRKT), PHDRSZ); 86*1618Srie 87*1618Srie return ((const char *)string); 880Sstevel@tonic-gate } 89