1d29b2c44Sab196087 /*
2d29b2c44Sab196087 * CDDL HEADER START
3d29b2c44Sab196087 *
4d29b2c44Sab196087 * The contents of this file are subject to the terms of the
5d29b2c44Sab196087 * Common Development and Distribution License (the "License").
6d29b2c44Sab196087 * You may not use this file except in compliance with the License.
7d29b2c44Sab196087 *
8d29b2c44Sab196087 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d29b2c44Sab196087 * or http://www.opensolaris.org/os/licensing.
10d29b2c44Sab196087 * See the License for the specific language governing permissions
11d29b2c44Sab196087 * and limitations under the License.
12d29b2c44Sab196087 *
13d29b2c44Sab196087 * When distributing Covered Code, include this CDDL HEADER in each
14d29b2c44Sab196087 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d29b2c44Sab196087 * If applicable, add the following below this CDDL HEADER, with the
16d29b2c44Sab196087 * fields enclosed by brackets "[]" replaced with your own identifying
17d29b2c44Sab196087 * information: Portions Copyright [yyyy] [name of copyright owner]
18d29b2c44Sab196087 *
19d29b2c44Sab196087 * CDDL HEADER END
20d29b2c44Sab196087 */
21d29b2c44Sab196087
22d29b2c44Sab196087 /*
23f441771bSRod Evans * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24d29b2c44Sab196087 */
25d29b2c44Sab196087
26d29b2c44Sab196087 /*
27d29b2c44Sab196087 * String conversion routines for syminfo attributes.
28d29b2c44Sab196087 */
29d29b2c44Sab196087 #include <stdio.h>
30ba2be530Sab196087 #include <_machelf.h>
31d29b2c44Sab196087 #include "_conv.h"
32d29b2c44Sab196087 #include "syminfo_msg.h"
33d29b2c44Sab196087
34d29b2c44Sab196087
35d29b2c44Sab196087
364f680cc6SAli Bahrami static const Val_desc *
conv_syminfo_flags_strings(Conv_fmt_flags_t fmt_flags)374f680cc6SAli Bahrami conv_syminfo_flags_strings(Conv_fmt_flags_t fmt_flags)
384f680cc6SAli Bahrami {
39d29b2c44Sab196087 #define FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
404f680cc6SAli Bahrami MSG_SYMINFO_FLG_DIRECT_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
414f680cc6SAli Bahrami MSG_SYMINFO_FLG_FILTER_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
424f680cc6SAli Bahrami MSG_SYMINFO_FLG_COPY_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
434f680cc6SAli Bahrami MSG_SYMINFO_FLG_LAZYLOAD_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
444f680cc6SAli Bahrami MSG_SYMINFO_FLG_DIRECTBIND_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
454f680cc6SAli Bahrami MSG_SYMINFO_FLG_NOEXTDIRECT_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
464f680cc6SAli Bahrami MSG_SYMINFO_FLG_AUXILIARY_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
474f680cc6SAli Bahrami MSG_SYMINFO_FLG_INTERPOSE_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
48f441771bSRod Evans MSG_SYMINFO_FLG_CAP_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
49f441771bSRod Evans MSG_SYMINFO_FLG_DEFERRED_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
50d29b2c44Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
51d29b2c44Sab196087
52d29b2c44Sab196087 /*
53d29b2c44Sab196087 * Ensure that Conv_syminfo_flags_buf_t is large enough:
54d29b2c44Sab196087 *
55d29b2c44Sab196087 * FLAGSZ is the real minimum size of the buffer required by
56d29b2c44Sab196087 * conv_syminfo_flags(). However, Conv_syminfo_flags_buf_t uses
57d29b2c44Sab196087 * CONV_SYMINFO_FLAGS_BUFSIZE to set the buffer size. We do things
58d29b2c44Sab196087 * this way because the definition of FLAGSZ uses information that
59d29b2c44Sab196087 * is not available in the environment of other programs that include
60d29b2c44Sab196087 * the conv.h header file.
61d29b2c44Sab196087 */
626a074c93Sab196087 #if (CONV_SYMINFO_FLAGS_BUFSIZE != FLAGSZ) && !defined(__lint)
636a074c93Sab196087 #define REPORT_BUFSIZE FLAGSZ
646a074c93Sab196087 #include "report_bufsize.h"
656a074c93Sab196087 #error "CONV_SYMINFO_FLAGS_BUFSIZE does not match FLAGSZ"
66d29b2c44Sab196087 #endif
67d29b2c44Sab196087
684f680cc6SAli Bahrami static const Val_desc vda_cf[] = {
694f680cc6SAli Bahrami { SYMINFO_FLG_DIRECT, MSG_SYMINFO_FLG_DIRECT_CF },
704f680cc6SAli Bahrami { SYMINFO_FLG_FILTER, MSG_SYMINFO_FLG_FILTER_CF },
714f680cc6SAli Bahrami { SYMINFO_FLG_COPY, MSG_SYMINFO_FLG_COPY_CF },
724f680cc6SAli Bahrami { SYMINFO_FLG_LAZYLOAD, MSG_SYMINFO_FLG_LAZYLOAD_CF },
734f680cc6SAli Bahrami { SYMINFO_FLG_DIRECTBIND, MSG_SYMINFO_FLG_DIRECTBIND_CF },
744f680cc6SAli Bahrami { SYMINFO_FLG_NOEXTDIRECT, MSG_SYMINFO_FLG_NOEXTDIRECT_CF },
754f680cc6SAli Bahrami { SYMINFO_FLG_AUXILIARY, MSG_SYMINFO_FLG_AUXILIARY_CF },
764f680cc6SAli Bahrami { SYMINFO_FLG_INTERPOSE, MSG_SYMINFO_FLG_INTERPOSE_CF },
7708278a5eSRod Evans { SYMINFO_FLG_CAP, MSG_SYMINFO_FLG_CAP_CF },
78f441771bSRod Evans { SYMINFO_FLG_DEFERRED, MSG_SYMINFO_FLG_DEFERRED_CF },
794f680cc6SAli Bahrami { 0 }
804f680cc6SAli Bahrami };
814f680cc6SAli Bahrami static const Val_desc vda_cfnp[] = {
824f680cc6SAli Bahrami { SYMINFO_FLG_DIRECT, MSG_SYMINFO_FLG_DIRECT_CFNP },
834f680cc6SAli Bahrami { SYMINFO_FLG_FILTER, MSG_SYMINFO_FLG_FILTER_CFNP },
844f680cc6SAli Bahrami { SYMINFO_FLG_COPY, MSG_SYMINFO_FLG_COPY_CFNP },
854f680cc6SAli Bahrami { SYMINFO_FLG_LAZYLOAD, MSG_SYMINFO_FLG_LAZYLOAD_CFNP },
864f680cc6SAli Bahrami { SYMINFO_FLG_DIRECTBIND, MSG_SYMINFO_FLG_DIRECTBIND_CFNP },
874f680cc6SAli Bahrami { SYMINFO_FLG_NOEXTDIRECT, MSG_SYMINFO_FLG_NOEXTDIRECT_CFNP },
884f680cc6SAli Bahrami { SYMINFO_FLG_AUXILIARY, MSG_SYMINFO_FLG_AUXILIARY_CFNP },
894f680cc6SAli Bahrami { SYMINFO_FLG_INTERPOSE, MSG_SYMINFO_FLG_INTERPOSE_CFNP },
9008278a5eSRod Evans { SYMINFO_FLG_CAP, MSG_SYMINFO_FLG_CAP_CFNP },
91f441771bSRod Evans { SYMINFO_FLG_DEFERRED, MSG_SYMINFO_FLG_DEFERRED_CFNP },
924f680cc6SAli Bahrami { 0 }
934f680cc6SAli Bahrami };
944f680cc6SAli Bahrami static const Val_desc vda_nf[] = {
954f680cc6SAli Bahrami { SYMINFO_FLG_DIRECT, MSG_SYMINFO_FLG_DIRECT_NF },
964f680cc6SAli Bahrami { SYMINFO_FLG_FILTER, MSG_SYMINFO_FLG_FILTER_NF },
974f680cc6SAli Bahrami { SYMINFO_FLG_COPY, MSG_SYMINFO_FLG_COPY_NF },
984f680cc6SAli Bahrami { SYMINFO_FLG_LAZYLOAD, MSG_SYMINFO_FLG_LAZYLOAD_NF },
994f680cc6SAli Bahrami { SYMINFO_FLG_DIRECTBIND, MSG_SYMINFO_FLG_DIRECTBIND_NF },
1004f680cc6SAli Bahrami { SYMINFO_FLG_NOEXTDIRECT, MSG_SYMINFO_FLG_NOEXTDIRECT_NF },
1014f680cc6SAli Bahrami { SYMINFO_FLG_AUXILIARY, MSG_SYMINFO_FLG_AUXILIARY_NF },
1024f680cc6SAli Bahrami { SYMINFO_FLG_INTERPOSE, MSG_SYMINFO_FLG_INTERPOSE_NF },
10308278a5eSRod Evans { SYMINFO_FLG_CAP, MSG_SYMINFO_FLG_CAP_NF },
104f441771bSRod Evans { SYMINFO_FLG_DEFERRED, MSG_SYMINFO_FLG_DEFERRED_NF },
1054f680cc6SAli Bahrami { 0 }
1064f680cc6SAli Bahrami };
1074f680cc6SAli Bahrami
1084f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
1094f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
1104f680cc6SAli Bahrami return (vda_cf);
1114f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
1124f680cc6SAli Bahrami return (vda_nf);
1134f680cc6SAli Bahrami }
1144f680cc6SAli Bahrami
1154f680cc6SAli Bahrami return (vda_cfnp);
1164f680cc6SAli Bahrami }
1174f680cc6SAli Bahrami
1184f680cc6SAli Bahrami
119d29b2c44Sab196087 const char *
conv_syminfo_flags(Half flags,Conv_fmt_flags_t fmt_flags,Conv_syminfo_flags_buf_t * syminfo_flags_buf)1204f680cc6SAli Bahrami conv_syminfo_flags(Half flags, Conv_fmt_flags_t fmt_flags,
121d29b2c44Sab196087 Conv_syminfo_flags_buf_t *syminfo_flags_buf)
122d29b2c44Sab196087 {
123d29b2c44Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = {
1244f680cc6SAli Bahrami NULL, sizeof (syminfo_flags_buf->buf) };
125d29b2c44Sab196087
126d29b2c44Sab196087 if (flags == 0)
127d29b2c44Sab196087 return (MSG_ORIG(MSG_GBL_ZERO));
128d29b2c44Sab196087
129d29b2c44Sab196087 conv_arg.buf = syminfo_flags_buf->buf;
130d29b2c44Sab196087 conv_arg.oflags = conv_arg.rflags = flags;
131d29b2c44Sab196087 conv_arg.prefix = conv_arg.suffix = NULL;
1324f680cc6SAli Bahrami (void) conv_expn_field(&conv_arg,
1334f680cc6SAli Bahrami conv_syminfo_flags_strings(fmt_flags), fmt_flags);
134d29b2c44Sab196087
135d29b2c44Sab196087 return ((const char *)syminfo_flags_buf->buf);
136d29b2c44Sab196087 }
1374f680cc6SAli Bahrami
1384f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_syminfo_flags(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)1394f680cc6SAli Bahrami conv_iter_syminfo_flags(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
1404f680cc6SAli Bahrami void *uvalue)
1414f680cc6SAli Bahrami {
1424f680cc6SAli Bahrami return (conv_iter_vd(conv_syminfo_flags_strings(fmt_flags),
1434f680cc6SAli Bahrami func, uvalue));
1444f680cc6SAli Bahrami }
1454f680cc6SAli Bahrami
1464f680cc6SAli Bahrami
1474f680cc6SAli Bahrami static const conv_ds_t **
conv_syminfo_boundto_strings(Conv_fmt_flags_t fmt_flags)1484f680cc6SAli Bahrami conv_syminfo_boundto_strings(Conv_fmt_flags_t fmt_flags)
1494f680cc6SAli Bahrami {
1504f680cc6SAli Bahrami static const Msg boundto_cf[] = {
1514f680cc6SAli Bahrami MSG_SYMINFO_BT_EXTERN_CF, MSG_SYMINFO_BT_NONE_CF,
1524f680cc6SAli Bahrami MSG_SYMINFO_BT_PARENT_CF, MSG_SYMINFO_BT_SELF_CF
1534f680cc6SAli Bahrami };
1544f680cc6SAli Bahrami static const Msg boundto_cfnp[] = {
1554f680cc6SAli Bahrami MSG_SYMINFO_BT_EXTERN_CFNP, MSG_SYMINFO_BT_NONE_CFNP,
1564f680cc6SAli Bahrami MSG_SYMINFO_BT_PARENT_CFNP, MSG_SYMINFO_BT_SELF_CFNP
1574f680cc6SAli Bahrami };
1584f680cc6SAli Bahrami static const Msg boundto_nf[] = {
1594f680cc6SAli Bahrami MSG_SYMINFO_BT_EXTERN_NF, MSG_SYMINFO_BT_NONE_NF,
1604f680cc6SAli Bahrami MSG_SYMINFO_BT_PARENT_NF, MSG_SYMINFO_BT_SELF_NF
1614f680cc6SAli Bahrami };
1624f680cc6SAli Bahrami static const conv_ds_msg_t ds_boundto_cf = {
1634f680cc6SAli Bahrami CONV_DS_MSG_INIT(SYMINFO_BT_EXTERN, boundto_cf) };
1644f680cc6SAli Bahrami static const conv_ds_msg_t ds_boundto_cfnp = {
1654f680cc6SAli Bahrami CONV_DS_MSG_INIT(SYMINFO_BT_EXTERN, boundto_cfnp) };
1664f680cc6SAli Bahrami static const conv_ds_msg_t ds_boundto_nf = {
1674f680cc6SAli Bahrami CONV_DS_MSG_INIT(SYMINFO_BT_EXTERN, boundto_nf) };
1684f680cc6SAli Bahrami
1694f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
170*e6d6d618SToomas Soome static const conv_ds_t *ds_cf[] = {
1714f680cc6SAli Bahrami CONV_DS_ADDR(ds_boundto_cf), NULL };
172*e6d6d618SToomas Soome static const conv_ds_t *ds_cfnp[] = {
1734f680cc6SAli Bahrami CONV_DS_ADDR(ds_boundto_cfnp), NULL };
174*e6d6d618SToomas Soome static const conv_ds_t *ds_nf[] = {
1754f680cc6SAli Bahrami CONV_DS_ADDR(ds_boundto_nf), NULL };
1764f680cc6SAli Bahrami
1774f680cc6SAli Bahrami /* Select the strings to use */
1784f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
1794f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
1804f680cc6SAli Bahrami return (ds_cf);
1814f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
1824f680cc6SAli Bahrami return (ds_nf);
1834f680cc6SAli Bahrami }
1844f680cc6SAli Bahrami
1854f680cc6SAli Bahrami return (ds_cfnp);
1864f680cc6SAli Bahrami }
1874f680cc6SAli Bahrami
1884f680cc6SAli Bahrami const char *
conv_syminfo_boundto(Half value,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)1894f680cc6SAli Bahrami conv_syminfo_boundto(Half value, Conv_fmt_flags_t fmt_flags,
1904f680cc6SAli Bahrami Conv_inv_buf_t *inv_buf)
1914f680cc6SAli Bahrami {
1924f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, EM_NONE, value,
1934f680cc6SAli Bahrami conv_syminfo_boundto_strings(fmt_flags), fmt_flags, inv_buf));
1944f680cc6SAli Bahrami }
1954f680cc6SAli Bahrami
1964f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_syminfo_boundto(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)1974f680cc6SAli Bahrami conv_iter_syminfo_boundto(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
1984f680cc6SAli Bahrami void *uvalue)
1994f680cc6SAli Bahrami {
2004f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, EM_NONE,
2014f680cc6SAli Bahrami conv_syminfo_boundto_strings(fmt_flags), func, uvalue));
2024f680cc6SAli Bahrami }
203