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*69112eddSAli Bahrami * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* 287c478bd9Sstevel@tonic-gate * String conversion routine for segment flags. 297c478bd9Sstevel@tonic-gate */ 307c478bd9Sstevel@tonic-gate #include <string.h> 315aefb655Srie #include <libld.h> 325aefb655Srie #include "_conv.h" 337c478bd9Sstevel@tonic-gate #include "segments_msg.h" 347c478bd9Sstevel@tonic-gate 35ba4e3c84Sab196087 #define SEGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 36*69112eddSAli Bahrami MSG_FLG_SG_P_VADDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 37*69112eddSAli Bahrami MSG_FLG_SG_P_PADDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 38ba4e3c84Sab196087 MSG_FLG_SG_LENGTH_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 39*69112eddSAli Bahrami MSG_FLG_SG_P_ALIGN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 40ba4e3c84Sab196087 MSG_FLG_SG_ROUND_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 41*69112eddSAli Bahrami MSG_FLG_SG_P_FLAGS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 42*69112eddSAli Bahrami MSG_FLG_SG_P_TYPE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 43*69112eddSAli Bahrami MSG_FLG_SG_IS_ORDER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 44ba4e3c84Sab196087 MSG_FLG_SG_NOHDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 45ba4e3c84Sab196087 MSG_FLG_SG_EMPTY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 46ba4e3c84Sab196087 MSG_FLG_SG_KEY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 47*69112eddSAli Bahrami MSG_FLG_SG_NODISABLE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 48ba4e3c84Sab196087 MSG_FLG_SG_DISABLED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 49ba4e3c84Sab196087 MSG_FLG_SG_PHREQ_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 50*69112eddSAli Bahrami MSG_FLG_SG_ORDERED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 51de777a60Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 52de777a60Sab196087 53de777a60Sab196087 /* 54de777a60Sab196087 * Ensure that Conv_seg_flags_buf_t is large enough: 55de777a60Sab196087 * 56de777a60Sab196087 * SEGSZ is the real minimum size of the buffer required by conv_seg_flags(). 57de777a60Sab196087 * However, Conv_seg_flags_buf_t uses CONV_SEG_FLAGS_BUFSIZE to set the 58de777a60Sab196087 * buffer size. We do things this way because the definition of SEGSZ uses 59de777a60Sab196087 * information that is not available in the environment of other programs 60de777a60Sab196087 * that include the conv.h header file. 61de777a60Sab196087 */ 626a074c93Sab196087 #if (CONV_SEG_FLAGS_BUFSIZE != SEGSZ) && !defined(__lint) 636a074c93Sab196087 #define REPORT_BUFSIZE SEGSZ 646a074c93Sab196087 #include "report_bufsize.h" 656a074c93Sab196087 #error "CONV_SEG_FLAGS_BUFSIZE does not match SEGSZ" 66de777a60Sab196087 #endif 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate const char * 69*69112eddSAli Bahrami conv_seg_flags(sg_flags_t flags, Conv_seg_flags_buf_t *seg_flags_buf) 707c478bd9Sstevel@tonic-gate { 715aefb655Srie static Val_desc vda[] = { 72*69112eddSAli Bahrami { FLG_SG_P_VADDR, MSG_FLG_SG_P_VADDR }, 73*69112eddSAli Bahrami { FLG_SG_P_PADDR, MSG_FLG_SG_P_PADDR }, 744f680cc6SAli Bahrami { FLG_SG_LENGTH, MSG_FLG_SG_LENGTH }, 75*69112eddSAli Bahrami { FLG_SG_P_ALIGN, MSG_FLG_SG_P_ALIGN }, 764f680cc6SAli Bahrami { FLG_SG_ROUND, MSG_FLG_SG_ROUND }, 77*69112eddSAli Bahrami { FLG_SG_P_FLAGS, MSG_FLG_SG_P_FLAGS }, 78*69112eddSAli Bahrami { FLG_SG_P_TYPE, MSG_FLG_SG_P_TYPE }, 79*69112eddSAli Bahrami { FLG_SG_IS_ORDER, MSG_FLG_SG_IS_ORDER }, 804f680cc6SAli Bahrami { FLG_SG_NOHDR, MSG_FLG_SG_NOHDR }, 814f680cc6SAli Bahrami { FLG_SG_EMPTY, MSG_FLG_SG_EMPTY }, 824f680cc6SAli Bahrami { FLG_SG_KEY, MSG_FLG_SG_KEY }, 83*69112eddSAli Bahrami { FLG_SG_NODISABLE, MSG_FLG_SG_NODISABLE }, 844f680cc6SAli Bahrami { FLG_SG_DISABLED, MSG_FLG_SG_DISABLED }, 854f680cc6SAli Bahrami { FLG_SG_PHREQ, MSG_FLG_SG_PHREQ }, 86*69112eddSAli Bahrami { FLG_SG_ORDERED, MSG_FLG_SG_ORDERED }, 875aefb655Srie { 0, 0 } 885aefb655Srie }; 89de777a60Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 904f680cc6SAli Bahrami NULL, sizeof (seg_flags_buf->buf) }; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate if (flags == 0) 937c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 945aefb655Srie 95de777a60Sab196087 conv_arg.buf = seg_flags_buf->buf; 96ba4e3c84Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 974f680cc6SAli Bahrami (void) conv_expn_field(&conv_arg, vda, 0); 987c478bd9Sstevel@tonic-gate 99de777a60Sab196087 return ((const char *)seg_flags_buf->buf); 1007c478bd9Sstevel@tonic-gate } 101