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 /*
23*dc0f59e5SAli Bahrami * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate * String conversion routines for ELF header attributes.
287c478bd9Sstevel@tonic-gate */
297c478bd9Sstevel@tonic-gate #include <stdio.h>
307c478bd9Sstevel@tonic-gate #include <string.h>
317c478bd9Sstevel@tonic-gate #include "_conv.h"
327c478bd9Sstevel@tonic-gate #include "elf_msg.h"
337c478bd9Sstevel@tonic-gate #include <sys/elf_SPARC.h>
347c478bd9Sstevel@tonic-gate
35c13de8f6Sab196087
36c13de8f6Sab196087
374f680cc6SAli Bahrami static const conv_ds_t **
ehdr_class_strings(Conv_fmt_flags_t fmt_flags)384f680cc6SAli Bahrami ehdr_class_strings(Conv_fmt_flags_t fmt_flags)
394f680cc6SAli Bahrami {
404f680cc6SAli Bahrami static const Msg class_cf[] = {
414f680cc6SAli Bahrami MSG_ELFCLASSNONE_CF, MSG_ELFCLASS32_CF, MSG_ELFCLASS64_CF
424f680cc6SAli Bahrami };
434f680cc6SAli Bahrami static const Msg class_nf[] = {
444f680cc6SAli Bahrami MSG_ELFCLASSNONE_NF, MSG_ELFCLASS32_NF, MSG_ELFCLASS64_NF
454f680cc6SAli Bahrami };
464f680cc6SAli Bahrami static const Msg class_dump[] = {
474f680cc6SAli Bahrami MSG_ELFCLASSNONE_DMP, MSG_ELFCLASS32_DMP, MSG_ELFCLASS64_DMP
484f680cc6SAli Bahrami };
49c13de8f6Sab196087
504f680cc6SAli Bahrami static const conv_ds_msg_t ds_classes_cf = {
514f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFCLASSNONE, class_cf) };
524f680cc6SAli Bahrami static const conv_ds_msg_t ds_classes_nf = {
534f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFCLASSNONE, class_nf) };
544f680cc6SAli Bahrami static const conv_ds_msg_t ds_classes_dump = {
554f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFCLASSNONE, class_dump) };
56c13de8f6Sab196087
574f680cc6SAli Bahrami static const conv_ds_t *ds_cf[] = { CONV_DS_ADDR(ds_classes_cf), NULL };
584f680cc6SAli Bahrami static const conv_ds_t *ds_nf[] = { CONV_DS_ADDR(ds_classes_nf), NULL };
594f680cc6SAli Bahrami static const conv_ds_t *ds_dump[] = {
604f680cc6SAli Bahrami CONV_DS_ADDR(ds_classes_dump), NULL };
614f680cc6SAli Bahrami
624f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
634f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
644f680cc6SAli Bahrami case CONV_FMT_ALT_FILE:
654f680cc6SAli Bahrami return (ds_dump);
664f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
674f680cc6SAli Bahrami return (ds_nf);
684f680cc6SAli Bahrami }
694f680cc6SAli Bahrami
704f680cc6SAli Bahrami return (ds_cf);
714f680cc6SAli Bahrami }
72c13de8f6Sab196087
735aefb655Srie const char *
conv_ehdr_class(uchar_t class,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)74d29b2c44Sab196087 conv_ehdr_class(uchar_t class, Conv_fmt_flags_t fmt_flags,
75d29b2c44Sab196087 Conv_inv_buf_t *inv_buf)
765aefb655Srie {
774f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, EM_NONE, class,
784f680cc6SAli Bahrami ehdr_class_strings(fmt_flags), fmt_flags, inv_buf));
79d29b2c44Sab196087 }
80d29b2c44Sab196087
814f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_class(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)824f680cc6SAli Bahrami conv_iter_ehdr_class(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
834f680cc6SAli Bahrami void *uvalue)
844f680cc6SAli Bahrami {
854f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, EM_NONE,
864f680cc6SAli Bahrami ehdr_class_strings(fmt_flags), func, uvalue));
874f680cc6SAli Bahrami }
884f680cc6SAli Bahrami
894f680cc6SAli Bahrami static const conv_ds_t **
ehdr_data_strings(Conv_fmt_flags_t fmt_flags)904f680cc6SAli Bahrami ehdr_data_strings(Conv_fmt_flags_t fmt_flags)
914f680cc6SAli Bahrami {
924f680cc6SAli Bahrami static const Msg data_cf[] = {
934f680cc6SAli Bahrami MSG_ELFDATANONE_CF, MSG_ELFDATA2LSB_CF, MSG_ELFDATA2MSB_CF
944f680cc6SAli Bahrami };
954f680cc6SAli Bahrami static const Msg data_nf[] = {
964f680cc6SAli Bahrami MSG_ELFDATANONE_NF, MSG_ELFDATA2LSB_NF, MSG_ELFDATA2MSB_NF
974f680cc6SAli Bahrami };
984f680cc6SAli Bahrami static const Msg data_dump[] = {
994f680cc6SAli Bahrami MSG_ELFDATANONE_DMP, MSG_ELFDATA2LSB_DMP, MSG_ELFDATA2MSB_DMP
1004f680cc6SAli Bahrami };
1014f680cc6SAli Bahrami static const Msg data_file[] = {
1024f680cc6SAli Bahrami MSG_ELFDATANONE_DMP, MSG_ELFDATA2LSB_FIL, MSG_ELFDATA2MSB_FIL
1034f680cc6SAli Bahrami };
1044f680cc6SAli Bahrami
1054f680cc6SAli Bahrami
1064f680cc6SAli Bahrami static const conv_ds_msg_t ds_data_cf = {
1074f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFCLASSNONE, data_cf) };
1084f680cc6SAli Bahrami static const conv_ds_msg_t ds_data_nf = {
1094f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFCLASSNONE, data_nf) };
1104f680cc6SAli Bahrami static const conv_ds_msg_t ds_data_dump = {
1114f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFCLASSNONE, data_dump) };
1124f680cc6SAli Bahrami static const conv_ds_msg_t ds_data_file = {
1134f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFCLASSNONE, data_file) };
1144f680cc6SAli Bahrami
1154f680cc6SAli Bahrami static const conv_ds_t *ds_cf[] = { CONV_DS_ADDR(ds_data_cf), NULL };
1164f680cc6SAli Bahrami static const conv_ds_t *ds_nf[] = { CONV_DS_ADDR(ds_data_nf), NULL };
1174f680cc6SAli Bahrami static const conv_ds_t *ds_dump[] = { CONV_DS_ADDR(ds_data_dump),
1184f680cc6SAli Bahrami NULL };
1194f680cc6SAli Bahrami static const conv_ds_t *ds_file[] = { CONV_DS_ADDR(ds_data_file),
1204f680cc6SAli Bahrami NULL };
1214f680cc6SAli Bahrami
1224f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
1234f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
1244f680cc6SAli Bahrami return (ds_dump);
1254f680cc6SAli Bahrami case CONV_FMT_ALT_FILE:
1264f680cc6SAli Bahrami return (ds_file);
1274f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
1284f680cc6SAli Bahrami return (ds_nf);
1294f680cc6SAli Bahrami }
1304f680cc6SAli Bahrami
1314f680cc6SAli Bahrami return (ds_cf);
1327c478bd9Sstevel@tonic-gate }
1337c478bd9Sstevel@tonic-gate
1345aefb655Srie const char *
conv_ehdr_data(uchar_t data,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)135d29b2c44Sab196087 conv_ehdr_data(uchar_t data, Conv_fmt_flags_t fmt_flags,
136d29b2c44Sab196087 Conv_inv_buf_t *inv_buf)
1375aefb655Srie {
1384f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, EM_NONE, data,
1394f680cc6SAli Bahrami ehdr_data_strings(fmt_flags), fmt_flags, inv_buf));
140d29b2c44Sab196087 }
141d29b2c44Sab196087
1424f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_data(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)1434f680cc6SAli Bahrami conv_iter_ehdr_data(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
1444f680cc6SAli Bahrami void *uvalue)
1454f680cc6SAli Bahrami {
1464f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, EM_NONE,
1474f680cc6SAli Bahrami ehdr_data_strings(fmt_flags), func, uvalue));
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate
1504f680cc6SAli Bahrami static const conv_ds_t **
ehdr_mach_strings(Conv_fmt_flags_t fmt_flags)1514f680cc6SAli Bahrami ehdr_mach_strings(Conv_fmt_flags_t fmt_flags)
1524f680cc6SAli Bahrami {
1534f680cc6SAli Bahrami
1544f680cc6SAli Bahrami static const Msg mach_0_11_cf[] = {
1554f680cc6SAli Bahrami MSG_EM_NONE_CF, MSG_EM_M32_CF,
1564f680cc6SAli Bahrami MSG_EM_SPARC_CF, MSG_EM_386_CF,
1574f680cc6SAli Bahrami MSG_EM_68K_CF, MSG_EM_88K_CF,
1584f680cc6SAli Bahrami MSG_EM_486_CF, MSG_EM_860_CF,
1594f680cc6SAli Bahrami MSG_EM_MIPS_CF, MSG_EM_S370_CF,
1604f680cc6SAli Bahrami MSG_EM_MIPS_RS3_LE_CF, MSG_EM_RS6000_CF
1617c478bd9Sstevel@tonic-gate };
1624f680cc6SAli Bahrami static const Msg mach_0_11_nf[] = {
1634f680cc6SAli Bahrami MSG_EM_NONE_NF, MSG_EM_M32_NF,
1644f680cc6SAli Bahrami MSG_EM_SPARC_NF, MSG_EM_386_NF,
1654f680cc6SAli Bahrami MSG_EM_68K_NF, MSG_EM_88K_NF,
1664f680cc6SAli Bahrami MSG_EM_486_NF, MSG_EM_860_NF,
1674f680cc6SAli Bahrami MSG_EM_MIPS_NF, MSG_EM_S370_NF,
1684f680cc6SAli Bahrami MSG_EM_MIPS_RS3_LE_NF, MSG_EM_RS6000_NF
1694f680cc6SAli Bahrami };
1704f680cc6SAli Bahrami static const Msg mach_0_11_dmp[] = {
1714f680cc6SAli Bahrami MSG_EM_NONE_DMP, MSG_EM_M32_DMP,
1724f680cc6SAli Bahrami MSG_EM_SPARC_DMP, MSG_EM_386_DMP,
1734f680cc6SAli Bahrami MSG_EM_68K_DMP, MSG_EM_88K_DMP,
1744f680cc6SAli Bahrami MSG_EM_486_DMP, MSG_EM_860_DMP,
1754f680cc6SAli Bahrami MSG_EM_MIPS_DMP, MSG_EM_S370_CF,
1764f680cc6SAli Bahrami MSG_EM_MIPS_RS3_LE_DMP, MSG_EM_RS6000_DMP
1774f680cc6SAli Bahrami };
1784f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_0_11_cf = {
1794f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_NONE, mach_0_11_cf) };
1804f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_0_11_nf = {
1814f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_NONE, mach_0_11_nf) };
1824f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_0_11_dmp = {
1834f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_NONE, mach_0_11_dmp) };
1844f680cc6SAli Bahrami
1854f680cc6SAli Bahrami
1864f680cc6SAli Bahrami static const Msg mach_15_22_cf[] = {
1874f680cc6SAli Bahrami MSG_EM_PA_RISC_CF, MSG_EM_NCUBE_CF,
1884f680cc6SAli Bahrami MSG_EM_VPP500_CF, MSG_EM_SPARC32PLUS_CF,
1894f680cc6SAli Bahrami MSG_EM_960_CF, MSG_EM_PPC_CF,
1904f680cc6SAli Bahrami MSG_EM_PPC64_CF, MSG_EM_S390_CF
1914f680cc6SAli Bahrami };
1924f680cc6SAli Bahrami static const Msg mach_15_22_nf[] = {
1934f680cc6SAli Bahrami MSG_EM_PA_RISC_NF, MSG_EM_NCUBE_NF,
1944f680cc6SAli Bahrami MSG_EM_VPP500_NF, MSG_EM_SPARC32PLUS_NF,
1954f680cc6SAli Bahrami MSG_EM_960_NF, MSG_EM_PPC_NF,
1964f680cc6SAli Bahrami MSG_EM_PPC64_NF, MSG_EM_S390_NF
1974f680cc6SAli Bahrami };
1984f680cc6SAli Bahrami static const Msg mach_15_22_dmp[] = {
1994f680cc6SAli Bahrami MSG_EM_PA_RISC_DMP, MSG_EM_NCUBE_DMP,
2004f680cc6SAli Bahrami MSG_EM_VPP500_DMP, MSG_EM_SPARC32PLUS_DMP,
2014f680cc6SAli Bahrami MSG_EM_960_CF, MSG_EM_PPC_DMP,
2024f680cc6SAli Bahrami MSG_EM_PPC64_DMP, MSG_EM_S390_CF
2034f680cc6SAli Bahrami };
2044f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_15_22_cf = {
2054f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_PA_RISC, mach_15_22_cf) };
2064f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_15_22_nf = {
2074f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_PA_RISC, mach_15_22_nf) };
2084f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_15_22_dmp = {
2094f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_PA_RISC, mach_15_22_dmp) };
2104f680cc6SAli Bahrami
2114f680cc6SAli Bahrami
2124f680cc6SAli Bahrami static const Msg mach_36_63_cf[] = {
2134f680cc6SAli Bahrami MSG_EM_V800_CF, MSG_EM_FR20_CF,
2144f680cc6SAli Bahrami MSG_EM_RH32_CF, MSG_EM_RCE_CF,
2154f680cc6SAli Bahrami MSG_EM_ARM_CF, MSG_EM_ALPHA_CF,
2164f680cc6SAli Bahrami MSG_EM_SH_CF, MSG_EM_SPARCV9_CF,
2174f680cc6SAli Bahrami MSG_EM_TRICORE_CF, MSG_EM_ARC_CF,
2184f680cc6SAli Bahrami MSG_EM_H8_300_CF, MSG_EM_H8_300H_CF,
2194f680cc6SAli Bahrami MSG_EM_H8S_CF, MSG_EM_H8_500_CF,
2204f680cc6SAli Bahrami MSG_EM_IA_64_CF, MSG_EM_MIPS_X_CF,
2214f680cc6SAli Bahrami MSG_EM_COLDFIRE_CF, MSG_EM_68HC12_CF,
2224f680cc6SAli Bahrami MSG_EM_MMA_CF, MSG_EM_PCP_CF,
2234f680cc6SAli Bahrami MSG_EM_NCPU_CF, MSG_EM_NDR1_CF,
2244f680cc6SAli Bahrami MSG_EM_STARCORE_CF, MSG_EM_ME16_CF,
2254f680cc6SAli Bahrami MSG_EM_ST100_CF, MSG_EM_TINYJ_CF,
2264f680cc6SAli Bahrami MSG_EM_AMD64_CF, MSG_EM_PDSP_CF
2274f680cc6SAli Bahrami };
2284f680cc6SAli Bahrami static const Msg mach_36_63_nf[] = {
2294f680cc6SAli Bahrami MSG_EM_V800_NF, MSG_EM_FR20_NF,
2304f680cc6SAli Bahrami MSG_EM_RH32_NF, MSG_EM_RCE_NF,
2314f680cc6SAli Bahrami MSG_EM_ARM_NF, MSG_EM_ALPHA_NF,
2324f680cc6SAli Bahrami MSG_EM_SH_NF, MSG_EM_SPARCV9_NF,
2334f680cc6SAli Bahrami MSG_EM_TRICORE_NF, MSG_EM_ARC_NF,
2344f680cc6SAli Bahrami MSG_EM_H8_300_NF, MSG_EM_H8_300H_NF,
2354f680cc6SAli Bahrami MSG_EM_H8S_NF, MSG_EM_H8_500_NF,
2364f680cc6SAli Bahrami MSG_EM_IA_64_NF, MSG_EM_MIPS_X_NF,
2374f680cc6SAli Bahrami MSG_EM_COLDFIRE_NF, MSG_EM_68HC12_NF,
2384f680cc6SAli Bahrami MSG_EM_MMA_NF, MSG_EM_PCP_NF,
2394f680cc6SAli Bahrami MSG_EM_NCPU_NF, MSG_EM_NDR1_NF,
2404f680cc6SAli Bahrami MSG_EM_STARCORE_NF, MSG_EM_ME16_NF,
2414f680cc6SAli Bahrami MSG_EM_ST100_NF, MSG_EM_TINYJ_NF,
2424f680cc6SAli Bahrami MSG_EM_AMD64_NF, MSG_EM_PDSP_NF
2434f680cc6SAli Bahrami };
2444f680cc6SAli Bahrami static const Msg mach_36_63_dmp[] = {
2454f680cc6SAli Bahrami MSG_EM_V800_CF, MSG_EM_FR20_CF,
2464f680cc6SAli Bahrami MSG_EM_RH32_CF, MSG_EM_RCE_CF,
2474f680cc6SAli Bahrami MSG_EM_ARM_DMP, MSG_EM_ALPHA_DMP,
2484f680cc6SAli Bahrami MSG_EM_SH_CF, MSG_EM_SPARCV9_DMP,
2494f680cc6SAli Bahrami MSG_EM_TRICORE_CF, MSG_EM_ARC_CF,
2504f680cc6SAli Bahrami MSG_EM_H8_300_CF, MSG_EM_H8_300H_CF,
2514f680cc6SAli Bahrami MSG_EM_H8S_CF, MSG_EM_H8_500_CF,
2524f680cc6SAli Bahrami MSG_EM_IA_64_DMP, MSG_EM_MIPS_X_CF,
2534f680cc6SAli Bahrami MSG_EM_COLDFIRE_CF, MSG_EM_68HC12_CF,
2544f680cc6SAli Bahrami MSG_EM_MMA_CF, MSG_EM_PCP_CF,
2554f680cc6SAli Bahrami MSG_EM_NCPU_CF, MSG_EM_NDR1_CF,
2564f680cc6SAli Bahrami MSG_EM_STARCORE_CF, MSG_EM_ME16_CF,
2574f680cc6SAli Bahrami MSG_EM_ST100_CF, MSG_EM_TINYJ_CF,
2584f680cc6SAli Bahrami MSG_EM_AMD64_DMP, MSG_EM_PDSP_CF
2594f680cc6SAli Bahrami };
2604f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_36_63_cf = {
2614f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_V800, mach_36_63_cf) };
2624f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_36_63_nf = {
2634f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_V800, mach_36_63_nf) };
2644f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_36_63_dmp = {
2654f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_V800, mach_36_63_dmp) };
2664f680cc6SAli Bahrami
2674f680cc6SAli Bahrami
2684f680cc6SAli Bahrami static const Msg mach_66_94_cf[] = {
2694f680cc6SAli Bahrami MSG_EM_FX66_CF, MSG_EM_ST9PLUS_CF,
2704f680cc6SAli Bahrami MSG_EM_ST7_CF, MSG_EM_68HC16_CF,
2714f680cc6SAli Bahrami MSG_EM_68HC11_CF, MSG_EM_68HC08_CF,
2724f680cc6SAli Bahrami MSG_EM_68HC05_CF, MSG_EM_SVX_CF,
2734f680cc6SAli Bahrami MSG_EM_ST19_CF, MSG_EM_VAX_CF,
2744f680cc6SAli Bahrami MSG_EM_CRIS_CF, MSG_EM_JAVELIN_CF,
2754f680cc6SAli Bahrami MSG_EM_FIREPATH_CF, MSG_EM_ZSP_CF,
2764f680cc6SAli Bahrami MSG_EM_MMIX_CF, MSG_EM_HUANY_CF,
2774f680cc6SAli Bahrami MSG_EM_PRISM_CF, MSG_EM_AVR_CF,
2784f680cc6SAli Bahrami MSG_EM_FR30_CF, MSG_EM_D10V_CF,
2794f680cc6SAli Bahrami MSG_EM_D30V_CF, MSG_EM_V850_CF,
2804f680cc6SAli Bahrami MSG_EM_M32R_CF, MSG_EM_MN10300_CF,
2814f680cc6SAli Bahrami MSG_EM_MN10200_CF, MSG_EM_PJ_CF,
2824f680cc6SAli Bahrami MSG_EM_OPENRISC_CF, MSG_EM_ARC_A5_CF,
2834f680cc6SAli Bahrami MSG_EM_XTENSA_CF
2844f680cc6SAli Bahrami };
2854f680cc6SAli Bahrami static const Msg mach_66_94_nf[] = {
2864f680cc6SAli Bahrami MSG_EM_FX66_NF, MSG_EM_ST9PLUS_NF,
2874f680cc6SAli Bahrami MSG_EM_ST7_NF, MSG_EM_68HC16_NF,
2884f680cc6SAli Bahrami MSG_EM_68HC11_NF, MSG_EM_68HC08_NF,
2894f680cc6SAli Bahrami MSG_EM_68HC05_NF, MSG_EM_SVX_NF,
2904f680cc6SAli Bahrami MSG_EM_ST19_NF, MSG_EM_VAX_NF,
2914f680cc6SAli Bahrami MSG_EM_CRIS_NF, MSG_EM_JAVELIN_NF,
2924f680cc6SAli Bahrami MSG_EM_FIREPATH_NF, MSG_EM_ZSP_NF,
2934f680cc6SAli Bahrami MSG_EM_MMIX_NF, MSG_EM_HUANY_NF,
2944f680cc6SAli Bahrami MSG_EM_PRISM_NF, MSG_EM_AVR_NF,
2954f680cc6SAli Bahrami MSG_EM_FR30_NF, MSG_EM_D10V_NF,
2964f680cc6SAli Bahrami MSG_EM_D30V_NF, MSG_EM_V850_NF,
2974f680cc6SAli Bahrami MSG_EM_M32R_NF, MSG_EM_MN10300_NF,
2984f680cc6SAli Bahrami MSG_EM_MN10200_NF, MSG_EM_PJ_NF,
2994f680cc6SAli Bahrami MSG_EM_OPENRISC_NF, MSG_EM_ARC_A5_NF,
3004f680cc6SAli Bahrami MSG_EM_XTENSA_NF
3014f680cc6SAli Bahrami };
3024f680cc6SAli Bahrami static const Msg mach_66_94_dmp[] = {
3034f680cc6SAli Bahrami MSG_EM_FX66_CF, MSG_EM_ST9PLUS_CF,
3044f680cc6SAli Bahrami MSG_EM_ST7_CF, MSG_EM_68HC16_CF,
3054f680cc6SAli Bahrami MSG_EM_68HC11_CF, MSG_EM_68HC08_CF,
3064f680cc6SAli Bahrami MSG_EM_68HC05_CF, MSG_EM_SVX_CF,
3074f680cc6SAli Bahrami MSG_EM_ST19_CF, MSG_EM_VAX_DMP,
3084f680cc6SAli Bahrami MSG_EM_CRIS_CF, MSG_EM_JAVELIN_CF,
3094f680cc6SAli Bahrami MSG_EM_FIREPATH_CF, MSG_EM_ZSP_CF,
3104f680cc6SAli Bahrami MSG_EM_MMIX_CF, MSG_EM_HUANY_CF,
3114f680cc6SAli Bahrami MSG_EM_PRISM_CF, MSG_EM_AVR_CF,
3124f680cc6SAli Bahrami MSG_EM_FR30_CF, MSG_EM_D10V_CF,
3134f680cc6SAli Bahrami MSG_EM_D30V_CF, MSG_EM_V850_CF,
3144f680cc6SAli Bahrami MSG_EM_M32R_CF, MSG_EM_MN10300_CF,
3154f680cc6SAli Bahrami MSG_EM_MN10200_CF, MSG_EM_PJ_CF,
3164f680cc6SAli Bahrami MSG_EM_OPENRISC_CF, MSG_EM_ARC_A5_CF,
3174f680cc6SAli Bahrami MSG_EM_XTENSA_CF
318c13de8f6Sab196087 };
3197c478bd9Sstevel@tonic-gate #if (EM_NUM != (EM_XTENSA + 1))
3207c478bd9Sstevel@tonic-gate #error "EM_NUM has grown"
3217c478bd9Sstevel@tonic-gate #endif
3224f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_66_94_cf = {
3234f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_FX66, mach_66_94_cf) };
3244f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_66_94_nf = {
3254f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_FX66, mach_66_94_nf) };
3264f680cc6SAli Bahrami static const conv_ds_msg_t ds_mach_66_94_dmp = {
3274f680cc6SAli Bahrami CONV_DS_MSG_INIT(EM_FX66, mach_66_94_dmp) };
3284f680cc6SAli Bahrami
3294f680cc6SAli Bahrami
3304f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
3314f680cc6SAli Bahrami static const const conv_ds_t *ds_cf[] = {
3324f680cc6SAli Bahrami CONV_DS_ADDR(ds_mach_0_11_cf), CONV_DS_ADDR(ds_mach_15_22_cf),
3334f680cc6SAli Bahrami CONV_DS_ADDR(ds_mach_36_63_cf), CONV_DS_ADDR(ds_mach_66_94_cf),
3344f680cc6SAli Bahrami NULL
3354f680cc6SAli Bahrami };
3364f680cc6SAli Bahrami static const const conv_ds_t *ds_nf[] = {
3374f680cc6SAli Bahrami CONV_DS_ADDR(ds_mach_0_11_nf), CONV_DS_ADDR(ds_mach_15_22_nf),
3384f680cc6SAli Bahrami CONV_DS_ADDR(ds_mach_36_63_nf), CONV_DS_ADDR(ds_mach_66_94_nf),
3394f680cc6SAli Bahrami NULL
3404f680cc6SAli Bahrami };
3414f680cc6SAli Bahrami static const const conv_ds_t *ds_dmp[] = {
3424f680cc6SAli Bahrami CONV_DS_ADDR(ds_mach_0_11_dmp), CONV_DS_ADDR(ds_mach_15_22_dmp),
3434f680cc6SAli Bahrami CONV_DS_ADDR(ds_mach_36_63_dmp),
3444f680cc6SAli Bahrami CONV_DS_ADDR(ds_mach_66_94_dmp), NULL
3454f680cc6SAli Bahrami };
3464f680cc6SAli Bahrami
3474f680cc6SAli Bahrami
3484f680cc6SAli Bahrami /* Select the strings to use */
3494f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
3504f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
3514f680cc6SAli Bahrami case CONV_FMT_ALT_FILE:
3524f680cc6SAli Bahrami return (ds_dmp);
3534f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
3544f680cc6SAli Bahrami return (ds_nf);
3554f680cc6SAli Bahrami }
3564f680cc6SAli Bahrami
3574f680cc6SAli Bahrami return (ds_cf);
3584f680cc6SAli Bahrami }
3595aefb655Srie
3605aefb655Srie const char *
conv_ehdr_mach(Half machine,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)361d29b2c44Sab196087 conv_ehdr_mach(Half machine, Conv_fmt_flags_t fmt_flags,
362d29b2c44Sab196087 Conv_inv_buf_t *inv_buf)
3635aefb655Srie {
3644f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, EM_NONE, machine,
3654f680cc6SAli Bahrami ehdr_mach_strings(fmt_flags), fmt_flags, inv_buf));
3664f680cc6SAli Bahrami }
3674f680cc6SAli Bahrami
3684f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_mach(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)3694f680cc6SAli Bahrami conv_iter_ehdr_mach(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
3704f680cc6SAli Bahrami void *uvalue)
3714f680cc6SAli Bahrami {
3724f680cc6SAli Bahrami static const Val_desc extra_dmp_nf[] = {
3734f680cc6SAli Bahrami { EM_M32, MSG_EM_M32_DMP},
3744f680cc6SAli Bahrami { EM_386, MSG_EM_386_DMP },
3754f680cc6SAli Bahrami { EM_68K, MSG_EM_68K_DMP },
3764f680cc6SAli Bahrami { EM_88K, MSG_EM_88K_DMP },
3774f680cc6SAli Bahrami { EM_486, MSG_EM_486_DMP },
3784f680cc6SAli Bahrami { EM_860, MSG_EM_860_DMP },
3794f680cc6SAli Bahrami { EM_MIPS, MSG_EM_MIPS_DMP },
3804f680cc6SAli Bahrami { EM_MIPS_RS3_LE, MSG_EM_MIPS_RS3_LE_DMP },
3814f680cc6SAli Bahrami { EM_PPC, MSG_EM_PPC_DMP },
3824f680cc6SAli Bahrami { EM_PPC64, MSG_EM_PPC64_DMP },
3834f680cc6SAli Bahrami
3844f680cc6SAli Bahrami { 0 }
3854f680cc6SAli Bahrami };
3864f680cc6SAli Bahrami
3874f680cc6SAli Bahrami if (conv_iter_ds(ELFOSABI_NONE, EM_NONE,
3884f680cc6SAli Bahrami ehdr_mach_strings(fmt_flags), func, uvalue) == CONV_ITER_DONE)
3894f680cc6SAli Bahrami return (CONV_ITER_DONE);
3904f680cc6SAli Bahrami
3914f680cc6SAli Bahrami /*
3924f680cc6SAli Bahrami * For the NF style, we also supply a few of the traditional
3934f680cc6SAli Bahrami * dump versions for iteration, but not for display.
3944f680cc6SAli Bahrami */
3954f680cc6SAli Bahrami if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF)
3964f680cc6SAli Bahrami return (conv_iter_vd(extra_dmp_nf, func, uvalue));
3974f680cc6SAli Bahrami
3984f680cc6SAli Bahrami return (CONV_ITER_CONT);
3994f680cc6SAli Bahrami }
4004f680cc6SAli Bahrami
4014f680cc6SAli Bahrami
4024f680cc6SAli Bahrami
4034f680cc6SAli Bahrami static const conv_ds_t **
ehdr_eident_strings(Conv_fmt_flags_t fmt_flags)4044f680cc6SAli Bahrami ehdr_eident_strings(Conv_fmt_flags_t fmt_flags)
4054f680cc6SAli Bahrami {
4064f680cc6SAli Bahrami static const Msg eident_cf[] = {
4074f680cc6SAli Bahrami MSG_EI_MAG0_CF, MSG_EI_MAG1_CF,
4084f680cc6SAli Bahrami MSG_EI_MAG2_CF, MSG_EI_MAG3_CF,
4094f680cc6SAli Bahrami MSG_EI_CLASS_CF, MSG_EI_DATA_CF,
4104f680cc6SAli Bahrami MSG_EI_VERSION_CF, MSG_EI_OSABI_CF,
4114f680cc6SAli Bahrami MSG_EI_ABIVERSION_CF
4124f680cc6SAli Bahrami };
4134f680cc6SAli Bahrami static const Msg eident_nf[] = {
4144f680cc6SAli Bahrami MSG_EI_MAG0_NF, MSG_EI_MAG1_NF,
4154f680cc6SAli Bahrami MSG_EI_MAG2_NF, MSG_EI_MAG3_NF,
4164f680cc6SAli Bahrami MSG_EI_CLASS_NF, MSG_EI_DATA_NF,
4174f680cc6SAli Bahrami MSG_EI_VERSION_NF, MSG_EI_OSABI_NF,
4184f680cc6SAli Bahrami MSG_EI_ABIVERSION_NF
4194f680cc6SAli Bahrami };
4204f680cc6SAli Bahrami #if EI_PAD != (EI_ABIVERSION + 1)
4214f680cc6SAli Bahrami error "EI_PAD has grown. Update etypes[]"
4224f680cc6SAli Bahrami #endif
4234f680cc6SAli Bahrami static const conv_ds_msg_t ds_eident_cf = {
4244f680cc6SAli Bahrami CONV_DS_MSG_INIT(EI_MAG0, eident_cf) };
4254f680cc6SAli Bahrami static const conv_ds_msg_t ds_eident_nf = {
4264f680cc6SAli Bahrami CONV_DS_MSG_INIT(EI_MAG0, eident_nf) };
4274f680cc6SAli Bahrami
4284f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
4294f680cc6SAli Bahrami static const const conv_ds_t *ds_cf[] = {
4304f680cc6SAli Bahrami CONV_DS_ADDR(ds_eident_cf), NULL };
4314f680cc6SAli Bahrami static const conv_ds_t *ds_nf[] = {
4324f680cc6SAli Bahrami CONV_DS_ADDR(ds_eident_nf), NULL };
4334f680cc6SAli Bahrami
4344f680cc6SAli Bahrami /* Select the strings to use */
4354f680cc6SAli Bahrami return ((CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_CF) ?
4364f680cc6SAli Bahrami ds_cf : ds_nf);
4374f680cc6SAli Bahrami }
4384f680cc6SAli Bahrami
4394f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_eident(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)4404f680cc6SAli Bahrami conv_iter_ehdr_eident(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
4414f680cc6SAli Bahrami void *uvalue)
4424f680cc6SAli Bahrami {
4434f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, EM_NONE,
4444f680cc6SAli Bahrami ehdr_eident_strings(fmt_flags), func, uvalue));
4454f680cc6SAli Bahrami }
4464f680cc6SAli Bahrami
4474f680cc6SAli Bahrami static const conv_ds_t **
ehdr_type_strings(Conv_fmt_flags_t fmt_flags)4484f680cc6SAli Bahrami ehdr_type_strings(Conv_fmt_flags_t fmt_flags)
4494f680cc6SAli Bahrami {
4504f680cc6SAli Bahrami #define SOL ELFOSABI_SOLARIS, EM_NONE
4514f680cc6SAli Bahrami
4524f680cc6SAli Bahrami static const Msg type_cf[] = {
4534f680cc6SAli Bahrami MSG_ET_NONE_CF, MSG_ET_REL_CF, MSG_ET_EXEC_CF,
4544f680cc6SAli Bahrami MSG_ET_DYN_CF, MSG_ET_CORE_CF
4554f680cc6SAli Bahrami };
4564f680cc6SAli Bahrami static const Msg type_nf[] = {
4574f680cc6SAli Bahrami MSG_ET_NONE_NF, MSG_ET_REL_NF, MSG_ET_EXEC_NF,
4584f680cc6SAli Bahrami MSG_ET_DYN_NF, MSG_ET_CORE_NF
4594f680cc6SAli Bahrami };
4604f680cc6SAli Bahrami static const Msg type_dmp[] = {
4614f680cc6SAli Bahrami MSG_ET_NONE_DMP, MSG_ET_REL_DMP, MSG_ET_EXEC_DMP,
4624f680cc6SAli Bahrami MSG_ET_DYN_DMP, MSG_ET_CORE_DMP
4634f680cc6SAli Bahrami };
4644f680cc6SAli Bahrami #if ET_NUM != (ET_CORE + 1)
4654f680cc6SAli Bahrami error "ET_NUM has grown. Update types[]"
4664f680cc6SAli Bahrami #endif
4674f680cc6SAli Bahrami static const conv_ds_msg_t ds_type_cf = {
4684f680cc6SAli Bahrami CONV_DS_MSG_INIT(ET_NONE, type_cf) };
4694f680cc6SAli Bahrami static const conv_ds_msg_t ds_type_nf = {
4704f680cc6SAli Bahrami CONV_DS_MSG_INIT(ET_NONE, type_nf) };
4714f680cc6SAli Bahrami static const conv_ds_msg_t ds_type_dmp = {
4724f680cc6SAli Bahrami CONV_DS_MSG_INIT(ET_NONE, type_dmp) };
4734f680cc6SAli Bahrami
4744f680cc6SAli Bahrami static const Val_desc2 type_osabi_cf[] = {
4754f680cc6SAli Bahrami { ET_SUNWPSEUDO, SOL, MSG_ET_SUNWPSEUDO_CF },
4764f680cc6SAli Bahrami { 0 }
4774f680cc6SAli Bahrami };
4784f680cc6SAli Bahrami static const Val_desc2 type_osabi_nf[] = {
4794f680cc6SAli Bahrami { ET_SUNWPSEUDO, SOL, MSG_ET_SUNWPSEUDO_NF },
4804f680cc6SAli Bahrami { 0 }
4814f680cc6SAli Bahrami };
4824f680cc6SAli Bahrami static const Val_desc2 type_osabi_dmp[] = {
4834f680cc6SAli Bahrami { ET_SUNWPSEUDO, SOL, MSG_ET_SUNWPSEUDO_DMP },
4844f680cc6SAli Bahrami { 0 }
4854f680cc6SAli Bahrami };
4864f680cc6SAli Bahrami #if ET_LOSUNW != ET_SUNWPSEUDO
4874f680cc6SAli Bahrami error "ET_LOSUNW has grown. Update type_osabi[]"
4884f680cc6SAli Bahrami #endif
4894f680cc6SAli Bahrami static const conv_ds_vd2_t ds_type_osabi_cf = {
4904f680cc6SAli Bahrami CONV_DS_VD2, ET_LOOS, ET_HIOS, type_osabi_cf };
4914f680cc6SAli Bahrami static const conv_ds_vd2_t ds_type_osabi_nf = {
4924f680cc6SAli Bahrami CONV_DS_VD2, ET_LOOS, ET_HIOS, type_osabi_nf };
4934f680cc6SAli Bahrami static const conv_ds_vd2_t ds_type_osabi_dmp = {
4944f680cc6SAli Bahrami CONV_DS_VD2, ET_LOOS, ET_HIOS, type_osabi_dmp };
4954f680cc6SAli Bahrami
4964f680cc6SAli Bahrami
4974f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
4984f680cc6SAli Bahrami static const const conv_ds_t *ds_cf[] = {
4994f680cc6SAli Bahrami CONV_DS_ADDR(ds_type_cf), CONV_DS_ADDR(ds_type_osabi_cf),
5004f680cc6SAli Bahrami NULL };
5014f680cc6SAli Bahrami static const conv_ds_t *ds_nf[] = {
5024f680cc6SAli Bahrami CONV_DS_ADDR(ds_type_nf), CONV_DS_ADDR(ds_type_osabi_nf),
5034f680cc6SAli Bahrami NULL };
5044f680cc6SAli Bahrami static const conv_ds_t *ds_dmp[] = {
5054f680cc6SAli Bahrami CONV_DS_ADDR(ds_type_dmp), CONV_DS_ADDR(ds_type_osabi_dmp),
5064f680cc6SAli Bahrami NULL };
5074f680cc6SAli Bahrami
5084f680cc6SAli Bahrami /* Select the strings to use */
509d29b2c44Sab196087 switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
510d29b2c44Sab196087 case CONV_FMT_ALT_DUMP:
5114f680cc6SAli Bahrami return (ds_dmp);
5124f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
5134f680cc6SAli Bahrami return (ds_nf);
514d29b2c44Sab196087 }
515d29b2c44Sab196087
5164f680cc6SAli Bahrami return (ds_cf);
5177c478bd9Sstevel@tonic-gate
5184f680cc6SAli Bahrami #undef SOL
5194f680cc6SAli Bahrami }
520c13de8f6Sab196087
5215aefb655Srie const char *
conv_ehdr_type(uchar_t osabi,Half etype,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)5224f680cc6SAli Bahrami conv_ehdr_type(uchar_t osabi, Half etype, Conv_fmt_flags_t fmt_flags,
5234f680cc6SAli Bahrami Conv_inv_buf_t *inv_buf)
5245aefb655Srie {
5254f680cc6SAli Bahrami return (conv_map_ds(osabi, EM_NONE, etype,
5264f680cc6SAli Bahrami ehdr_type_strings(fmt_flags), fmt_flags, inv_buf));
5274f680cc6SAli Bahrami }
5287c478bd9Sstevel@tonic-gate
5294f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_type(conv_iter_osabi_t osabi,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)5304f680cc6SAli Bahrami conv_iter_ehdr_type(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags,
5314f680cc6SAli Bahrami conv_iter_cb_t func, void *uvalue)
5324f680cc6SAli Bahrami {
5334f680cc6SAli Bahrami return (conv_iter_ds(osabi, EM_NONE,
5344f680cc6SAli Bahrami ehdr_type_strings(fmt_flags), func, uvalue));
5354f680cc6SAli Bahrami }
5364f680cc6SAli Bahrami
5374f680cc6SAli Bahrami static const conv_ds_t **
ehdr_vers_strings(Conv_fmt_flags_t fmt_flags)5384f680cc6SAli Bahrami ehdr_vers_strings(Conv_fmt_flags_t fmt_flags)
5394f680cc6SAli Bahrami {
5404f680cc6SAli Bahrami static const Msg versions_cf[] = {
5414f680cc6SAli Bahrami MSG_EV_NONE_CF, MSG_EV_CURRENT_CF
5424f680cc6SAli Bahrami };
5434f680cc6SAli Bahrami static const Msg versions_nf[] = {
5444f680cc6SAli Bahrami MSG_EV_NONE_NF, MSG_EV_CURRENT_NF
5454f680cc6SAli Bahrami };
5464f680cc6SAli Bahrami static const Msg versions_dmp[] = {
5474f680cc6SAli Bahrami MSG_EV_NONE_DMP, MSG_EV_CURRENT_DMP
5484f680cc6SAli Bahrami };
5494f680cc6SAli Bahrami #if EV_NUM != 2
5504f680cc6SAli Bahrami error "EV_NUM has grown. Update versions[]"
5514f680cc6SAli Bahrami #endif
5524f680cc6SAli Bahrami static const conv_ds_msg_t ds_versions_cf = {
5534f680cc6SAli Bahrami CONV_DS_MSG_INIT(EV_NONE, versions_cf) };
5544f680cc6SAli Bahrami static const conv_ds_msg_t ds_versions_nf = {
5554f680cc6SAli Bahrami CONV_DS_MSG_INIT(EV_NONE, versions_nf) };
5564f680cc6SAli Bahrami static const conv_ds_msg_t ds_versions_dmp = {
5574f680cc6SAli Bahrami CONV_DS_MSG_INIT(EV_NONE, versions_dmp) };
5584f680cc6SAli Bahrami
5594f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
5604f680cc6SAli Bahrami static const const conv_ds_t *ds_cf[] = {
5614f680cc6SAli Bahrami CONV_DS_ADDR(ds_versions_cf), NULL };
5624f680cc6SAli Bahrami static const conv_ds_t *ds_nf[] = {
5634f680cc6SAli Bahrami CONV_DS_ADDR(ds_versions_nf), NULL };
5644f680cc6SAli Bahrami static const conv_ds_t *ds_dmp[] = {
5654f680cc6SAli Bahrami CONV_DS_ADDR(ds_versions_dmp), NULL };
5664f680cc6SAli Bahrami
5674f680cc6SAli Bahrami /* Select the strings to use */
568d29b2c44Sab196087 switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
569d29b2c44Sab196087 case CONV_FMT_ALT_DUMP:
5704f680cc6SAli Bahrami return (ds_dmp);
5714f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
5724f680cc6SAli Bahrami return (ds_nf);
573c13de8f6Sab196087 }
574c13de8f6Sab196087
5754f680cc6SAli Bahrami return (ds_cf);
5767c478bd9Sstevel@tonic-gate }
5777c478bd9Sstevel@tonic-gate
5785aefb655Srie const char *
conv_ehdr_vers(Word version,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)579d29b2c44Sab196087 conv_ehdr_vers(Word version, Conv_fmt_flags_t fmt_flags,
580d29b2c44Sab196087 Conv_inv_buf_t *inv_buf)
5815aefb655Srie {
5824f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, EM_NONE, version,
5834f680cc6SAli Bahrami ehdr_vers_strings(fmt_flags), fmt_flags, inv_buf));
584d29b2c44Sab196087 }
585d29b2c44Sab196087
5864f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_vers(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)5874f680cc6SAli Bahrami conv_iter_ehdr_vers(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
5884f680cc6SAli Bahrami void *uvalue)
5894f680cc6SAli Bahrami {
5904f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, EM_NONE,
5914f680cc6SAli Bahrami ehdr_vers_strings(fmt_flags), func, uvalue));
5927c478bd9Sstevel@tonic-gate }
5937c478bd9Sstevel@tonic-gate
5944f680cc6SAli Bahrami static void
conv_ehdr_sparc_flags_strings(Conv_fmt_flags_t fmt_flags,const conv_ds_msg_t ** mm_msg,const Val_desc ** flag_desc)5954f680cc6SAli Bahrami conv_ehdr_sparc_flags_strings(Conv_fmt_flags_t fmt_flags,
5964f680cc6SAli Bahrami const conv_ds_msg_t **mm_msg, const Val_desc **flag_desc)
5974f680cc6SAli Bahrami {
598ba4e3c84Sab196087 #define EFLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
5994f680cc6SAli Bahrami MSG_EF_SPARCV9_TSO_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
6004f680cc6SAli Bahrami MSG_EF_SPARC_SUN_US1_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
6014f680cc6SAli Bahrami MSG_EF_SPARC_HAL_R1_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
6024f680cc6SAli Bahrami MSG_EF_SPARC_SUN_US3_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
603de777a60Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
604de777a60Sab196087
605de777a60Sab196087 /*
606de777a60Sab196087 * Ensure that Conv_ehdr_flags_buf_t is large enough:
607de777a60Sab196087 *
6084f680cc6SAli Bahrami * EFLAGSZ is the real minimum size of the buffer required by
6094f680cc6SAli Bahrami * conv_ehdr_flags(). However, Conv_ehdr_flags_buf_t uses
6104f680cc6SAli Bahrami * CONV_EHDR_FLAG_BUFSIZE to set the buffer size. We do things
6114f680cc6SAli Bahrami * this way because the definition of EFLAGSZ uses information
6124f680cc6SAli Bahrami * that is not available in the environment of other programs
613de777a60Sab196087 * that include the conv.h header file.
614de777a60Sab196087 */
6156a074c93Sab196087 #if (CONV_EHDR_FLAGS_BUFSIZE != EFLAGSZ) && !defined(__lint)
6166a074c93Sab196087 #define REPORT_BUFSIZE EFLAGSZ
6176a074c93Sab196087 #include "report_bufsize.h"
6186a074c93Sab196087 #error "CONV_EHDR_FLAGS_BUFSIZE does not match EFLAGSZ"
619de777a60Sab196087 #endif
6207c478bd9Sstevel@tonic-gate
6214f680cc6SAli Bahrami static const Msg mm_flags_cf[] = {
6224f680cc6SAli Bahrami MSG_EF_SPARCV9_TSO_CF, MSG_EF_SPARCV9_PSO_CF,
6234f680cc6SAli Bahrami MSG_EF_SPARCV9_RMO_CF
6244f680cc6SAli Bahrami };
6254f680cc6SAli Bahrami static const Msg mm_flags_nf[] = {
6264f680cc6SAli Bahrami MSG_EF_SPARCV9_TSO_NF, MSG_EF_SPARCV9_PSO_NF,
6274f680cc6SAli Bahrami MSG_EF_SPARCV9_RMO_NF
6284f680cc6SAli Bahrami };
6294f680cc6SAli Bahrami static const conv_ds_msg_t ds_mm_flags_cf = {
6304f680cc6SAli Bahrami CONV_DS_MSG_INIT(EF_SPARCV9_TSO, mm_flags_cf) };
6314f680cc6SAli Bahrami static const conv_ds_msg_t ds_mm_flags_nf = {
6324f680cc6SAli Bahrami CONV_DS_MSG_INIT(EF_SPARCV9_TSO, mm_flags_nf) };
6334f680cc6SAli Bahrami
6344f680cc6SAli Bahrami
6354f680cc6SAli Bahrami static const Val_desc vda_cf[] = {
6364f680cc6SAli Bahrami { EF_SPARC_32PLUS, MSG_EF_SPARC_32PLUS_CF },
6374f680cc6SAli Bahrami { EF_SPARC_SUN_US1, MSG_EF_SPARC_SUN_US1_CF },
6384f680cc6SAli Bahrami { EF_SPARC_HAL_R1, MSG_EF_SPARC_HAL_R1_CF },
6394f680cc6SAli Bahrami { EF_SPARC_SUN_US3, MSG_EF_SPARC_SUN_US3_CF },
6404f680cc6SAli Bahrami { 0 }
6414f680cc6SAli Bahrami };
6424f680cc6SAli Bahrami static const Val_desc vda_nf[] = {
6434f680cc6SAli Bahrami { EF_SPARC_32PLUS, MSG_EF_SPARC_32PLUS_NF },
6444f680cc6SAli Bahrami { EF_SPARC_SUN_US1, MSG_EF_SPARC_SUN_US1_NF },
6454f680cc6SAli Bahrami { EF_SPARC_HAL_R1, MSG_EF_SPARC_HAL_R1_NF },
6464f680cc6SAli Bahrami { EF_SPARC_SUN_US3, MSG_EF_SPARC_SUN_US3_NF },
6474f680cc6SAli Bahrami { 0 }
6484f680cc6SAli Bahrami };
6494f680cc6SAli Bahrami
6504f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
6514f680cc6SAli Bahrami default:
6524f680cc6SAli Bahrami *mm_msg = &ds_mm_flags_cf;
6534f680cc6SAli Bahrami *flag_desc = vda_cf;
6544f680cc6SAli Bahrami break;
6554f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
6564f680cc6SAli Bahrami *mm_msg = &ds_mm_flags_nf;
6574f680cc6SAli Bahrami *flag_desc = vda_nf;
6584f680cc6SAli Bahrami break;
6594f680cc6SAli Bahrami }
6604f680cc6SAli Bahrami }
6614f680cc6SAli Bahrami
6627c478bd9Sstevel@tonic-gate /*
6635aefb655Srie * Make a string representation of the e_flags field.
6647c478bd9Sstevel@tonic-gate */
6657c478bd9Sstevel@tonic-gate const char *
conv_ehdr_flags(Half mach,Word flags,Conv_fmt_flags_t fmt_flags,Conv_ehdr_flags_buf_t * flags_buf)666d29b2c44Sab196087 conv_ehdr_flags(Half mach, Word flags, Conv_fmt_flags_t fmt_flags,
667d29b2c44Sab196087 Conv_ehdr_flags_buf_t *flags_buf)
6687c478bd9Sstevel@tonic-gate {
669ba4e3c84Sab196087 static const char *leading_str_arr[2];
670de777a60Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = {
6714f680cc6SAli Bahrami NULL, sizeof (flags_buf->buf), leading_str_arr };
672ba4e3c84Sab196087
6734f680cc6SAli Bahrami const char **lstr;
6744f680cc6SAli Bahrami const conv_ds_msg_t *mm_msg;
6754f680cc6SAli Bahrami const Val_desc *vdp;
6764f680cc6SAli Bahrami Word mm;
677de777a60Sab196087
6787c478bd9Sstevel@tonic-gate /*
6795aefb655Srie * Non-SPARC architectures presently provide no known flags.
6807c478bd9Sstevel@tonic-gate */
6814f680cc6SAli Bahrami if ((mach != EM_SPARCV9) && (((mach != EM_SPARC) &&
6824f680cc6SAli Bahrami (mach != EM_SPARC32PLUS)) || (flags == 0)))
6834f680cc6SAli Bahrami return (conv_invalid_val(&flags_buf->inv_buf, flags,
6844f680cc6SAli Bahrami CONV_FMT_DECIMAL));
6857c478bd9Sstevel@tonic-gate
6864f680cc6SAli Bahrami conv_arg.buf = flags_buf->buf;
6874f680cc6SAli Bahrami conv_ehdr_sparc_flags_strings(fmt_flags, &mm_msg, &vdp);
688ba4e3c84Sab196087 conv_arg.oflags = conv_arg.rflags = flags;
6894f680cc6SAli Bahrami
6904f680cc6SAli Bahrami mm = flags & EF_SPARCV9_MM;
6914f680cc6SAli Bahrami lstr = leading_str_arr;
6924f680cc6SAli Bahrami if ((mach == EM_SPARCV9) && (mm <= mm_msg->ds_topval)) {
6934f680cc6SAli Bahrami *lstr++ = MSG_ORIG(mm_msg->ds_msg[mm]);
694ba4e3c84Sab196087 conv_arg.rflags &= ~EF_SPARCV9_MM;
6957c478bd9Sstevel@tonic-gate }
696ba4e3c84Sab196087 *lstr = NULL;
6977c478bd9Sstevel@tonic-gate
6984f680cc6SAli Bahrami (void) conv_expn_field(&conv_arg, vdp, fmt_flags);
6997c478bd9Sstevel@tonic-gate
700de777a60Sab196087 return (conv_arg.buf);
7017c478bd9Sstevel@tonic-gate }
702de777a60Sab196087
7034f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_flags(Half mach,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)7044f680cc6SAli Bahrami conv_iter_ehdr_flags(Half mach, Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
7054f680cc6SAli Bahrami void *uvalue)
7064f680cc6SAli Bahrami {
7074f680cc6SAli Bahrami
7084f680cc6SAli Bahrami if ((mach == EM_SPARCV9) || (mach == EM_SPARC) ||
7094f680cc6SAli Bahrami (mach == EM_SPARC32PLUS) || (mach == CONV_MACH_ALL)) {
7104f680cc6SAli Bahrami const conv_ds_msg_t *ds_msg_mm;
7114f680cc6SAli Bahrami const Val_desc *vdp;
7124f680cc6SAli Bahrami
7134f680cc6SAli Bahrami conv_ehdr_sparc_flags_strings(fmt_flags, &ds_msg_mm, &vdp);
7144f680cc6SAli Bahrami
7154f680cc6SAli Bahrami if (mach == EM_SPARCV9) {
7164f680cc6SAli Bahrami const conv_ds_t *ds[2];
7174f680cc6SAli Bahrami
7184f680cc6SAli Bahrami ds[0] = CONV_DS_ADDR(ds_msg_mm);
7194f680cc6SAli Bahrami ds[1] = NULL;
7204f680cc6SAli Bahrami
7214f680cc6SAli Bahrami if (conv_iter_ds(ELFOSABI_NONE, mach, ds,
7224f680cc6SAli Bahrami func, uvalue) == CONV_ITER_DONE)
7234f680cc6SAli Bahrami return (CONV_ITER_DONE);
7244f680cc6SAli Bahrami }
7254f680cc6SAli Bahrami
7264f680cc6SAli Bahrami return (conv_iter_vd(vdp, func, uvalue));
7274f680cc6SAli Bahrami }
7284f680cc6SAli Bahrami
7294f680cc6SAli Bahrami return (CONV_ITER_CONT);
7304f680cc6SAli Bahrami }
7314f680cc6SAli Bahrami
7324f680cc6SAli Bahrami static const conv_ds_t **
ehdr_osabi_strings(Conv_fmt_flags_t fmt_flags)7334f680cc6SAli Bahrami ehdr_osabi_strings(Conv_fmt_flags_t fmt_flags)
7344f680cc6SAli Bahrami {
7354f680cc6SAli Bahrami
7364f680cc6SAli Bahrami static const Msg osabi_0_3_cf[] = {
7374f680cc6SAli Bahrami MSG_OSABI_NONE_CF, MSG_OSABI_HPUX_CF,
7384f680cc6SAli Bahrami MSG_OSABI_NETBSD_CF, MSG_OSABI_LINUX_CF
7394f680cc6SAli Bahrami };
7404f680cc6SAli Bahrami static const Msg osabi_0_3_nf[] = {
7414f680cc6SAli Bahrami MSG_OSABI_NONE_NF, MSG_OSABI_HPUX_NF,
7424f680cc6SAli Bahrami MSG_OSABI_NETBSD_NF, MSG_OSABI_LINUX_NF
7434f680cc6SAli Bahrami };
7444f680cc6SAli Bahrami static const Msg osabi_0_3_dmp[] = {
7454f680cc6SAli Bahrami MSG_OSABI_NONE_DMP, MSG_OSABI_HPUX_DMP,
7464f680cc6SAli Bahrami MSG_OSABI_NETBSD_DMP, MSG_OSABI_LINUX_DMP
7474f680cc6SAli Bahrami };
7484f680cc6SAli Bahrami static const conv_ds_msg_t ds_osabi_0_3_cf = {
7494f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFOSABI_NONE, osabi_0_3_cf) };
7504f680cc6SAli Bahrami static const conv_ds_msg_t ds_osabi_0_3_nf = {
7514f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFOSABI_NONE, osabi_0_3_nf) };
7524f680cc6SAli Bahrami static const conv_ds_msg_t ds_osabi_0_3_dmp = {
7534f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFOSABI_NONE, osabi_0_3_dmp) };
7544f680cc6SAli Bahrami
7554f680cc6SAli Bahrami
7564f680cc6SAli Bahrami static const Msg osabi_6_15_cf[] = {
7574f680cc6SAli Bahrami MSG_OSABI_SOLARIS_CF, MSG_OSABI_AIX_CF,
7584f680cc6SAli Bahrami MSG_OSABI_IRIX_CF, MSG_OSABI_FREEBSD_CF,
7594f680cc6SAli Bahrami MSG_OSABI_TRU64_CF, MSG_OSABI_MODESTO_CF,
7604f680cc6SAli Bahrami MSG_OSABI_OPENBSD_CF, MSG_OSABI_OPENVMS_CF,
7614f680cc6SAli Bahrami MSG_OSABI_NSK_CF, MSG_OSABI_AROS_CF
7624f680cc6SAli Bahrami };
7634f680cc6SAli Bahrami static const Msg osabi_6_15_nf[] = {
7644f680cc6SAli Bahrami MSG_OSABI_SOLARIS_NF, MSG_OSABI_AIX_NF,
7654f680cc6SAli Bahrami MSG_OSABI_IRIX_NF, MSG_OSABI_FREEBSD_NF,
7664f680cc6SAli Bahrami MSG_OSABI_TRU64_NF, MSG_OSABI_MODESTO_NF,
7674f680cc6SAli Bahrami MSG_OSABI_OPENBSD_NF, MSG_OSABI_OPENVMS_NF,
7684f680cc6SAli Bahrami MSG_OSABI_NSK_NF, MSG_OSABI_AROS_NF
7694f680cc6SAli Bahrami };
7704f680cc6SAli Bahrami static const Msg osabi_6_15_dmp[] = {
7714f680cc6SAli Bahrami MSG_OSABI_SOLARIS_DMP, MSG_OSABI_AIX_DMP,
7724f680cc6SAli Bahrami MSG_OSABI_IRIX_DMP, MSG_OSABI_FREEBSD_DMP,
7734f680cc6SAli Bahrami MSG_OSABI_TRU64_DMP, MSG_OSABI_MODESTO_DMP,
7744f680cc6SAli Bahrami MSG_OSABI_OPENBSD_DMP, MSG_OSABI_OPENVMS_DMP,
7754f680cc6SAli Bahrami MSG_OSABI_NSK_DMP, MSG_OSABI_AROS_DMP
7764f680cc6SAli Bahrami };
7774f680cc6SAli Bahrami static const conv_ds_msg_t ds_osabi_6_15_cf = {
7784f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFOSABI_SOLARIS, osabi_6_15_cf) };
7794f680cc6SAli Bahrami static const conv_ds_msg_t ds_osabi_6_15_nf = {
7804f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFOSABI_SOLARIS, osabi_6_15_nf) };
7814f680cc6SAli Bahrami static const conv_ds_msg_t ds_osabi_6_15_dmp = {
7824f680cc6SAli Bahrami CONV_DS_MSG_INIT(ELFOSABI_SOLARIS, osabi_6_15_dmp) };
7834f680cc6SAli Bahrami
7844f680cc6SAli Bahrami
7854f680cc6SAli Bahrami static const Val_desc osabi_misc_cf[] = {
7864f680cc6SAli Bahrami { ELFOSABI_ARM, MSG_OSABI_ARM_CF },
7874f680cc6SAli Bahrami { ELFOSABI_STANDALONE, MSG_OSABI_STANDALONE_CF },
7884f680cc6SAli Bahrami { 0 }
7894f680cc6SAli Bahrami };
7904f680cc6SAli Bahrami static const Val_desc osabi_misc_nf[] = {
7914f680cc6SAli Bahrami { ELFOSABI_ARM, MSG_OSABI_ARM_NF },
7924f680cc6SAli Bahrami { ELFOSABI_STANDALONE, MSG_OSABI_STANDALONE_NF },
7934f680cc6SAli Bahrami { 0 }
7944f680cc6SAli Bahrami };
7954f680cc6SAli Bahrami static const Val_desc osabi_misc_dmp[] = {
7964f680cc6SAli Bahrami { ELFOSABI_ARM, MSG_OSABI_ARM_DMP },
7974f680cc6SAli Bahrami { ELFOSABI_STANDALONE, MSG_OSABI_STANDALONE_DMP },
7984f680cc6SAli Bahrami { 0 }
7994f680cc6SAli Bahrami };
8004f680cc6SAli Bahrami static const conv_ds_vd_t ds_osabi_misc_cf = {
8014f680cc6SAli Bahrami CONV_DS_VD, ELFOSABI_ARM, ELFOSABI_STANDALONE, osabi_misc_cf };
8024f680cc6SAli Bahrami static const conv_ds_vd_t ds_osabi_misc_nf = {
8034f680cc6SAli Bahrami CONV_DS_VD, ELFOSABI_ARM, ELFOSABI_STANDALONE, osabi_misc_nf };
8044f680cc6SAli Bahrami static const conv_ds_vd_t ds_osabi_misc_dmp = {
8054f680cc6SAli Bahrami CONV_DS_VD, ELFOSABI_ARM, ELFOSABI_STANDALONE, osabi_misc_dmp };
8064f680cc6SAli Bahrami
8074f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
8084f680cc6SAli Bahrami static const const conv_ds_t *ds_cf[] = {
8094f680cc6SAli Bahrami CONV_DS_ADDR(ds_osabi_0_3_cf), CONV_DS_ADDR(ds_osabi_6_15_cf),
8104f680cc6SAli Bahrami CONV_DS_ADDR(ds_osabi_misc_cf), NULL };
8114f680cc6SAli Bahrami static const const conv_ds_t *ds_nf[] = {
8124f680cc6SAli Bahrami CONV_DS_ADDR(ds_osabi_0_3_nf), CONV_DS_ADDR(ds_osabi_6_15_nf),
8134f680cc6SAli Bahrami CONV_DS_ADDR(ds_osabi_misc_nf), NULL };
8144f680cc6SAli Bahrami static const const conv_ds_t *ds_dmp[] = {
8154f680cc6SAli Bahrami CONV_DS_ADDR(ds_osabi_0_3_dmp), CONV_DS_ADDR(ds_osabi_6_15_dmp),
8164f680cc6SAli Bahrami CONV_DS_ADDR(ds_osabi_misc_dmp), NULL };
8174f680cc6SAli Bahrami
8184f680cc6SAli Bahrami /* Select the strings to use */
8194f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
8204f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
8214f680cc6SAli Bahrami return (ds_dmp);
8224f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
8234f680cc6SAli Bahrami return (ds_nf);
8244f680cc6SAli Bahrami }
8254f680cc6SAli Bahrami
8264f680cc6SAli Bahrami return (ds_cf);
8275aefb655Srie }
8287c478bd9Sstevel@tonic-gate
8297c478bd9Sstevel@tonic-gate /*
8303244bcaaSab196087 * Make a string representation of the e_ident[EI_OSABI] field.
8313244bcaaSab196087 */
8323244bcaaSab196087 const char *
conv_ehdr_osabi(uchar_t osabi,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)833d29b2c44Sab196087 conv_ehdr_osabi(uchar_t osabi, Conv_fmt_flags_t fmt_flags,
834d29b2c44Sab196087 Conv_inv_buf_t *inv_buf)
8353244bcaaSab196087 {
8364f680cc6SAli Bahrami return (conv_map_ds(ELFOSABI_NONE, EM_NONE, osabi,
8374f680cc6SAli Bahrami ehdr_osabi_strings(fmt_flags), fmt_flags, inv_buf));
8384f680cc6SAli Bahrami }
8394f680cc6SAli Bahrami
8404f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_osabi(Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)8414f680cc6SAli Bahrami conv_iter_ehdr_osabi(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func,
8424f680cc6SAli Bahrami void *uvalue)
8434f680cc6SAli Bahrami {
8444f680cc6SAli Bahrami if (conv_iter_ds(ELFOSABI_NONE, EM_NONE, ehdr_osabi_strings(fmt_flags),
8454f680cc6SAli Bahrami func, uvalue) == CONV_ITER_DONE)
8464f680cc6SAli Bahrami return (CONV_ITER_DONE);
8474f680cc6SAli Bahrami
8484f680cc6SAli Bahrami /*
8494f680cc6SAli Bahrami * ELFOSABI_NONE might have been better named ELFOSABI_SYSV. For the
8504f680cc6SAli Bahrami * CF and NF sytles, we supply that name for 0 in addition to NONE.
8514f680cc6SAli Bahrami */
8524f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
8534f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
8544f680cc6SAli Bahrami return ((* func)(MSG_ORIG(MSG_OSABI_SYSV_CF),
8554f680cc6SAli Bahrami ELFOSABI_NONE, uvalue));
8564f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
8574f680cc6SAli Bahrami return ((* func)(MSG_ORIG(MSG_OSABI_SYSV_NF),
8584f680cc6SAli Bahrami ELFOSABI_NONE, uvalue));
8594f680cc6SAli Bahrami }
8604f680cc6SAli Bahrami
8614f680cc6SAli Bahrami return (CONV_ITER_CONT);
8624f680cc6SAli Bahrami }
8634f680cc6SAli Bahrami
8644f680cc6SAli Bahrami static const conv_ds_t **
ehdr_abivers_strings(conv_iter_osabi_t osabi,Conv_fmt_flags_t fmt_flags)8654f680cc6SAli Bahrami ehdr_abivers_strings(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags)
8664f680cc6SAli Bahrami {
8674f680cc6SAli Bahrami static const Msg abiversions_cf[] = {
8684f680cc6SAli Bahrami MSG_EAV_SUNW_NONE_CF, MSG_EAV_SUNW_CURRENT_CF
8693244bcaaSab196087 };
8704f680cc6SAli Bahrami static const Msg abiversions_nf[] = {
8714f680cc6SAli Bahrami MSG_EAV_SUNW_NONE_NF, MSG_EAV_SUNW_CURRENT_NF
8723244bcaaSab196087 };
8734f680cc6SAli Bahrami #if EAV_SUNW_NUM != 2
8744f680cc6SAli Bahrami error "EAV_SUNW_NUM has grown. Update abiversions[]"
8754f680cc6SAli Bahrami #endif
8764f680cc6SAli Bahrami static const conv_ds_msg_t ds_abiversions_cf = {
8774f680cc6SAli Bahrami CONV_DS_MSG_INIT(EV_NONE, abiversions_cf) };
8784f680cc6SAli Bahrami static const conv_ds_msg_t ds_abiversions_nf = {
8794f680cc6SAli Bahrami CONV_DS_MSG_INIT(EV_NONE, abiversions_nf) };
8803244bcaaSab196087
8814f680cc6SAli Bahrami /* Build NULL terminated return arrays for each string style */
8824f680cc6SAli Bahrami static const const conv_ds_t *ds_cf[] = {
8834f680cc6SAli Bahrami CONV_DS_ADDR(ds_abiversions_cf), NULL };
8844f680cc6SAli Bahrami static const conv_ds_t *ds_nf[] = {
8854f680cc6SAli Bahrami CONV_DS_ADDR(ds_abiversions_nf), NULL };
8863244bcaaSab196087
8874f680cc6SAli Bahrami /* For non-Solaris OSABI, we don't have symbolic names */
8884f680cc6SAli Bahrami static const conv_ds_t *ds_none[] = { NULL };
8893244bcaaSab196087
8903244bcaaSab196087
8914f680cc6SAli Bahrami /*
8924f680cc6SAli Bahrami * Select the strings to use. This is a rare case where
8934f680cc6SAli Bahrami * we don't treat ELFOSABI_NONE and ELFOSABI_SOLARIS
8944f680cc6SAli Bahrami * as the same thing. We should never create a Solaris
8954f680cc6SAli Bahrami * object tagged as ELFOSABI_NONE for which the abiversion
8964f680cc6SAli Bahrami * is non-zero.
8974f680cc6SAli Bahrami */
8984f680cc6SAli Bahrami if ((osabi == ELFOSABI_SOLARIS) || (osabi == CONV_OSABI_ALL))
8994f680cc6SAli Bahrami return ((CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF) ?
9004f680cc6SAli Bahrami ds_nf : ds_cf);
9014f680cc6SAli Bahrami
9024f680cc6SAli Bahrami return (ds_none);
9033244bcaaSab196087 }
9043244bcaaSab196087
9054f680cc6SAli Bahrami const char *
conv_ehdr_abivers(uchar_t osabi,Word version,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)9064f680cc6SAli Bahrami conv_ehdr_abivers(uchar_t osabi, Word version, Conv_fmt_flags_t fmt_flags,
9074f680cc6SAli Bahrami Conv_inv_buf_t *inv_buf)
9084f680cc6SAli Bahrami {
9094f680cc6SAli Bahrami return (conv_map_ds(osabi, EM_NONE, version,
9104f680cc6SAli Bahrami ehdr_abivers_strings(osabi, fmt_flags), fmt_flags, inv_buf));
9114f680cc6SAli Bahrami }
9124f680cc6SAli Bahrami
9134f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_ehdr_abivers(conv_iter_osabi_t osabi,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)9144f680cc6SAli Bahrami conv_iter_ehdr_abivers(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags,
9154f680cc6SAli Bahrami conv_iter_cb_t func, void *uvalue)
9164f680cc6SAli Bahrami {
9174f680cc6SAli Bahrami return (conv_iter_ds(osabi, EM_NONE,
9184f680cc6SAli Bahrami ehdr_abivers_strings(osabi, fmt_flags), func, uvalue));
9193244bcaaSab196087 }
9203244bcaaSab196087
9213244bcaaSab196087 /*
9227c478bd9Sstevel@tonic-gate * A generic means of returning additional information for a rejected file in
9234f680cc6SAli Bahrami * terms of a string. ELFOSABI_SOLARIS is assummed.
9247c478bd9Sstevel@tonic-gate */
9257c478bd9Sstevel@tonic-gate const char *
conv_reject_desc(Rej_desc * rej,Conv_reject_desc_buf_t * reject_desc_buf,Half mach)926ba2be530Sab196087 conv_reject_desc(Rej_desc * rej, Conv_reject_desc_buf_t *reject_desc_buf,
927ba2be530Sab196087 Half mach)
9287c478bd9Sstevel@tonic-gate {
9297c478bd9Sstevel@tonic-gate ushort_t type = rej->rej_type;
9307c478bd9Sstevel@tonic-gate uint_t info = rej->rej_info;
9317c478bd9Sstevel@tonic-gate
932bebb829dSRod Evans switch (type) {
933bebb829dSRod Evans case SGS_REJ_MACH:
934de777a60Sab196087 return (conv_ehdr_mach((Half)info, 0,
935de777a60Sab196087 &reject_desc_buf->inv_buf));
936bebb829dSRod Evans case SGS_REJ_CLASS:
937de777a60Sab196087 return (conv_ehdr_class((uchar_t)info, 0,
938de777a60Sab196087 &reject_desc_buf->inv_buf));
939bebb829dSRod Evans case SGS_REJ_DATA:
940de777a60Sab196087 return (conv_ehdr_data((uchar_t)info, 0,
941de777a60Sab196087 &reject_desc_buf->inv_buf));
942bebb829dSRod Evans case SGS_REJ_TYPE:
9434f680cc6SAli Bahrami return (conv_ehdr_type(ELFOSABI_SOLARIS, (Half)info, 0,
944de777a60Sab196087 &reject_desc_buf->inv_buf));
945bebb829dSRod Evans case SGS_REJ_BADFLAG:
946bebb829dSRod Evans case SGS_REJ_MISFLAG:
947bebb829dSRod Evans case SGS_REJ_HAL:
948bebb829dSRod Evans case SGS_REJ_US3:
949ba2be530Sab196087 return (conv_ehdr_flags(mach, (Word)info, 0,
950de777a60Sab196087 &reject_desc_buf->flags_buf));
951bebb829dSRod Evans case SGS_REJ_UNKFILE:
952*dc0f59e5SAli Bahrami case SGS_REJ_ARCHIVE:
953*dc0f59e5SAli Bahrami return (NULL);
954bebb829dSRod Evans case SGS_REJ_STR:
955bebb829dSRod Evans case SGS_REJ_HWCAP_1:
956bebb829dSRod Evans case SGS_REJ_SFCAP_1:
95708278a5eSRod Evans case SGS_REJ_HWCAP_2:
95808278a5eSRod Evans case SGS_REJ_MACHCAP:
95908278a5eSRod Evans case SGS_REJ_PLATCAP:
9607c478bd9Sstevel@tonic-gate if (rej->rej_str)
9617c478bd9Sstevel@tonic-gate return ((const char *)rej->rej_str);
9627c478bd9Sstevel@tonic-gate else
9637c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_STR_EMPTY));
964bebb829dSRod Evans default:
965de777a60Sab196087 return (conv_invalid_val(&reject_desc_buf->inv_buf, info,
966c13de8f6Sab196087 CONV_FMT_DECIMAL));
9677c478bd9Sstevel@tonic-gate }
968bebb829dSRod Evans }
969