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 /*
234f680cc6SAli Bahrami * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #include <string.h>
287c478bd9Sstevel@tonic-gate #include "rtld.h"
297c478bd9Sstevel@tonic-gate #include "_conv.h"
307c478bd9Sstevel@tonic-gate #include "group_msg.h"
317c478bd9Sstevel@tonic-gate
3202ca3e02Srie #define HDLSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
33ba4e3c84Sab196087 MSG_GPH_ZERO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
34ba4e3c84Sab196087 MSG_GPH_LDSO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
35ba4e3c84Sab196087 MSG_GPH_FIRST_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
36ba4e3c84Sab196087 MSG_GPH_FILTEE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
37ba4e3c84Sab196087 MSG_GPH_INITIAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
388af2c5b9Srie MSG_GPH_NOPENDLAZY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
39de777a60Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
40de777a60Sab196087
41de777a60Sab196087 /*
42de777a60Sab196087 * Ensure that Conv_grphdl_flags_buf_t is large enough:
43de777a60Sab196087 *
44de777a60Sab196087 * HDLSZ is the real minimum size of the buffer required by conv_grphdl_flags().
45de777a60Sab196087 * However, Conv_grphdl_flags_buf_t uses CONV_GRPHDL_FLAGS_BUFSIZE to set the
46de777a60Sab196087 * buffer size. We do things this way because the definition of HDLSZ uses
47de777a60Sab196087 * information that is not available in the environment of other programs
48de777a60Sab196087 * that include the conv.h header file.
49de777a60Sab196087 */
506a074c93Sab196087 #if (CONV_GRPHDL_FLAGS_BUFSIZE != HDLSZ) && !defined(__lint)
516a074c93Sab196087 #define REPORT_BUFSIZE HDLSZ
526a074c93Sab196087 #include "report_bufsize.h"
536a074c93Sab196087 #error "CONV_GRPHDL_FLAGS_BUFSIZE does not match HDLSZ"
54de777a60Sab196087 #endif
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate * String conversion routine for Grp_hdl flags.
587c478bd9Sstevel@tonic-gate */
597c478bd9Sstevel@tonic-gate const char *
conv_grphdl_flags(uint_t flags,Conv_grphdl_flags_buf_t * grphdl_flags_buf)60de777a60Sab196087 conv_grphdl_flags(uint_t flags, Conv_grphdl_flags_buf_t *grphdl_flags_buf)
617c478bd9Sstevel@tonic-gate {
624f680cc6SAli Bahrami static const Val_desc vda[] = {
63*2017c965SRod Evans { GPH_PUBLIC, MSG_GPH_PUBLIC },
64*2017c965SRod Evans { GPH_PRIVATE, MSG_GPH_PRIVATE },
654f680cc6SAli Bahrami { GPH_ZERO, MSG_GPH_ZERO },
664f680cc6SAli Bahrami { GPH_LDSO, MSG_GPH_LDSO },
674f680cc6SAli Bahrami { GPH_FIRST, MSG_GPH_FIRST },
684f680cc6SAli Bahrami { GPH_FILTEE, MSG_GPH_FILTEE },
694f680cc6SAli Bahrami { GPH_INITIAL, MSG_GPH_INITIAL },
7002ca3e02Srie { 0, 0 }
7102ca3e02Srie };
72de777a60Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = {
734f680cc6SAli Bahrami NULL, sizeof (grphdl_flags_buf->buf) };
7402ca3e02Srie
7502ca3e02Srie if (flags == 0)
7602ca3e02Srie return (MSG_ORIG(MSG_GBL_NULL));
7702ca3e02Srie
78de777a60Sab196087 conv_arg.buf = grphdl_flags_buf->buf;
7902ca3e02Srie conv_arg.oflags = conv_arg.rflags = flags;
804f680cc6SAli Bahrami (void) conv_expn_field(&conv_arg, vda, 0);
8102ca3e02Srie
82de777a60Sab196087 return ((const char *)grphdl_flags_buf->buf);
8302ca3e02Srie }
8402ca3e02Srie
8502ca3e02Srie #define DESCSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
86efb9e8b8Srie MSG_GPD_DLSYM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
87efb9e8b8Srie MSG_GPD_RELOC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
8802ca3e02Srie MSG_GPD_ADDEPS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
8902ca3e02Srie MSG_GPD_PARENT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
9002ca3e02Srie MSG_GPD_FILTER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
918af2c5b9Srie MSG_GPD_PROMOTE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
9202ca3e02Srie MSG_GPD_REMOVE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
93de777a60Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
94de777a60Sab196087
95de777a60Sab196087 /*
96de777a60Sab196087 * Ensure that Conv_grpdesc_flags_buf_t is large enough:
97de777a60Sab196087 *
98de777a60Sab196087 * DESCSZ is the real min size of the buffer required by conv_grpdesc_flags().
99de777a60Sab196087 * However, Conv_grpdesc_flags_buf_t uses CONV_GRPDESC_FLAGS_BUFSIZE to set the
100de777a60Sab196087 * buffer size. We do things this way because the definition of DESCSZ uses
101de777a60Sab196087 * information that is not available in the environment of other programs
102de777a60Sab196087 * that include the conv.h header file.
103de777a60Sab196087 */
1046a074c93Sab196087 #if (CONV_GRPDESC_FLAGS_BUFSIZE != DESCSZ) && !defined(__lint)
1056a074c93Sab196087 #define REPORT_BUFSIZE DESCSZ
1066a074c93Sab196087 #include "report_bufsize.h"
1076a074c93Sab196087 #error "CONV_GRPDESC_FLAGS_BUFSIZE does not match DESCSZ"
108de777a60Sab196087 #endif
109de777a60Sab196087
11002ca3e02Srie /*
11102ca3e02Srie * String conversion routine for Grp_desc flags.
11202ca3e02Srie */
11302ca3e02Srie const char *
conv_grpdesc_flags(uint_t flags,Conv_grpdesc_flags_buf_t * grpdesc_flags_buf)114de777a60Sab196087 conv_grpdesc_flags(uint_t flags, Conv_grpdesc_flags_buf_t *grpdesc_flags_buf)
11502ca3e02Srie {
1164f680cc6SAli Bahrami static const Val_desc vda[] = {
1174f680cc6SAli Bahrami { GPD_DLSYM, MSG_GPD_DLSYM },
1184f680cc6SAli Bahrami { GPD_RELOC, MSG_GPD_RELOC },
1194f680cc6SAli Bahrami { GPD_ADDEPS, MSG_GPD_ADDEPS },
1204f680cc6SAli Bahrami { GPD_PARENT, MSG_GPD_PARENT },
1214f680cc6SAli Bahrami { GPD_FILTER, MSG_GPD_FILTER },
1224f680cc6SAli Bahrami { GPD_REMOVE, MSG_GPD_REMOVE },
1235aefb655Srie { 0, 0 }
1245aefb655Srie };
125de777a60Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = {
1264f680cc6SAli Bahrami NULL, sizeof (grpdesc_flags_buf->buf) };
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate if (flags == 0)
1297c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_NULL));
1307c478bd9Sstevel@tonic-gate
131de777a60Sab196087 conv_arg.buf = grpdesc_flags_buf->buf;
132ba4e3c84Sab196087 conv_arg.oflags = conv_arg.rflags = flags;
1334f680cc6SAli Bahrami (void) conv_expn_field(&conv_arg, vda, 0);
1347c478bd9Sstevel@tonic-gate
135de777a60Sab196087 return ((const char *)grpdesc_flags_buf->buf);
1367c478bd9Sstevel@tonic-gate }
137