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 51618Srie * Common Development and Distribution License (the "License"). 61618Srie * 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 */ 211618Srie 220Sstevel@tonic-gate /* 233731Srie * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 241618Srie * 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 <string.h> 290Sstevel@tonic-gate #include "rtld.h" 300Sstevel@tonic-gate #include "_conv.h" 310Sstevel@tonic-gate #include "group_msg.h" 320Sstevel@tonic-gate 333731Srie #define HDLSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 342352Sab196087 MSG_GPH_ZERO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 352352Sab196087 MSG_GPH_LDSO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 362352Sab196087 MSG_GPH_FIRST_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 372352Sab196087 MSG_GPH_PARENT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 382352Sab196087 MSG_GPH_FILTEE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 392352Sab196087 MSG_GPH_INITIAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 40*4734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 41*4734Sab196087 42*4734Sab196087 /* 43*4734Sab196087 * Ensure that Conv_grphdl_flags_buf_t is large enough: 44*4734Sab196087 * 45*4734Sab196087 * HDLSZ is the real minimum size of the buffer required by conv_grphdl_flags(). 46*4734Sab196087 * However, Conv_grphdl_flags_buf_t uses CONV_GRPHDL_FLAGS_BUFSIZE to set the 47*4734Sab196087 * buffer size. We do things this way because the definition of HDLSZ uses 48*4734Sab196087 * information that is not available in the environment of other programs 49*4734Sab196087 * that include the conv.h header file. 50*4734Sab196087 */ 51*4734Sab196087 #if (CONV_GRPHDL_FLAGS_BUFSIZE < HDLSZ) && !defined(__lint) 52*4734Sab196087 #error "CONV_GRPHDL_FLAGS_BUFSIZE is not large enough" 53*4734Sab196087 #endif 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * String conversion routine for Grp_hdl flags. 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate const char * 59*4734Sab196087 conv_grphdl_flags(uint_t flags, Conv_grphdl_flags_buf_t *grphdl_flags_buf) 600Sstevel@tonic-gate { 611618Srie static Val_desc vda[] = { 621618Srie { GPH_ZERO, MSG_ORIG(MSG_GPH_ZERO) }, 631618Srie { GPH_LDSO, MSG_ORIG(MSG_GPH_LDSO) }, 641618Srie { GPH_FIRST, MSG_ORIG(MSG_GPH_FIRST) }, 651618Srie { GPH_PARENT, MSG_ORIG(MSG_GPH_PARENT) }, 661618Srie { GPH_FILTEE, MSG_ORIG(MSG_GPH_FILTEE) }, 671618Srie { GPH_INITIAL, MSG_ORIG(MSG_GPH_INITIAL) }, 681618Srie { 0, 0 } 691618Srie }; 70*4734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 71*4734Sab196087 NULL, sizeof (grphdl_flags_buf->buf), vda }; 720Sstevel@tonic-gate 730Sstevel@tonic-gate if (flags == 0) 740Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_NULL)); 750Sstevel@tonic-gate 76*4734Sab196087 conv_arg.buf = grphdl_flags_buf->buf; 772352Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 782352Sab196087 (void) conv_expn_field(&conv_arg); 790Sstevel@tonic-gate 80*4734Sab196087 return ((const char *)grphdl_flags_buf->buf); 810Sstevel@tonic-gate } 823731Srie 833731Srie #define DESCSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 844699Srie MSG_GPD_DLSYM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 854699Srie MSG_GPD_RELOC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 863731Srie MSG_GPD_ADDEPS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 873731Srie MSG_GPD_PARENT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 883731Srie MSG_GPD_FILTER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 893731Srie MSG_GPD_REMOVE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 90*4734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 91*4734Sab196087 92*4734Sab196087 /* 93*4734Sab196087 * Ensure that Conv_grpdesc_flags_buf_t is large enough: 94*4734Sab196087 * 95*4734Sab196087 * DESCSZ is the real min size of the buffer required by conv_grpdesc_flags(). 96*4734Sab196087 * However, Conv_grpdesc_flags_buf_t uses CONV_GRPDESC_FLAGS_BUFSIZE to set the 97*4734Sab196087 * buffer size. We do things this way because the definition of DESCSZ uses 98*4734Sab196087 * information that is not available in the environment of other programs 99*4734Sab196087 * that include the conv.h header file. 100*4734Sab196087 */ 101*4734Sab196087 #if (CONV_GRPDESC_FLAGS_BUFSIZE < DESCSZ) && !defined(__lint) 102*4734Sab196087 #error "CONV_GRPDESC_FLAGS_BUFSIZE is not large enough" 103*4734Sab196087 #endif 104*4734Sab196087 1053731Srie /* 1063731Srie * String conversion routine for Grp_desc flags. 1073731Srie */ 1083731Srie const char * 109*4734Sab196087 conv_grpdesc_flags(uint_t flags, Conv_grpdesc_flags_buf_t *grpdesc_flags_buf) 1103731Srie { 1113731Srie static Val_desc vda[] = { 1124699Srie { GPD_DLSYM, MSG_ORIG(MSG_GPD_DLSYM) }, 1134699Srie { GPD_RELOC, MSG_ORIG(MSG_GPD_RELOC) }, 1143731Srie { GPD_ADDEPS, MSG_ORIG(MSG_GPD_ADDEPS) }, 1153731Srie { GPD_PARENT, MSG_ORIG(MSG_GPD_PARENT) }, 1163731Srie { GPD_FILTER, MSG_ORIG(MSG_GPD_FILTER) }, 1173731Srie { GPD_REMOVE, MSG_ORIG(MSG_GPD_REMOVE) }, 1183731Srie { 0, 0 } 1193731Srie }; 120*4734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 121*4734Sab196087 NULL, sizeof (grpdesc_flags_buf->buf), vda }; 1223731Srie 1233731Srie if (flags == 0) 1243731Srie return (MSG_ORIG(MSG_GBL_NULL)); 1253731Srie 126*4734Sab196087 conv_arg.buf = grpdesc_flags_buf->buf; 1273731Srie conv_arg.oflags = conv_arg.rflags = flags; 1283731Srie (void) conv_expn_field(&conv_arg); 1293731Srie 130*4734Sab196087 return ((const char *)grpdesc_flags_buf->buf); 1313731Srie } 132