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 #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <strings.h> 290Sstevel@tonic-gate #include <dwarf.h> 300Sstevel@tonic-gate #include <dwarf_ehe_msg.h> 31*1618Srie #include "_conv.h" 320Sstevel@tonic-gate 33*1618Srie #define FLAGSZ MSG_GBL_OSQBRKT_SIZE + \ 34*1618Srie MSG_DWEHE_SLEB128_SIZE + \ 35*1618Srie MSG_DWEHE_INDIRECT_SIZE + \ 36*1618Srie CONV_INV_STRSIZE + MSG_GBL_CSQBRKT_SIZE 37*1618Srie 380Sstevel@tonic-gate const char * 39*1618Srie conv_dwarf_ehe(uint_t flags) 400Sstevel@tonic-gate { 41*1618Srie static char string[FLAGSZ]; 42*1618Srie size_t ret = 0; 430Sstevel@tonic-gate 44*1618Srie (void) strncpy(string, MSG_ORIG(MSG_GBL_OSQBRKT), FLAGSZ); 45*1618Srie 46*1618Srie if (flags == DW_EH_PE_omit) 47*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_OMIT), FLAGSZ); 48*1618Srie else if (flags == DW_EH_PE_absptr) 49*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_ABSPTR), FLAGSZ); 50*1618Srie 51*1618Srie if (ret >= FLAGSZ) 52*1618Srie return (conv_invalid_val(string, FLAGSZ, flags, 0)); 53*1618Srie 54*1618Srie if ((flags == DW_EH_PE_omit) || (flags == DW_EH_PE_absptr)) { 55*1618Srie (void) strlcat(string, MSG_ORIG(MSG_GBL_CSQBRKT), FLAGSZ); 560Sstevel@tonic-gate return (string); 570Sstevel@tonic-gate } 580Sstevel@tonic-gate 590Sstevel@tonic-gate switch (flags & 0x0f) { 600Sstevel@tonic-gate case DW_EH_PE_uleb128: 61*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_ULEB128), FLAGSZ); 620Sstevel@tonic-gate break; 630Sstevel@tonic-gate case DW_EH_PE_udata2: 64*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_UDATA2), FLAGSZ); 650Sstevel@tonic-gate break; 660Sstevel@tonic-gate case DW_EH_PE_udata4: 67*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_UDATA4), FLAGSZ); 680Sstevel@tonic-gate break; 690Sstevel@tonic-gate case DW_EH_PE_udata8: 70*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_UDATA8), FLAGSZ); 710Sstevel@tonic-gate break; 720Sstevel@tonic-gate case DW_EH_PE_sleb128: 73*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_SLEB128), FLAGSZ); 740Sstevel@tonic-gate break; 750Sstevel@tonic-gate case DW_EH_PE_sdata2: 76*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_SDATA2), FLAGSZ); 770Sstevel@tonic-gate break; 780Sstevel@tonic-gate case DW_EH_PE_sdata4: 79*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_SDATA4), FLAGSZ); 800Sstevel@tonic-gate break; 810Sstevel@tonic-gate case DW_EH_PE_sdata8: 82*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_SDATA8), FLAGSZ); 830Sstevel@tonic-gate break; 840Sstevel@tonic-gate } 85*1618Srie if (ret >= FLAGSZ) 86*1618Srie return (conv_invalid_val(string, FLAGSZ, flags, 0)); 870Sstevel@tonic-gate 880Sstevel@tonic-gate switch (flags & 0xf0) { 890Sstevel@tonic-gate case DW_EH_PE_pcrel: 90*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_PCREL), FLAGSZ); 910Sstevel@tonic-gate break; 920Sstevel@tonic-gate case DW_EH_PE_textrel: 93*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_TEXTREL), FLAGSZ); 940Sstevel@tonic-gate break; 950Sstevel@tonic-gate case DW_EH_PE_datarel: 96*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_DATAREL), FLAGSZ); 970Sstevel@tonic-gate break; 980Sstevel@tonic-gate case DW_EH_PE_funcrel: 99*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_FUNCREL), FLAGSZ); 1000Sstevel@tonic-gate break; 1010Sstevel@tonic-gate case DW_EH_PE_aligned: 102*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_ALIGNED), FLAGSZ); 1030Sstevel@tonic-gate break; 1040Sstevel@tonic-gate case DW_EH_PE_indirect: 105*1618Srie ret = strlcat(string, MSG_ORIG(MSG_DWEHE_INDIRECT), FLAGSZ); 1060Sstevel@tonic-gate break; 1070Sstevel@tonic-gate } 108*1618Srie if (ret >= FLAGSZ) 109*1618Srie return (conv_invalid_val(string, FLAGSZ, flags, 0)); 1100Sstevel@tonic-gate 111*1618Srie (void) strlcat(string, MSG_ORIG(MSG_GBL_CSQBRKT), FLAGSZ); 1120Sstevel@tonic-gate return (string); 1130Sstevel@tonic-gate } 114