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 /*
237e16fca0SAli 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 /*
287c478bd9Sstevel@tonic-gate * String conversion routines for symbol attributes.
297c478bd9Sstevel@tonic-gate */
307c478bd9Sstevel@tonic-gate #include <stdio.h>
317c478bd9Sstevel@tonic-gate #include <sys/elf_SPARC.h>
3254d82594Sseizo #include <sys/elf_amd64.h>
335aefb655Srie #include "_conv.h"
345aefb655Srie #include "symbols_msg.h"
357c478bd9Sstevel@tonic-gate
365aefb655Srie const char *
conv_sym_other(uchar_t other,Conv_inv_buf_t * inv_buf)37de777a60Sab196087 conv_sym_other(uchar_t other, Conv_inv_buf_t *inv_buf)
385aefb655Srie {
3960758829Srie static const char visibility[7] = {
407c478bd9Sstevel@tonic-gate 'D', /* STV_DEFAULT */
417c478bd9Sstevel@tonic-gate 'I', /* STV_INTERNAL */
427c478bd9Sstevel@tonic-gate 'H', /* STV_HIDDEN */
4360758829Srie 'P', /* STV_PROTECTED */
4460758829Srie 'X', /* STV_EXPORTED */
4560758829Srie 'S', /* STV_SINGLETON */
4660758829Srie 'E' /* STV_ELIMINATE */
477c478bd9Sstevel@tonic-gate };
4860758829Srie uchar_t vis = ELF_ST_VISIBILITY(other);
497c478bd9Sstevel@tonic-gate uint_t ndx = 0;
507c478bd9Sstevel@tonic-gate
51de777a60Sab196087 inv_buf->buf[ndx++] = visibility[vis];
525aefb655Srie
537c478bd9Sstevel@tonic-gate /*
54d29b2c44Sab196087 * If unknown bits are present in st_other - throw out a '?'
557c478bd9Sstevel@tonic-gate */
565aefb655Srie if (other & ~MSK_SYM_VISIBILITY)
57de777a60Sab196087 inv_buf->buf[ndx++] = '?';
58de777a60Sab196087 inv_buf->buf[ndx++] = '\0';
597c478bd9Sstevel@tonic-gate
60de777a60Sab196087 return (inv_buf->buf);
617c478bd9Sstevel@tonic-gate }
627c478bd9Sstevel@tonic-gate
634f680cc6SAli Bahrami static const conv_ds_t **
conv_sym_other_vis_strings(Conv_fmt_flags_t fmt_flags)644f680cc6SAli Bahrami conv_sym_other_vis_strings(Conv_fmt_flags_t fmt_flags)
654f680cc6SAli Bahrami {
664f680cc6SAli Bahrami static const Msg vis_def[] = {
674f680cc6SAli Bahrami MSG_STV_DEFAULT_DEF, MSG_STV_INTERNAL_DEF,
684f680cc6SAli Bahrami MSG_STV_HIDDEN_DEF, MSG_STV_PROTECTED_DEF,
694f680cc6SAli Bahrami MSG_STV_EXPORTED_DEF, MSG_STV_SINGLETON_DEF,
704f680cc6SAli Bahrami MSG_STV_ELIMINATE_DEF
714f680cc6SAli Bahrami };
724f680cc6SAli Bahrami static const Msg vis_cf[] = {
734f680cc6SAli Bahrami MSG_STV_DEFAULT_CF, MSG_STV_INTERNAL_CF,
744f680cc6SAli Bahrami MSG_STV_HIDDEN_CF, MSG_STV_PROTECTED_CF,
754f680cc6SAli Bahrami MSG_STV_EXPORTED_CF, MSG_STV_SINGLETON_CF,
764f680cc6SAli Bahrami MSG_STV_ELIMINATE_CF
774f680cc6SAli Bahrami };
784f680cc6SAli Bahrami static const Msg vis_nf[] = {
794f680cc6SAli Bahrami MSG_STV_DEFAULT_NF, MSG_STV_INTERNAL_NF,
804f680cc6SAli Bahrami MSG_STV_HIDDEN_NF, MSG_STV_PROTECTED_NF,
814f680cc6SAli Bahrami MSG_STV_EXPORTED_NF, MSG_STV_SINGLETON_NF,
824f680cc6SAli Bahrami MSG_STV_ELIMINATE_NF
834f680cc6SAli Bahrami };
844f680cc6SAli Bahrami static const conv_ds_msg_t ds_vis_def = {
854f680cc6SAli Bahrami CONV_DS_MSG_INIT(STV_DEFAULT, vis_def) };
864f680cc6SAli Bahrami static const conv_ds_msg_t ds_vis_cf = {
874f680cc6SAli Bahrami CONV_DS_MSG_INIT(STV_DEFAULT, vis_cf) };
884f680cc6SAli Bahrami static const conv_ds_msg_t ds_vis_nf = {
894f680cc6SAli Bahrami CONV_DS_MSG_INIT(STV_DEFAULT, vis_nf) };
904f680cc6SAli Bahrami
914f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
92*59d2069dSToomas Soome static const conv_ds_t *ds_def[] = {
934f680cc6SAli Bahrami CONV_DS_ADDR(ds_vis_def), NULL };
94*59d2069dSToomas Soome static const conv_ds_t *ds_cf[] = {
954f680cc6SAli Bahrami CONV_DS_ADDR(ds_vis_cf), NULL };
96*59d2069dSToomas Soome static const conv_ds_t *ds_nf[] = {
974f680cc6SAli Bahrami CONV_DS_ADDR(ds_vis_nf), NULL };
984f680cc6SAli Bahrami
994f680cc6SAli Bahrami /* Select the strings to use */
1004f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
1014f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
1024f680cc6SAli Bahrami return (ds_cf);
1034f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
1044f680cc6SAli Bahrami return (ds_nf);
1054f680cc6SAli Bahrami }
1064f680cc6SAli Bahrami
1074f680cc6SAli Bahrami return (ds_def);
1084f680cc6SAli Bahrami }
1094f680cc6SAli Bahrami
1105aefb655Srie const char *
conv_sym_other_vis(uchar_t value,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)111d29b2c44Sab196087 conv_sym_other_vis(uchar_t value, Conv_fmt_flags_t fmt_flags,
112d29b2c44Sab196087 Conv_inv_buf_t *inv_buf)
113d29b2c44Sab196087 {
1144f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, EM_NONE, value,
1154f680cc6SAli Bahrami conv_sym_other_vis_strings(fmt_flags), fmt_flags, inv_buf));
1164f680cc6SAli Bahrami }
1174f680cc6SAli Bahrami
1184f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_sym_other_vis(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)1194f680cc6SAli Bahrami conv_iter_sym_other_vis(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
1204f680cc6SAli Bahrami void *uvalue)
1214f680cc6SAli Bahrami {
1224f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, EM_NONE,
1234f680cc6SAli Bahrami conv_sym_other_vis_strings(fmt_flags), func, uvalue));
1244f680cc6SAli Bahrami }
1254f680cc6SAli Bahrami
1264f680cc6SAli Bahrami static const conv_ds_t **
conv_sym_info_type_strings(Half mach,Conv_fmt_flags_t fmt_flags)1274f680cc6SAli Bahrami conv_sym_info_type_strings(Half mach, Conv_fmt_flags_t fmt_flags)
1284f680cc6SAli Bahrami {
1294f680cc6SAli Bahrami /*
1304f680cc6SAli Bahrami * This routine can return an array with 1 generic array, and
1314f680cc6SAli Bahrami * a machine array, plus the NULL termination.
1324f680cc6SAli Bahrami */
1334f680cc6SAli Bahrami #define MAX_RET 3
1344f680cc6SAli Bahrami
1354f680cc6SAli Bahrami static const Msg types_def[] = {
1364f680cc6SAli Bahrami MSG_STT_NOTYPE_DEF, MSG_STT_OBJECT_DEF,
1374f680cc6SAli Bahrami MSG_STT_FUNC_DEF, MSG_STT_SECTION_DEF,
1384f680cc6SAli Bahrami MSG_STT_FILE_DEF, MSG_STT_COMMON_DEF,
1394f680cc6SAli Bahrami MSG_STT_TLS_DEF, MSG_STT_IFUNC_DEF
140d29b2c44Sab196087 };
1414f680cc6SAli Bahrami static const Msg types_cf[] = {
1424f680cc6SAli Bahrami MSG_STT_NOTYPE_CF, MSG_STT_OBJECT_CF,
1434f680cc6SAli Bahrami MSG_STT_FUNC_CF, MSG_STT_SECTION_CF,
1444f680cc6SAli Bahrami MSG_STT_FILE_CF, MSG_STT_COMMON_CF,
1454f680cc6SAli Bahrami MSG_STT_TLS_CF, MSG_STT_IFUNC_CF
146d29b2c44Sab196087 };
1474f680cc6SAli Bahrami static const Msg types_nf[] = {
1484f680cc6SAli Bahrami MSG_STT_NOTYPE_NF, MSG_STT_OBJECT_NF,
1494f680cc6SAli Bahrami MSG_STT_FUNC_NF, MSG_STT_SECTION_NF,
1504f680cc6SAli Bahrami MSG_STT_FILE_NF, MSG_STT_COMMON_NF,
1514f680cc6SAli Bahrami MSG_STT_TLS_NF, MSG_STT_IFUNC_NF
1524f680cc6SAli Bahrami };
1534f680cc6SAli Bahrami static const conv_ds_msg_t ds_types_def = {
1544f680cc6SAli Bahrami CONV_DS_MSG_INIT(STT_NOTYPE, types_def) };
1554f680cc6SAli Bahrami static const conv_ds_msg_t ds_types_cf = {
1564f680cc6SAli Bahrami CONV_DS_MSG_INIT(STT_NOTYPE, types_cf) };
1574f680cc6SAli Bahrami static const conv_ds_msg_t ds_types_nf = {
1584f680cc6SAli Bahrami CONV_DS_MSG_INIT(STT_NOTYPE, types_nf) };
159d29b2c44Sab196087
160d29b2c44Sab196087
1614f680cc6SAli Bahrami static const Msg sparc_def[] = { MSG_STT_SPARC_REGISTER_DEF };
1624f680cc6SAli Bahrami static const Msg sparc_cf[] = { MSG_STT_SPARC_REGISTER_CF };
1634f680cc6SAli Bahrami static const Msg sparc_nf[] = { MSG_STT_SPARC_REGISTER_NF };
1644f680cc6SAli Bahrami static const conv_ds_msg_t ds_sparc_def = {
1654f680cc6SAli Bahrami CONV_DS_MSG_INIT(STT_SPARC_REGISTER, sparc_def) };
1664f680cc6SAli Bahrami static const conv_ds_msg_t ds_sparc_cf = {
1674f680cc6SAli Bahrami CONV_DS_MSG_INIT(STT_SPARC_REGISTER, sparc_cf) };
1684f680cc6SAli Bahrami static const conv_ds_msg_t ds_sparc_nf = {
1694f680cc6SAli Bahrami CONV_DS_MSG_INIT(STT_SPARC_REGISTER, sparc_nf) };
170d29b2c44Sab196087
1714f680cc6SAli Bahrami
1724f680cc6SAli Bahrami static const conv_ds_t *retarr[MAX_RET];
1734f680cc6SAli Bahrami
1744f680cc6SAli Bahrami int retndx = 0;
1754f680cc6SAli Bahrami int is_sparc;
1764f680cc6SAli Bahrami
1774f680cc6SAli Bahrami is_sparc = (mach == EM_SPARC) || (mach == EM_SPARCV9) ||
1784f680cc6SAli Bahrami (mach == EM_SPARC32PLUS) || (mach == CONV_MACH_ALL);
1794f680cc6SAli Bahrami
1804f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
1814f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
1824f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_types_cf);
1834f680cc6SAli Bahrami if (is_sparc)
1844f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_sparc_cf);
1854f680cc6SAli Bahrami break;
1864f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
1874f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_types_nf);
1884f680cc6SAli Bahrami if (is_sparc)
1894f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_sparc_nf);
1904f680cc6SAli Bahrami break;
1914f680cc6SAli Bahrami default:
1924f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_types_def);
1934f680cc6SAli Bahrami if (is_sparc)
1944f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_sparc_def);
1954f680cc6SAli Bahrami break;
1964f680cc6SAli Bahrami }
1974f680cc6SAli Bahrami
1984f680cc6SAli Bahrami retarr[retndx++] = NULL;
1994f680cc6SAli Bahrami assert(retndx <= MAX_RET);
2004f680cc6SAli Bahrami return (retarr);
201d29b2c44Sab196087 }
202d29b2c44Sab196087
203d29b2c44Sab196087 const char *
conv_sym_info_type(Half mach,uchar_t type,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)204d29b2c44Sab196087 conv_sym_info_type(Half mach, uchar_t type, Conv_fmt_flags_t fmt_flags,
205de777a60Sab196087 Conv_inv_buf_t *inv_buf)
2065aefb655Srie {
2074f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, mach, type,
2084f680cc6SAli Bahrami conv_sym_info_type_strings(mach, fmt_flags), fmt_flags, inv_buf));
209c13de8f6Sab196087 }
2104f680cc6SAli Bahrami
2114f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_sym_info_type(Half mach,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)2124f680cc6SAli Bahrami conv_iter_sym_info_type(Half mach, Conv_fmt_flags_t fmt_flags,
2134f680cc6SAli Bahrami conv_iter_cb_t func, void *uvalue)
2144f680cc6SAli Bahrami {
2154f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, mach,
2164f680cc6SAli Bahrami conv_sym_info_type_strings(mach, fmt_flags), func, uvalue));
2174f680cc6SAli Bahrami }
2184f680cc6SAli Bahrami
2194f680cc6SAli Bahrami static const conv_ds_t **
conv_sym_info_bind_strings(Conv_fmt_flags_t fmt_flags)2204f680cc6SAli Bahrami conv_sym_info_bind_strings(Conv_fmt_flags_t fmt_flags)
2214f680cc6SAli Bahrami {
2224f680cc6SAli Bahrami static const Msg binds_def[] = {
2234f680cc6SAli Bahrami MSG_STB_LOCAL_DEF, MSG_STB_GLOBAL_DEF,
2244f680cc6SAli Bahrami MSG_STB_WEAK_DEF
2254f680cc6SAli Bahrami };
2264f680cc6SAli Bahrami static const Msg binds_cf[] = {
2274f680cc6SAli Bahrami MSG_STB_LOCAL_CF, MSG_STB_GLOBAL_CF,
2284f680cc6SAli Bahrami MSG_STB_WEAK_CF
2294f680cc6SAli Bahrami };
2304f680cc6SAli Bahrami static const Msg binds_nf[] = {
2314f680cc6SAli Bahrami MSG_STB_LOCAL_NF, MSG_STB_GLOBAL_NF,
2324f680cc6SAli Bahrami MSG_STB_WEAK_NF
2334f680cc6SAli Bahrami };
2344f680cc6SAli Bahrami static const conv_ds_msg_t ds_binds_def = {
2354f680cc6SAli Bahrami CONV_DS_MSG_INIT(STB_LOCAL, binds_def) };
2364f680cc6SAli Bahrami static const conv_ds_msg_t ds_binds_cf = {
2374f680cc6SAli Bahrami CONV_DS_MSG_INIT(STB_LOCAL, binds_cf) };
2384f680cc6SAli Bahrami static const conv_ds_msg_t ds_binds_nf = {
2394f680cc6SAli Bahrami CONV_DS_MSG_INIT(STB_LOCAL, binds_nf) };
2404f680cc6SAli Bahrami
2414f680cc6SAli Bahrami
2424f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
243*59d2069dSToomas Soome static const conv_ds_t *ds_def[] = {
2444f680cc6SAli Bahrami CONV_DS_ADDR(ds_binds_def), NULL };
245*59d2069dSToomas Soome static const conv_ds_t *ds_cf[] = {
2464f680cc6SAli Bahrami CONV_DS_ADDR(ds_binds_cf), NULL };
247*59d2069dSToomas Soome static const conv_ds_t *ds_nf[] = {
2484f680cc6SAli Bahrami CONV_DS_ADDR(ds_binds_nf), NULL };
2494f680cc6SAli Bahrami
2504f680cc6SAli Bahrami
2514f680cc6SAli Bahrami /* Select the strings to use */
2524f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
2534f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
2544f680cc6SAli Bahrami return (ds_cf);
2554f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
2564f680cc6SAli Bahrami return (ds_nf);
2574f680cc6SAli Bahrami }
2584f680cc6SAli Bahrami
2594f680cc6SAli Bahrami return (ds_def);
2607c478bd9Sstevel@tonic-gate }
2617c478bd9Sstevel@tonic-gate
2625aefb655Srie const char *
conv_sym_info_bind(uchar_t bind,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)263d29b2c44Sab196087 conv_sym_info_bind(uchar_t bind, Conv_fmt_flags_t fmt_flags,
264d29b2c44Sab196087 Conv_inv_buf_t *inv_buf)
2655aefb655Srie {
2664f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, EM_NONE, bind,
2674f680cc6SAli Bahrami conv_sym_info_bind_strings(fmt_flags), fmt_flags, inv_buf));
2684f680cc6SAli Bahrami }
2694f680cc6SAli Bahrami
2704f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_sym_info_bind(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)2714f680cc6SAli Bahrami conv_iter_sym_info_bind(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
2724f680cc6SAli Bahrami void *uvalue)
2734f680cc6SAli Bahrami {
2744f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, EM_NONE,
2754f680cc6SAli Bahrami conv_sym_info_bind_strings(fmt_flags), func, uvalue));
2764f680cc6SAli Bahrami }
2774f680cc6SAli Bahrami
2784f680cc6SAli Bahrami static const conv_ds_t **
conv_sym_shndx_strings(Conv_fmt_flags_t fmt_flags)2794f680cc6SAli Bahrami conv_sym_shndx_strings(Conv_fmt_flags_t fmt_flags)
2804f680cc6SAli Bahrami {
2814f680cc6SAli Bahrami #define ALL ELFOSABI_NONE, EM_NONE
2824f680cc6SAli Bahrami #define SOL ELFOSABI_SOLARIS, EM_NONE
2834f680cc6SAli Bahrami #define AMD ELFOSABI_NONE, EM_AMD64
2844f680cc6SAli Bahrami
2854f680cc6SAli Bahrami /*
2864f680cc6SAli Bahrami * There aren't many of these values, and they are sparse,
2874f680cc6SAli Bahrami * so rather than separate them into different ranges, I use
2884f680cc6SAli Bahrami * a single Val_desc2 array for all of them.
2894f680cc6SAli Bahrami */
2904f680cc6SAli Bahrami static const Val_desc2 shn_def[] = {
2914f680cc6SAli Bahrami { SHN_UNDEF, ALL, MSG_SHN_UNDEF_CFNP },
2924f680cc6SAli Bahrami { SHN_BEFORE, ALL, MSG_SHN_BEFORE_CFNP },
2934f680cc6SAli Bahrami { SHN_AFTER, ALL, MSG_SHN_AFTER_CFNP },
2944f680cc6SAli Bahrami { SHN_AMD64_LCOMMON, AMD, MSG_SHN_AMD64_LCOMMON_DEF },
2954f680cc6SAli Bahrami { SHN_SUNW_IGNORE, SOL, MSG_SHN_SUNW_IGNORE_DEF },
2964f680cc6SAli Bahrami { SHN_ABS, ALL, MSG_SHN_ABS_CFNP },
2974f680cc6SAli Bahrami { SHN_COMMON, ALL, MSG_SHN_COMMON_CFNP },
2984f680cc6SAli Bahrami { SHN_XINDEX, ALL, MSG_SHN_XINDEX_CFNP },
2994f680cc6SAli Bahrami { 0 }
3007c478bd9Sstevel@tonic-gate };
3014f680cc6SAli Bahrami static const Val_desc2 shn_cf[] = {
3024f680cc6SAli Bahrami { SHN_UNDEF, ALL, MSG_SHN_UNDEF_CF },
3034f680cc6SAli Bahrami { SHN_BEFORE, ALL, MSG_SHN_BEFORE_CF },
3044f680cc6SAli Bahrami { SHN_AFTER, ALL, MSG_SHN_AFTER_CF },
3054f680cc6SAli Bahrami { SHN_AMD64_LCOMMON, AMD, MSG_SHN_AMD64_LCOMMON_CF },
3064f680cc6SAli Bahrami { SHN_SUNW_IGNORE, SOL, MSG_SHN_SUNW_IGNORE_CF },
3074f680cc6SAli Bahrami { SHN_ABS, ALL, MSG_SHN_ABS_CF },
3084f680cc6SAli Bahrami { SHN_COMMON, ALL, MSG_SHN_COMMON_CF },
3094f680cc6SAli Bahrami { SHN_XINDEX, ALL, MSG_SHN_XINDEX_CF },
3104f680cc6SAli Bahrami { 0 }
311d29b2c44Sab196087 };
3124f680cc6SAli Bahrami static const Val_desc2 shn_cfnp[] = {
3134f680cc6SAli Bahrami { SHN_UNDEF, ALL, MSG_SHN_UNDEF_CFNP },
3144f680cc6SAli Bahrami { SHN_BEFORE, ALL, MSG_SHN_BEFORE_CFNP },
3154f680cc6SAli Bahrami { SHN_AFTER, ALL, MSG_SHN_AFTER_CFNP },
3164f680cc6SAli Bahrami { SHN_AMD64_LCOMMON, AMD, MSG_SHN_AMD64_LCOMMON_CFNP },
3174f680cc6SAli Bahrami { SHN_SUNW_IGNORE, SOL, MSG_SHN_SUNW_IGNORE_CFNP },
3184f680cc6SAli Bahrami { SHN_ABS, ALL, MSG_SHN_ABS_CFNP },
3194f680cc6SAli Bahrami { SHN_COMMON, ALL, MSG_SHN_COMMON_CFNP },
3204f680cc6SAli Bahrami { SHN_XINDEX, ALL, MSG_SHN_XINDEX_CFNP },
3214f680cc6SAli Bahrami { 0 }
3224f680cc6SAli Bahrami };
3234f680cc6SAli Bahrami static const Val_desc2 shn_nf[] = {
3244f680cc6SAli Bahrami { SHN_UNDEF, ALL, MSG_SHN_UNDEF_NF },
3254f680cc6SAli Bahrami { SHN_BEFORE, ALL, MSG_SHN_BEFORE_NF },
3264f680cc6SAli Bahrami { SHN_AFTER, ALL, MSG_SHN_AFTER_NF },
3274f680cc6SAli Bahrami { SHN_AMD64_LCOMMON, AMD, MSG_SHN_AMD64_LCOMMON_NF },
3284f680cc6SAli Bahrami { SHN_SUNW_IGNORE, SOL, MSG_SHN_SUNW_IGNORE_NF },
3294f680cc6SAli Bahrami { SHN_ABS, ALL, MSG_SHN_ABS_NF },
3304f680cc6SAli Bahrami { SHN_COMMON, ALL, MSG_SHN_COMMON_NF },
3314f680cc6SAli Bahrami { SHN_XINDEX, ALL, MSG_SHN_XINDEX_NF },
3324f680cc6SAli Bahrami { 0 }
3334f680cc6SAli Bahrami };
3344f680cc6SAli Bahrami static const conv_ds_vd2_t ds_shn_def = {
3354f680cc6SAli Bahrami CONV_DS_VD2, SHN_UNDEF, SHN_XINDEX, shn_def };
3364f680cc6SAli Bahrami static const conv_ds_vd2_t ds_shn_cf = {
3374f680cc6SAli Bahrami CONV_DS_VD2, SHN_UNDEF, SHN_XINDEX, shn_cf };
3384f680cc6SAli Bahrami static const conv_ds_vd2_t ds_shn_cfnp = {
3394f680cc6SAli Bahrami CONV_DS_VD2, SHN_UNDEF, SHN_XINDEX, shn_cfnp };
3404f680cc6SAli Bahrami static const conv_ds_vd2_t ds_shn_nf = {
3414f680cc6SAli Bahrami CONV_DS_VD2, SHN_UNDEF, SHN_XINDEX, shn_nf };
342d29b2c44Sab196087
3434f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
344*59d2069dSToomas Soome static const conv_ds_t *ds_def[] = {
3454f680cc6SAli Bahrami CONV_DS_ADDR(ds_shn_def), NULL };
346*59d2069dSToomas Soome static const conv_ds_t *ds_cf[] = {
3474f680cc6SAli Bahrami CONV_DS_ADDR(ds_shn_cf), NULL };
348*59d2069dSToomas Soome static const conv_ds_t *ds_cfnp[] = {
3494f680cc6SAli Bahrami CONV_DS_ADDR(ds_shn_cfnp), NULL };
350*59d2069dSToomas Soome static const conv_ds_t *ds_nf[] = {
3514f680cc6SAli Bahrami CONV_DS_ADDR(ds_shn_nf), NULL };
352d29b2c44Sab196087
3534f680cc6SAli Bahrami /* Select the strings to use */
3544f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
3554f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
3564f680cc6SAli Bahrami return (ds_cf);
3574f680cc6SAli Bahrami case CONV_FMT_ALT_CFNP:
3584f680cc6SAli Bahrami return (ds_cfnp);
3594f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
3604f680cc6SAli Bahrami return (ds_nf);
3614f680cc6SAli Bahrami }
362d29b2c44Sab196087
3634f680cc6SAli Bahrami return (ds_def);
3644f680cc6SAli Bahrami
3654f680cc6SAli Bahrami #undef ALL
3664f680cc6SAli Bahrami #undef SOL
3674f680cc6SAli Bahrami #undef AMD
3687c478bd9Sstevel@tonic-gate }
3697c478bd9Sstevel@tonic-gate
3707c478bd9Sstevel@tonic-gate const char *
conv_sym_shndx(uchar_t osabi,Half mach,Half shndx,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)3714f680cc6SAli Bahrami conv_sym_shndx(uchar_t osabi, Half mach, Half shndx, Conv_fmt_flags_t fmt_flags,
3724f680cc6SAli Bahrami Conv_inv_buf_t *inv_buf)
3737c478bd9Sstevel@tonic-gate {
3744f680cc6SAli Bahrami return (conv_map_ds(osabi, mach, shndx,
3754f680cc6SAli Bahrami conv_sym_shndx_strings(fmt_flags), fmt_flags, inv_buf));
3764f680cc6SAli Bahrami }
3774f680cc6SAli Bahrami
3784f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_sym_shndx(conv_iter_osabi_t osabi,Half mach,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)3794f680cc6SAli Bahrami conv_iter_sym_shndx(conv_iter_osabi_t osabi, Half mach,
3804f680cc6SAli Bahrami Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, void *uvalue)
3814f680cc6SAli Bahrami {
3824f680cc6SAli Bahrami static const Msg amd64_alias_cf[] = { MSG_SHN_X86_64_LCOMMON_CF };
3834f680cc6SAli Bahrami static const conv_ds_msg_t ds_msg_amd64_alias_cf = {
3844f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHN_X86_64_LCOMMON, amd64_alias_cf) };
3854f680cc6SAli Bahrami static const conv_ds_t *ds_amd64_alias_cf[] = {
3864f680cc6SAli Bahrami CONV_DS_ADDR(ds_msg_amd64_alias_cf), NULL };
3874f680cc6SAli Bahrami
3884f680cc6SAli Bahrami static const Msg amd64_alias_cfnp[] = { MSG_SHN_X86_64_LCOMMON_CFNP };
3894f680cc6SAli Bahrami static const conv_ds_msg_t ds_msg_amd64_alias_cfnp = {
3904f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHN_X86_64_LCOMMON, amd64_alias_cfnp) };
3914f680cc6SAli Bahrami static const conv_ds_t *ds_amd64_alias_cfnp[] = {
3924f680cc6SAli Bahrami CONV_DS_ADDR(ds_msg_amd64_alias_cfnp), NULL };
3934f680cc6SAli Bahrami
3944f680cc6SAli Bahrami static const Msg amd64_alias_nf[] = { MSG_SHN_X86_64_LCOMMON_NF };
3954f680cc6SAli Bahrami static const conv_ds_msg_t ds_msg_amd64_alias_nf = {
3964f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHN_X86_64_LCOMMON, amd64_alias_nf) };
3974f680cc6SAli Bahrami static const conv_ds_t *ds_amd64_alias_nf[] = {
3984f680cc6SAli Bahrami CONV_DS_ADDR(ds_msg_amd64_alias_nf), NULL };
3994f680cc6SAli Bahrami
4004f680cc6SAli Bahrami
4014f680cc6SAli Bahrami if (conv_iter_ds(osabi, mach, conv_sym_shndx_strings(fmt_flags),
4024f680cc6SAli Bahrami func, uvalue) == CONV_ITER_DONE)
4034f680cc6SAli Bahrami return (CONV_ITER_DONE);
4044f680cc6SAli Bahrami
4054f680cc6SAli Bahrami /*
4064f680cc6SAli Bahrami * SHN_AMD64_LCOMMON is also known as SHN_X86_64_LCOMMON
4074f680cc6SAli Bahrami */
4084f680cc6SAli Bahrami if (mach == EM_AMD64) {
4094f680cc6SAli Bahrami const conv_ds_t **ds;
4104f680cc6SAli Bahrami
4114f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
4124f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
4134f680cc6SAli Bahrami ds = ds_amd64_alias_cf;
4144f680cc6SAli Bahrami break;
4154f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
4164f680cc6SAli Bahrami ds = ds_amd64_alias_nf;
4174f680cc6SAli Bahrami break;
4185aefb655Srie default:
4194f680cc6SAli Bahrami ds = ds_amd64_alias_cfnp;
4204f680cc6SAli Bahrami break;
4215aefb655Srie }
4224f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, mach, ds, func, uvalue));
4237c478bd9Sstevel@tonic-gate }
4247c478bd9Sstevel@tonic-gate
4254f680cc6SAli Bahrami return (CONV_ITER_CONT);
4267c478bd9Sstevel@tonic-gate }
427