15088Sab196087 /* 25088Sab196087 * CDDL HEADER START 35088Sab196087 * 45088Sab196087 * The contents of this file are subject to the terms of the 55088Sab196087 * Common Development and Distribution License (the "License"). 65088Sab196087 * You may not use this file except in compliance with the License. 75088Sab196087 * 85088Sab196087 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 95088Sab196087 * or http://www.opensolaris.org/os/licensing. 105088Sab196087 * See the License for the specific language governing permissions 115088Sab196087 * and limitations under the License. 125088Sab196087 * 135088Sab196087 * When distributing Covered Code, include this CDDL HEADER in each 145088Sab196087 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 155088Sab196087 * If applicable, add the following below this CDDL HEADER, with the 165088Sab196087 * fields enclosed by brackets "[]" replaced with your own identifying 175088Sab196087 * information: Portions Copyright [yyyy] [name of copyright owner] 185088Sab196087 * 195088Sab196087 * CDDL HEADER END 205088Sab196087 */ 215088Sab196087 225088Sab196087 /* 23*9273SAli.Bahrami@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 245088Sab196087 * Use is subject to license terms. 255088Sab196087 */ 265088Sab196087 275088Sab196087 /* 285088Sab196087 * String conversion routines for syminfo attributes. 295088Sab196087 */ 305088Sab196087 #include <stdio.h> 316206Sab196087 #include <_machelf.h> 325088Sab196087 #include "_conv.h" 335088Sab196087 #include "syminfo_msg.h" 345088Sab196087 355088Sab196087 365088Sab196087 37*9273SAli.Bahrami@Sun.COM static const Val_desc * 38*9273SAli.Bahrami@Sun.COM conv_syminfo_flags_strings(Conv_fmt_flags_t fmt_flags) 39*9273SAli.Bahrami@Sun.COM { 405088Sab196087 #define FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 41*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_FLG_DIRECT_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 42*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_FLG_FILTER_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 43*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_FLG_COPY_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 44*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_FLG_LAZYLOAD_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 45*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_FLG_DIRECTBIND_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 46*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_FLG_NOEXTDIRECT_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 47*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_FLG_AUXILIARY_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 48*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_FLG_INTERPOSE_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 495088Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 505088Sab196087 51*9273SAli.Bahrami@Sun.COM /* 52*9273SAli.Bahrami@Sun.COM * Ensure that Conv_syminfo_flags_buf_t is large enough: 53*9273SAli.Bahrami@Sun.COM * 54*9273SAli.Bahrami@Sun.COM * FLAGSZ is the real minimum size of the buffer required by 55*9273SAli.Bahrami@Sun.COM * conv_syminfo_flags(). However, Conv_syminfo_flags_buf_t uses 56*9273SAli.Bahrami@Sun.COM * CONV_SYMINFO_FLAGS_BUFSIZE to set the buffer size. We do things 57*9273SAli.Bahrami@Sun.COM * this way because the definition of FLAGSZ uses information that 58*9273SAli.Bahrami@Sun.COM * is not available in the environment of other programs that include 59*9273SAli.Bahrami@Sun.COM * the conv.h header file. 60*9273SAli.Bahrami@Sun.COM */ 615152Sab196087 #if (CONV_SYMINFO_FLAGS_BUFSIZE != FLAGSZ) && !defined(__lint) 625152Sab196087 #define REPORT_BUFSIZE FLAGSZ 635152Sab196087 #include "report_bufsize.h" 645152Sab196087 #error "CONV_SYMINFO_FLAGS_BUFSIZE does not match FLAGSZ" 655088Sab196087 #endif 665088Sab196087 67*9273SAli.Bahrami@Sun.COM static const Val_desc vda_cf[] = { 68*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_DIRECT, MSG_SYMINFO_FLG_DIRECT_CF }, 69*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_FILTER, MSG_SYMINFO_FLG_FILTER_CF }, 70*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_COPY, MSG_SYMINFO_FLG_COPY_CF }, 71*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_LAZYLOAD, MSG_SYMINFO_FLG_LAZYLOAD_CF }, 72*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_DIRECTBIND, MSG_SYMINFO_FLG_DIRECTBIND_CF }, 73*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_NOEXTDIRECT, MSG_SYMINFO_FLG_NOEXTDIRECT_CF }, 74*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_AUXILIARY, MSG_SYMINFO_FLG_AUXILIARY_CF }, 75*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_INTERPOSE, MSG_SYMINFO_FLG_INTERPOSE_CF }, 76*9273SAli.Bahrami@Sun.COM { 0 } 77*9273SAli.Bahrami@Sun.COM }; 78*9273SAli.Bahrami@Sun.COM static const Val_desc vda_cfnp[] = { 79*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_DIRECT, MSG_SYMINFO_FLG_DIRECT_CFNP }, 80*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_FILTER, MSG_SYMINFO_FLG_FILTER_CFNP }, 81*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_COPY, MSG_SYMINFO_FLG_COPY_CFNP }, 82*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_LAZYLOAD, MSG_SYMINFO_FLG_LAZYLOAD_CFNP }, 83*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_DIRECTBIND, MSG_SYMINFO_FLG_DIRECTBIND_CFNP }, 84*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_NOEXTDIRECT, MSG_SYMINFO_FLG_NOEXTDIRECT_CFNP }, 85*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_AUXILIARY, MSG_SYMINFO_FLG_AUXILIARY_CFNP }, 86*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_INTERPOSE, MSG_SYMINFO_FLG_INTERPOSE_CFNP }, 87*9273SAli.Bahrami@Sun.COM { 0 } 88*9273SAli.Bahrami@Sun.COM }; 89*9273SAli.Bahrami@Sun.COM static const Val_desc vda_nf[] = { 90*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_DIRECT, MSG_SYMINFO_FLG_DIRECT_NF }, 91*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_FILTER, MSG_SYMINFO_FLG_FILTER_NF }, 92*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_COPY, MSG_SYMINFO_FLG_COPY_NF }, 93*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_LAZYLOAD, MSG_SYMINFO_FLG_LAZYLOAD_NF }, 94*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_DIRECTBIND, MSG_SYMINFO_FLG_DIRECTBIND_NF }, 95*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_NOEXTDIRECT, MSG_SYMINFO_FLG_NOEXTDIRECT_NF }, 96*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_AUXILIARY, MSG_SYMINFO_FLG_AUXILIARY_NF }, 97*9273SAli.Bahrami@Sun.COM { SYMINFO_FLG_INTERPOSE, MSG_SYMINFO_FLG_INTERPOSE_NF }, 98*9273SAli.Bahrami@Sun.COM { 0 } 99*9273SAli.Bahrami@Sun.COM }; 100*9273SAli.Bahrami@Sun.COM 101*9273SAli.Bahrami@Sun.COM switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 102*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_CF: 103*9273SAli.Bahrami@Sun.COM return (vda_cf); 104*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 105*9273SAli.Bahrami@Sun.COM return (vda_nf); 106*9273SAli.Bahrami@Sun.COM } 107*9273SAli.Bahrami@Sun.COM 108*9273SAli.Bahrami@Sun.COM return (vda_cfnp); 109*9273SAli.Bahrami@Sun.COM } 110*9273SAli.Bahrami@Sun.COM 111*9273SAli.Bahrami@Sun.COM 1125088Sab196087 const char * 113*9273SAli.Bahrami@Sun.COM conv_syminfo_flags(Half flags, Conv_fmt_flags_t fmt_flags, 1145088Sab196087 Conv_syminfo_flags_buf_t *syminfo_flags_buf) 1155088Sab196087 { 1165088Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 117*9273SAli.Bahrami@Sun.COM NULL, sizeof (syminfo_flags_buf->buf) }; 1185088Sab196087 1195088Sab196087 if (flags == 0) 1205088Sab196087 return (MSG_ORIG(MSG_GBL_ZERO)); 1215088Sab196087 1225088Sab196087 conv_arg.buf = syminfo_flags_buf->buf; 1235088Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 1245088Sab196087 conv_arg.prefix = conv_arg.suffix = NULL; 125*9273SAli.Bahrami@Sun.COM (void) conv_expn_field(&conv_arg, 126*9273SAli.Bahrami@Sun.COM conv_syminfo_flags_strings(fmt_flags), fmt_flags); 1275088Sab196087 1285088Sab196087 return ((const char *)syminfo_flags_buf->buf); 1295088Sab196087 } 130*9273SAli.Bahrami@Sun.COM 131*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 132*9273SAli.Bahrami@Sun.COM conv_iter_syminfo_flags(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 133*9273SAli.Bahrami@Sun.COM void *uvalue) 134*9273SAli.Bahrami@Sun.COM { 135*9273SAli.Bahrami@Sun.COM return (conv_iter_vd(conv_syminfo_flags_strings(fmt_flags), 136*9273SAli.Bahrami@Sun.COM func, uvalue)); 137*9273SAli.Bahrami@Sun.COM } 138*9273SAli.Bahrami@Sun.COM 139*9273SAli.Bahrami@Sun.COM 140*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 141*9273SAli.Bahrami@Sun.COM conv_syminfo_boundto_strings(Conv_fmt_flags_t fmt_flags) 142*9273SAli.Bahrami@Sun.COM { 143*9273SAli.Bahrami@Sun.COM static const Msg boundto_cf[] = { 144*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_BT_EXTERN_CF, MSG_SYMINFO_BT_NONE_CF, 145*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_BT_PARENT_CF, MSG_SYMINFO_BT_SELF_CF 146*9273SAli.Bahrami@Sun.COM }; 147*9273SAli.Bahrami@Sun.COM static const Msg boundto_cfnp[] = { 148*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_BT_EXTERN_CFNP, MSG_SYMINFO_BT_NONE_CFNP, 149*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_BT_PARENT_CFNP, MSG_SYMINFO_BT_SELF_CFNP 150*9273SAli.Bahrami@Sun.COM }; 151*9273SAli.Bahrami@Sun.COM static const Msg boundto_nf[] = { 152*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_BT_EXTERN_NF, MSG_SYMINFO_BT_NONE_NF, 153*9273SAli.Bahrami@Sun.COM MSG_SYMINFO_BT_PARENT_NF, MSG_SYMINFO_BT_SELF_NF 154*9273SAli.Bahrami@Sun.COM }; 155*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_boundto_cf = { 156*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(SYMINFO_BT_EXTERN, boundto_cf) }; 157*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_boundto_cfnp = { 158*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(SYMINFO_BT_EXTERN, boundto_cfnp) }; 159*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_boundto_nf = { 160*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(SYMINFO_BT_EXTERN, boundto_nf) }; 161*9273SAli.Bahrami@Sun.COM 162*9273SAli.Bahrami@Sun.COM /* Build NULL terminated return arrays for each string style */ 163*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_cf[] = { 164*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_boundto_cf), NULL }; 165*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_cfnp[] = { 166*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_boundto_cfnp), NULL }; 167*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_nf[] = { 168*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_boundto_nf), NULL }; 169*9273SAli.Bahrami@Sun.COM 170*9273SAli.Bahrami@Sun.COM /* Select the strings to use */ 171*9273SAli.Bahrami@Sun.COM switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 172*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_CF: 173*9273SAli.Bahrami@Sun.COM return (ds_cf); 174*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 175*9273SAli.Bahrami@Sun.COM return (ds_nf); 176*9273SAli.Bahrami@Sun.COM } 177*9273SAli.Bahrami@Sun.COM 178*9273SAli.Bahrami@Sun.COM return (ds_cfnp); 179*9273SAli.Bahrami@Sun.COM } 180*9273SAli.Bahrami@Sun.COM 181*9273SAli.Bahrami@Sun.COM const char * 182*9273SAli.Bahrami@Sun.COM conv_syminfo_boundto(Half value, Conv_fmt_flags_t fmt_flags, 183*9273SAli.Bahrami@Sun.COM Conv_inv_buf_t *inv_buf) 184*9273SAli.Bahrami@Sun.COM { 185*9273SAli.Bahrami@Sun.COM return (conv_map_ds(ELFOSABI_NONE, EM_NONE, value, 186*9273SAli.Bahrami@Sun.COM conv_syminfo_boundto_strings(fmt_flags), fmt_flags, inv_buf)); 187*9273SAli.Bahrami@Sun.COM } 188*9273SAli.Bahrami@Sun.COM 189*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 190*9273SAli.Bahrami@Sun.COM conv_iter_syminfo_boundto(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 191*9273SAli.Bahrami@Sun.COM void *uvalue) 192*9273SAli.Bahrami@Sun.COM { 193*9273SAli.Bahrami@Sun.COM return (conv_iter_ds(ELFOSABI_NONE, EM_NONE, 194*9273SAli.Bahrami@Sun.COM conv_syminfo_boundto_strings(fmt_flags), func, uvalue)); 195*9273SAli.Bahrami@Sun.COM } 196