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 /* 239273SAli.Bahrami@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 241618Srie * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #include <string.h> 280Sstevel@tonic-gate #include "rtld.h" 290Sstevel@tonic-gate #include "_conv.h" 300Sstevel@tonic-gate #include "group_msg.h" 310Sstevel@tonic-gate 323731Srie #define HDLSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 332352Sab196087 MSG_GPH_ZERO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 342352Sab196087 MSG_GPH_LDSO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 352352Sab196087 MSG_GPH_FIRST_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 362352Sab196087 MSG_GPH_FILTEE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 372352Sab196087 MSG_GPH_INITIAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 385067Srie MSG_GPH_NOPENDLAZY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 394734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 404734Sab196087 414734Sab196087 /* 424734Sab196087 * Ensure that Conv_grphdl_flags_buf_t is large enough: 434734Sab196087 * 444734Sab196087 * HDLSZ is the real minimum size of the buffer required by conv_grphdl_flags(). 454734Sab196087 * However, Conv_grphdl_flags_buf_t uses CONV_GRPHDL_FLAGS_BUFSIZE to set the 464734Sab196087 * buffer size. We do things this way because the definition of HDLSZ uses 474734Sab196087 * information that is not available in the environment of other programs 484734Sab196087 * that include the conv.h header file. 494734Sab196087 */ 505152Sab196087 #if (CONV_GRPHDL_FLAGS_BUFSIZE != HDLSZ) && !defined(__lint) 515152Sab196087 #define REPORT_BUFSIZE HDLSZ 525152Sab196087 #include "report_bufsize.h" 535152Sab196087 #error "CONV_GRPHDL_FLAGS_BUFSIZE does not match HDLSZ" 544734Sab196087 #endif 550Sstevel@tonic-gate 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * String conversion routine for Grp_hdl flags. 580Sstevel@tonic-gate */ 590Sstevel@tonic-gate const char * 604734Sab196087 conv_grphdl_flags(uint_t flags, Conv_grphdl_flags_buf_t *grphdl_flags_buf) 610Sstevel@tonic-gate { 629273SAli.Bahrami@Sun.COM static const Val_desc vda[] = { 63*9577SRod.Evans@Sun.COM { GPH_PUBLIC, MSG_GPH_PUBLIC }, 64*9577SRod.Evans@Sun.COM { GPH_PRIVATE, MSG_GPH_PRIVATE }, 659273SAli.Bahrami@Sun.COM { GPH_ZERO, MSG_GPH_ZERO }, 669273SAli.Bahrami@Sun.COM { GPH_LDSO, MSG_GPH_LDSO }, 679273SAli.Bahrami@Sun.COM { GPH_FIRST, MSG_GPH_FIRST }, 689273SAli.Bahrami@Sun.COM { GPH_FILTEE, MSG_GPH_FILTEE }, 699273SAli.Bahrami@Sun.COM { GPH_INITIAL, MSG_GPH_INITIAL }, 709273SAli.Bahrami@Sun.COM { GPH_NOPENDLAZY, MSG_GPH_NOPENDLAZY }, 711618Srie { 0, 0 } 721618Srie }; 734734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 749273SAli.Bahrami@Sun.COM NULL, sizeof (grphdl_flags_buf->buf) }; 750Sstevel@tonic-gate 760Sstevel@tonic-gate if (flags == 0) 770Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_NULL)); 780Sstevel@tonic-gate 794734Sab196087 conv_arg.buf = grphdl_flags_buf->buf; 802352Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 819273SAli.Bahrami@Sun.COM (void) conv_expn_field(&conv_arg, vda, 0); 820Sstevel@tonic-gate 834734Sab196087 return ((const char *)grphdl_flags_buf->buf); 840Sstevel@tonic-gate } 853731Srie 863731Srie #define DESCSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 874699Srie MSG_GPD_DLSYM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 884699Srie MSG_GPD_RELOC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 893731Srie MSG_GPD_ADDEPS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 903731Srie MSG_GPD_PARENT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 913731Srie MSG_GPD_FILTER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 925067Srie MSG_GPD_PROMOTE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 933731Srie MSG_GPD_REMOVE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 944734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 954734Sab196087 964734Sab196087 /* 974734Sab196087 * Ensure that Conv_grpdesc_flags_buf_t is large enough: 984734Sab196087 * 994734Sab196087 * DESCSZ is the real min size of the buffer required by conv_grpdesc_flags(). 1004734Sab196087 * However, Conv_grpdesc_flags_buf_t uses CONV_GRPDESC_FLAGS_BUFSIZE to set the 1014734Sab196087 * buffer size. We do things this way because the definition of DESCSZ uses 1024734Sab196087 * information that is not available in the environment of other programs 1034734Sab196087 * that include the conv.h header file. 1044734Sab196087 */ 1055152Sab196087 #if (CONV_GRPDESC_FLAGS_BUFSIZE != DESCSZ) && !defined(__lint) 1065152Sab196087 #define REPORT_BUFSIZE DESCSZ 1075152Sab196087 #include "report_bufsize.h" 1085152Sab196087 #error "CONV_GRPDESC_FLAGS_BUFSIZE does not match DESCSZ" 1094734Sab196087 #endif 1104734Sab196087 1113731Srie /* 1123731Srie * String conversion routine for Grp_desc flags. 1133731Srie */ 1143731Srie const char * 1154734Sab196087 conv_grpdesc_flags(uint_t flags, Conv_grpdesc_flags_buf_t *grpdesc_flags_buf) 1163731Srie { 1179273SAli.Bahrami@Sun.COM static const Val_desc vda[] = { 1189273SAli.Bahrami@Sun.COM { GPD_DLSYM, MSG_GPD_DLSYM }, 1199273SAli.Bahrami@Sun.COM { GPD_RELOC, MSG_GPD_RELOC }, 1209273SAli.Bahrami@Sun.COM { GPD_ADDEPS, MSG_GPD_ADDEPS }, 1219273SAli.Bahrami@Sun.COM { GPD_PARENT, MSG_GPD_PARENT }, 1229273SAli.Bahrami@Sun.COM { GPD_FILTER, MSG_GPD_FILTER }, 1239273SAli.Bahrami@Sun.COM { GPD_REMOVE, MSG_GPD_REMOVE }, 124*9577SRod.Evans@Sun.COM { GPD_MODECHANGE, MSG_GPD_MODECHANGE }, 1253731Srie { 0, 0 } 1263731Srie }; 1274734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 1289273SAli.Bahrami@Sun.COM NULL, sizeof (grpdesc_flags_buf->buf) }; 1293731Srie 1303731Srie if (flags == 0) 1313731Srie return (MSG_ORIG(MSG_GBL_NULL)); 1323731Srie 1334734Sab196087 conv_arg.buf = grpdesc_flags_buf->buf; 1343731Srie conv_arg.oflags = conv_arg.rflags = flags; 1359273SAli.Bahrami@Sun.COM (void) conv_expn_field(&conv_arg, vda, 0); 1363731Srie 1374734Sab196087 return ((const char *)grpdesc_flags_buf->buf); 1383731Srie } 139