1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #include <string.h> 28 #include "rtld.h" 29 #include "_conv.h" 30 #include "group_msg.h" 31 32 #define HDLSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 33 MSG_GPH_ZERO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 34 MSG_GPH_LDSO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 35 MSG_GPH_FIRST_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 36 MSG_GPH_FILTEE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 37 MSG_GPH_INITIAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 38 MSG_GPH_NOPENDLAZY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 39 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 40 41 /* 42 * Ensure that Conv_grphdl_flags_buf_t is large enough: 43 * 44 * HDLSZ is the real minimum size of the buffer required by conv_grphdl_flags(). 45 * However, Conv_grphdl_flags_buf_t uses CONV_GRPHDL_FLAGS_BUFSIZE to set the 46 * buffer size. We do things this way because the definition of HDLSZ uses 47 * information that is not available in the environment of other programs 48 * that include the conv.h header file. 49 */ 50 #if (CONV_GRPHDL_FLAGS_BUFSIZE != HDLSZ) && !defined(__lint) 51 #define REPORT_BUFSIZE HDLSZ 52 #include "report_bufsize.h" 53 #error "CONV_GRPHDL_FLAGS_BUFSIZE does not match HDLSZ" 54 #endif 55 56 /* 57 * String conversion routine for Grp_hdl flags. 58 */ 59 const char * 60 conv_grphdl_flags(uint_t flags, Conv_grphdl_flags_buf_t *grphdl_flags_buf) 61 { 62 static const Val_desc vda[] = { 63 { GPH_PUBLIC, MSG_GPH_PUBLIC }, 64 { GPH_PRIVATE, MSG_GPH_PRIVATE }, 65 { GPH_ZERO, MSG_GPH_ZERO }, 66 { GPH_LDSO, MSG_GPH_LDSO }, 67 { GPH_FIRST, MSG_GPH_FIRST }, 68 { GPH_FILTEE, MSG_GPH_FILTEE }, 69 { GPH_INITIAL, MSG_GPH_INITIAL }, 70 { GPH_NOPENDLAZY, MSG_GPH_NOPENDLAZY }, 71 { 0, 0 } 72 }; 73 static CONV_EXPN_FIELD_ARG conv_arg = { 74 NULL, sizeof (grphdl_flags_buf->buf) }; 75 76 if (flags == 0) 77 return (MSG_ORIG(MSG_GBL_NULL)); 78 79 conv_arg.buf = grphdl_flags_buf->buf; 80 conv_arg.oflags = conv_arg.rflags = flags; 81 (void) conv_expn_field(&conv_arg, vda, 0); 82 83 return ((const char *)grphdl_flags_buf->buf); 84 } 85 86 #define DESCSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 87 MSG_GPD_DLSYM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 88 MSG_GPD_RELOC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 89 MSG_GPD_ADDEPS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 90 MSG_GPD_PARENT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 91 MSG_GPD_FILTER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 92 MSG_GPD_PROMOTE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 93 MSG_GPD_REMOVE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 94 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 95 96 /* 97 * Ensure that Conv_grpdesc_flags_buf_t is large enough: 98 * 99 * DESCSZ is the real min size of the buffer required by conv_grpdesc_flags(). 100 * However, Conv_grpdesc_flags_buf_t uses CONV_GRPDESC_FLAGS_BUFSIZE to set the 101 * buffer size. We do things this way because the definition of DESCSZ uses 102 * information that is not available in the environment of other programs 103 * that include the conv.h header file. 104 */ 105 #if (CONV_GRPDESC_FLAGS_BUFSIZE != DESCSZ) && !defined(__lint) 106 #define REPORT_BUFSIZE DESCSZ 107 #include "report_bufsize.h" 108 #error "CONV_GRPDESC_FLAGS_BUFSIZE does not match DESCSZ" 109 #endif 110 111 /* 112 * String conversion routine for Grp_desc flags. 113 */ 114 const char * 115 conv_grpdesc_flags(uint_t flags, Conv_grpdesc_flags_buf_t *grpdesc_flags_buf) 116 { 117 static const Val_desc vda[] = { 118 { GPD_DLSYM, MSG_GPD_DLSYM }, 119 { GPD_RELOC, MSG_GPD_RELOC }, 120 { GPD_ADDEPS, MSG_GPD_ADDEPS }, 121 { GPD_PARENT, MSG_GPD_PARENT }, 122 { GPD_FILTER, MSG_GPD_FILTER }, 123 { GPD_REMOVE, MSG_GPD_REMOVE }, 124 { GPD_MODECHANGE, MSG_GPD_MODECHANGE }, 125 { 0, 0 } 126 }; 127 static CONV_EXPN_FIELD_ARG conv_arg = { 128 NULL, sizeof (grpdesc_flags_buf->buf) }; 129 130 if (flags == 0) 131 return (MSG_ORIG(MSG_GBL_NULL)); 132 133 conv_arg.buf = grpdesc_flags_buf->buf; 134 conv_arg.oflags = conv_arg.rflags = flags; 135 (void) conv_expn_field(&conv_arg, vda, 0); 136 137 return ((const char *)grpdesc_flags_buf->buf); 138 } 139