10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51618Srie * Common Development and Distribution License (the "License"). 61618Srie * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211618Srie 220Sstevel@tonic-gate /* 23*9273SAli.Bahrami@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* 280Sstevel@tonic-gate * String conversion routines for ELF header attributes. 290Sstevel@tonic-gate */ 300Sstevel@tonic-gate #include <stdio.h> 310Sstevel@tonic-gate #include <string.h> 320Sstevel@tonic-gate #include "_conv.h" 330Sstevel@tonic-gate #include "elf_msg.h" 340Sstevel@tonic-gate #include <sys/elf_SPARC.h> 350Sstevel@tonic-gate 361976Sab196087 371976Sab196087 38*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 39*9273SAli.Bahrami@Sun.COM ehdr_class_strings(Conv_fmt_flags_t fmt_flags) 40*9273SAli.Bahrami@Sun.COM { 41*9273SAli.Bahrami@Sun.COM static const Msg class_cf[] = { 42*9273SAli.Bahrami@Sun.COM MSG_ELFCLASSNONE_CF, MSG_ELFCLASS32_CF, MSG_ELFCLASS64_CF 43*9273SAli.Bahrami@Sun.COM }; 44*9273SAli.Bahrami@Sun.COM static const Msg class_nf[] = { 45*9273SAli.Bahrami@Sun.COM MSG_ELFCLASSNONE_NF, MSG_ELFCLASS32_NF, MSG_ELFCLASS64_NF 46*9273SAli.Bahrami@Sun.COM }; 47*9273SAli.Bahrami@Sun.COM static const Msg class_dump[] = { 48*9273SAli.Bahrami@Sun.COM MSG_ELFCLASSNONE_DMP, MSG_ELFCLASS32_DMP, MSG_ELFCLASS64_DMP 49*9273SAli.Bahrami@Sun.COM }; 501976Sab196087 51*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_classes_cf = { 52*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFCLASSNONE, class_cf) }; 53*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_classes_nf = { 54*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFCLASSNONE, class_nf) }; 55*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_classes_dump = { 56*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFCLASSNONE, class_dump) }; 571976Sab196087 58*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_cf[] = { CONV_DS_ADDR(ds_classes_cf), NULL }; 59*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_nf[] = { CONV_DS_ADDR(ds_classes_nf), NULL }; 60*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_dump[] = { 61*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_classes_dump), NULL }; 62*9273SAli.Bahrami@Sun.COM 63*9273SAli.Bahrami@Sun.COM switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 64*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_DUMP: 65*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_FILE: 66*9273SAli.Bahrami@Sun.COM return (ds_dump); 67*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 68*9273SAli.Bahrami@Sun.COM return (ds_nf); 69*9273SAli.Bahrami@Sun.COM } 70*9273SAli.Bahrami@Sun.COM 71*9273SAli.Bahrami@Sun.COM return (ds_cf); 72*9273SAli.Bahrami@Sun.COM } 731976Sab196087 740Sstevel@tonic-gate const char * 755088Sab196087 conv_ehdr_class(uchar_t class, Conv_fmt_flags_t fmt_flags, 765088Sab196087 Conv_inv_buf_t *inv_buf) 770Sstevel@tonic-gate { 78*9273SAli.Bahrami@Sun.COM return (conv_map_ds(ELFOSABI_NONE, EM_NONE, class, 79*9273SAli.Bahrami@Sun.COM ehdr_class_strings(fmt_flags), fmt_flags, inv_buf)); 80*9273SAli.Bahrami@Sun.COM } 81*9273SAli.Bahrami@Sun.COM 82*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 83*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_class(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 84*9273SAli.Bahrami@Sun.COM void *uvalue) 85*9273SAli.Bahrami@Sun.COM { 86*9273SAli.Bahrami@Sun.COM return (conv_iter_ds(ELFOSABI_NONE, EM_NONE, 87*9273SAli.Bahrami@Sun.COM ehdr_class_strings(fmt_flags), func, uvalue)); 88*9273SAli.Bahrami@Sun.COM } 89*9273SAli.Bahrami@Sun.COM 90*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 91*9273SAli.Bahrami@Sun.COM ehdr_data_strings(Conv_fmt_flags_t fmt_flags) 92*9273SAli.Bahrami@Sun.COM { 93*9273SAli.Bahrami@Sun.COM static const Msg data_cf[] = { 94*9273SAli.Bahrami@Sun.COM MSG_ELFDATANONE_CF, MSG_ELFDATA2LSB_CF, MSG_ELFDATA2MSB_CF 951976Sab196087 }; 96*9273SAli.Bahrami@Sun.COM static const Msg data_nf[] = { 97*9273SAli.Bahrami@Sun.COM MSG_ELFDATANONE_NF, MSG_ELFDATA2LSB_NF, MSG_ELFDATA2MSB_NF 98*9273SAli.Bahrami@Sun.COM }; 99*9273SAli.Bahrami@Sun.COM static const Msg data_dump[] = { 100*9273SAli.Bahrami@Sun.COM MSG_ELFDATANONE_DMP, MSG_ELFDATA2LSB_DMP, MSG_ELFDATA2MSB_DMP 101*9273SAli.Bahrami@Sun.COM }; 102*9273SAli.Bahrami@Sun.COM static const Msg data_file[] = { 103*9273SAli.Bahrami@Sun.COM MSG_ELFDATANONE_DMP, MSG_ELFDATA2LSB_FIL, MSG_ELFDATA2MSB_FIL 1041618Srie }; 1050Sstevel@tonic-gate 106*9273SAli.Bahrami@Sun.COM 107*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_data_cf = { 108*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFCLASSNONE, data_cf) }; 109*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_data_nf = { 110*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFCLASSNONE, data_nf) }; 111*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_data_dump = { 112*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFCLASSNONE, data_dump) }; 113*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_data_file = { 114*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFCLASSNONE, data_file) }; 115*9273SAli.Bahrami@Sun.COM 116*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_cf[] = { CONV_DS_ADDR(ds_data_cf), NULL }; 117*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_nf[] = { CONV_DS_ADDR(ds_data_nf), NULL }; 118*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_dump[] = { CONV_DS_ADDR(ds_data_dump), 119*9273SAli.Bahrami@Sun.COM NULL }; 120*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_file[] = { CONV_DS_ADDR(ds_data_file), 121*9273SAli.Bahrami@Sun.COM NULL }; 122*9273SAli.Bahrami@Sun.COM 1235088Sab196087 switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 1245088Sab196087 case CONV_FMT_ALT_DUMP: 125*9273SAli.Bahrami@Sun.COM return (ds_dump); 1265088Sab196087 case CONV_FMT_ALT_FILE: 127*9273SAli.Bahrami@Sun.COM return (ds_file); 128*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 129*9273SAli.Bahrami@Sun.COM return (ds_nf); 1305088Sab196087 } 1315088Sab196087 132*9273SAli.Bahrami@Sun.COM return (ds_cf); 1330Sstevel@tonic-gate } 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate const char * 1365088Sab196087 conv_ehdr_data(uchar_t data, Conv_fmt_flags_t fmt_flags, 1375088Sab196087 Conv_inv_buf_t *inv_buf) 1380Sstevel@tonic-gate { 139*9273SAli.Bahrami@Sun.COM return (conv_map_ds(ELFOSABI_NONE, EM_NONE, data, 140*9273SAli.Bahrami@Sun.COM ehdr_data_strings(fmt_flags), fmt_flags, inv_buf)); 141*9273SAli.Bahrami@Sun.COM } 1420Sstevel@tonic-gate 143*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 144*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_data(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 145*9273SAli.Bahrami@Sun.COM void *uvalue) 146*9273SAli.Bahrami@Sun.COM { 147*9273SAli.Bahrami@Sun.COM return (conv_iter_ds(ELFOSABI_NONE, EM_NONE, 148*9273SAli.Bahrami@Sun.COM ehdr_data_strings(fmt_flags), func, uvalue)); 1490Sstevel@tonic-gate } 1500Sstevel@tonic-gate 151*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 152*9273SAli.Bahrami@Sun.COM ehdr_mach_strings(Conv_fmt_flags_t fmt_flags) 153*9273SAli.Bahrami@Sun.COM { 154*9273SAli.Bahrami@Sun.COM 155*9273SAli.Bahrami@Sun.COM static const Msg mach_0_11_cf[] = { 156*9273SAli.Bahrami@Sun.COM MSG_EM_NONE_CF, MSG_EM_M32_CF, 157*9273SAli.Bahrami@Sun.COM MSG_EM_SPARC_CF, MSG_EM_386_CF, 158*9273SAli.Bahrami@Sun.COM MSG_EM_68K_CF, MSG_EM_88K_CF, 159*9273SAli.Bahrami@Sun.COM MSG_EM_486_CF, MSG_EM_860_CF, 160*9273SAli.Bahrami@Sun.COM MSG_EM_MIPS_CF, MSG_EM_S370_CF, 161*9273SAli.Bahrami@Sun.COM MSG_EM_MIPS_RS3_LE_CF, MSG_EM_RS6000_CF 162*9273SAli.Bahrami@Sun.COM }; 163*9273SAli.Bahrami@Sun.COM static const Msg mach_0_11_nf[] = { 164*9273SAli.Bahrami@Sun.COM MSG_EM_NONE_NF, MSG_EM_M32_NF, 165*9273SAli.Bahrami@Sun.COM MSG_EM_SPARC_NF, MSG_EM_386_NF, 166*9273SAli.Bahrami@Sun.COM MSG_EM_68K_NF, MSG_EM_88K_NF, 167*9273SAli.Bahrami@Sun.COM MSG_EM_486_NF, MSG_EM_860_NF, 168*9273SAli.Bahrami@Sun.COM MSG_EM_MIPS_NF, MSG_EM_S370_NF, 169*9273SAli.Bahrami@Sun.COM MSG_EM_MIPS_RS3_LE_NF, MSG_EM_RS6000_NF 170*9273SAli.Bahrami@Sun.COM }; 171*9273SAli.Bahrami@Sun.COM static const Msg mach_0_11_dmp[] = { 172*9273SAli.Bahrami@Sun.COM MSG_EM_NONE_DMP, MSG_EM_M32_DMP, 173*9273SAli.Bahrami@Sun.COM MSG_EM_SPARC_DMP, MSG_EM_386_DMP, 174*9273SAli.Bahrami@Sun.COM MSG_EM_68K_DMP, MSG_EM_88K_DMP, 175*9273SAli.Bahrami@Sun.COM MSG_EM_486_DMP, MSG_EM_860_DMP, 176*9273SAli.Bahrami@Sun.COM MSG_EM_MIPS_DMP, MSG_EM_S370_CF, 177*9273SAli.Bahrami@Sun.COM MSG_EM_MIPS_RS3_LE_DMP, MSG_EM_RS6000_DMP 178*9273SAli.Bahrami@Sun.COM }; 179*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_0_11_cf = { 180*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_NONE, mach_0_11_cf) }; 181*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_0_11_nf = { 182*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_NONE, mach_0_11_nf) }; 183*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_0_11_dmp = { 184*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_NONE, mach_0_11_dmp) }; 185*9273SAli.Bahrami@Sun.COM 186*9273SAli.Bahrami@Sun.COM 187*9273SAli.Bahrami@Sun.COM static const Msg mach_15_22_cf[] = { 188*9273SAli.Bahrami@Sun.COM MSG_EM_PA_RISC_CF, MSG_EM_NCUBE_CF, 189*9273SAli.Bahrami@Sun.COM MSG_EM_VPP500_CF, MSG_EM_SPARC32PLUS_CF, 190*9273SAli.Bahrami@Sun.COM MSG_EM_960_CF, MSG_EM_PPC_CF, 191*9273SAli.Bahrami@Sun.COM MSG_EM_PPC64_CF, MSG_EM_S390_CF 192*9273SAli.Bahrami@Sun.COM }; 193*9273SAli.Bahrami@Sun.COM static const Msg mach_15_22_nf[] = { 194*9273SAli.Bahrami@Sun.COM MSG_EM_PA_RISC_NF, MSG_EM_NCUBE_NF, 195*9273SAli.Bahrami@Sun.COM MSG_EM_VPP500_NF, MSG_EM_SPARC32PLUS_NF, 196*9273SAli.Bahrami@Sun.COM MSG_EM_960_NF, MSG_EM_PPC_NF, 197*9273SAli.Bahrami@Sun.COM MSG_EM_PPC64_NF, MSG_EM_S390_NF 198*9273SAli.Bahrami@Sun.COM }; 199*9273SAli.Bahrami@Sun.COM static const Msg mach_15_22_dmp[] = { 200*9273SAli.Bahrami@Sun.COM MSG_EM_PA_RISC_DMP, MSG_EM_NCUBE_DMP, 201*9273SAli.Bahrami@Sun.COM MSG_EM_VPP500_DMP, MSG_EM_SPARC32PLUS_DMP, 202*9273SAli.Bahrami@Sun.COM MSG_EM_960_CF, MSG_EM_PPC_DMP, 203*9273SAli.Bahrami@Sun.COM MSG_EM_PPC64_DMP, MSG_EM_S390_CF 204*9273SAli.Bahrami@Sun.COM }; 205*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_15_22_cf = { 206*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_PA_RISC, mach_15_22_cf) }; 207*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_15_22_nf = { 208*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_PA_RISC, mach_15_22_nf) }; 209*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_15_22_dmp = { 210*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_PA_RISC, mach_15_22_dmp) }; 211*9273SAli.Bahrami@Sun.COM 212*9273SAli.Bahrami@Sun.COM 213*9273SAli.Bahrami@Sun.COM static const Msg mach_36_63_cf[] = { 214*9273SAli.Bahrami@Sun.COM MSG_EM_V800_CF, MSG_EM_FR20_CF, 215*9273SAli.Bahrami@Sun.COM MSG_EM_RH32_CF, MSG_EM_RCE_CF, 216*9273SAli.Bahrami@Sun.COM MSG_EM_ARM_CF, MSG_EM_ALPHA_CF, 217*9273SAli.Bahrami@Sun.COM MSG_EM_SH_CF, MSG_EM_SPARCV9_CF, 218*9273SAli.Bahrami@Sun.COM MSG_EM_TRICORE_CF, MSG_EM_ARC_CF, 219*9273SAli.Bahrami@Sun.COM MSG_EM_H8_300_CF, MSG_EM_H8_300H_CF, 220*9273SAli.Bahrami@Sun.COM MSG_EM_H8S_CF, MSG_EM_H8_500_CF, 221*9273SAli.Bahrami@Sun.COM MSG_EM_IA_64_CF, MSG_EM_MIPS_X_CF, 222*9273SAli.Bahrami@Sun.COM MSG_EM_COLDFIRE_CF, MSG_EM_68HC12_CF, 223*9273SAli.Bahrami@Sun.COM MSG_EM_MMA_CF, MSG_EM_PCP_CF, 224*9273SAli.Bahrami@Sun.COM MSG_EM_NCPU_CF, MSG_EM_NDR1_CF, 225*9273SAli.Bahrami@Sun.COM MSG_EM_STARCORE_CF, MSG_EM_ME16_CF, 226*9273SAli.Bahrami@Sun.COM MSG_EM_ST100_CF, MSG_EM_TINYJ_CF, 227*9273SAli.Bahrami@Sun.COM MSG_EM_AMD64_CF, MSG_EM_PDSP_CF 228*9273SAli.Bahrami@Sun.COM }; 229*9273SAli.Bahrami@Sun.COM static const Msg mach_36_63_nf[] = { 230*9273SAli.Bahrami@Sun.COM MSG_EM_V800_NF, MSG_EM_FR20_NF, 231*9273SAli.Bahrami@Sun.COM MSG_EM_RH32_NF, MSG_EM_RCE_NF, 232*9273SAli.Bahrami@Sun.COM MSG_EM_ARM_NF, MSG_EM_ALPHA_NF, 233*9273SAli.Bahrami@Sun.COM MSG_EM_SH_NF, MSG_EM_SPARCV9_NF, 234*9273SAli.Bahrami@Sun.COM MSG_EM_TRICORE_NF, MSG_EM_ARC_NF, 235*9273SAli.Bahrami@Sun.COM MSG_EM_H8_300_NF, MSG_EM_H8_300H_NF, 236*9273SAli.Bahrami@Sun.COM MSG_EM_H8S_NF, MSG_EM_H8_500_NF, 237*9273SAli.Bahrami@Sun.COM MSG_EM_IA_64_NF, MSG_EM_MIPS_X_NF, 238*9273SAli.Bahrami@Sun.COM MSG_EM_COLDFIRE_NF, MSG_EM_68HC12_NF, 239*9273SAli.Bahrami@Sun.COM MSG_EM_MMA_NF, MSG_EM_PCP_NF, 240*9273SAli.Bahrami@Sun.COM MSG_EM_NCPU_NF, MSG_EM_NDR1_NF, 241*9273SAli.Bahrami@Sun.COM MSG_EM_STARCORE_NF, MSG_EM_ME16_NF, 242*9273SAli.Bahrami@Sun.COM MSG_EM_ST100_NF, MSG_EM_TINYJ_NF, 243*9273SAli.Bahrami@Sun.COM MSG_EM_AMD64_NF, MSG_EM_PDSP_NF 244*9273SAli.Bahrami@Sun.COM }; 245*9273SAli.Bahrami@Sun.COM static const Msg mach_36_63_dmp[] = { 246*9273SAli.Bahrami@Sun.COM MSG_EM_V800_CF, MSG_EM_FR20_CF, 247*9273SAli.Bahrami@Sun.COM MSG_EM_RH32_CF, MSG_EM_RCE_CF, 248*9273SAli.Bahrami@Sun.COM MSG_EM_ARM_DMP, MSG_EM_ALPHA_DMP, 249*9273SAli.Bahrami@Sun.COM MSG_EM_SH_CF, MSG_EM_SPARCV9_DMP, 250*9273SAli.Bahrami@Sun.COM MSG_EM_TRICORE_CF, MSG_EM_ARC_CF, 251*9273SAli.Bahrami@Sun.COM MSG_EM_H8_300_CF, MSG_EM_H8_300H_CF, 252*9273SAli.Bahrami@Sun.COM MSG_EM_H8S_CF, MSG_EM_H8_500_CF, 253*9273SAli.Bahrami@Sun.COM MSG_EM_IA_64_DMP, MSG_EM_MIPS_X_CF, 254*9273SAli.Bahrami@Sun.COM MSG_EM_COLDFIRE_CF, MSG_EM_68HC12_CF, 255*9273SAli.Bahrami@Sun.COM MSG_EM_MMA_CF, MSG_EM_PCP_CF, 256*9273SAli.Bahrami@Sun.COM MSG_EM_NCPU_CF, MSG_EM_NDR1_CF, 257*9273SAli.Bahrami@Sun.COM MSG_EM_STARCORE_CF, MSG_EM_ME16_CF, 258*9273SAli.Bahrami@Sun.COM MSG_EM_ST100_CF, MSG_EM_TINYJ_CF, 259*9273SAli.Bahrami@Sun.COM MSG_EM_AMD64_DMP, MSG_EM_PDSP_CF 260*9273SAli.Bahrami@Sun.COM }; 261*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_36_63_cf = { 262*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_V800, mach_36_63_cf) }; 263*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_36_63_nf = { 264*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_V800, mach_36_63_nf) }; 265*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_36_63_dmp = { 266*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_V800, mach_36_63_dmp) }; 267*9273SAli.Bahrami@Sun.COM 268*9273SAli.Bahrami@Sun.COM 269*9273SAli.Bahrami@Sun.COM static const Msg mach_66_94_cf[] = { 270*9273SAli.Bahrami@Sun.COM MSG_EM_FX66_CF, MSG_EM_ST9PLUS_CF, 271*9273SAli.Bahrami@Sun.COM MSG_EM_ST7_CF, MSG_EM_68HC16_CF, 272*9273SAli.Bahrami@Sun.COM MSG_EM_68HC11_CF, MSG_EM_68HC08_CF, 273*9273SAli.Bahrami@Sun.COM MSG_EM_68HC05_CF, MSG_EM_SVX_CF, 274*9273SAli.Bahrami@Sun.COM MSG_EM_ST19_CF, MSG_EM_VAX_CF, 275*9273SAli.Bahrami@Sun.COM MSG_EM_CRIS_CF, MSG_EM_JAVELIN_CF, 276*9273SAli.Bahrami@Sun.COM MSG_EM_FIREPATH_CF, MSG_EM_ZSP_CF, 277*9273SAli.Bahrami@Sun.COM MSG_EM_MMIX_CF, MSG_EM_HUANY_CF, 278*9273SAli.Bahrami@Sun.COM MSG_EM_PRISM_CF, MSG_EM_AVR_CF, 279*9273SAli.Bahrami@Sun.COM MSG_EM_FR30_CF, MSG_EM_D10V_CF, 280*9273SAli.Bahrami@Sun.COM MSG_EM_D30V_CF, MSG_EM_V850_CF, 281*9273SAli.Bahrami@Sun.COM MSG_EM_M32R_CF, MSG_EM_MN10300_CF, 282*9273SAli.Bahrami@Sun.COM MSG_EM_MN10200_CF, MSG_EM_PJ_CF, 283*9273SAli.Bahrami@Sun.COM MSG_EM_OPENRISC_CF, MSG_EM_ARC_A5_CF, 284*9273SAli.Bahrami@Sun.COM MSG_EM_XTENSA_CF 285*9273SAli.Bahrami@Sun.COM }; 286*9273SAli.Bahrami@Sun.COM static const Msg mach_66_94_nf[] = { 287*9273SAli.Bahrami@Sun.COM MSG_EM_FX66_NF, MSG_EM_ST9PLUS_NF, 288*9273SAli.Bahrami@Sun.COM MSG_EM_ST7_NF, MSG_EM_68HC16_NF, 289*9273SAli.Bahrami@Sun.COM MSG_EM_68HC11_NF, MSG_EM_68HC08_NF, 290*9273SAli.Bahrami@Sun.COM MSG_EM_68HC05_NF, MSG_EM_SVX_NF, 291*9273SAli.Bahrami@Sun.COM MSG_EM_ST19_NF, MSG_EM_VAX_NF, 292*9273SAli.Bahrami@Sun.COM MSG_EM_CRIS_NF, MSG_EM_JAVELIN_NF, 293*9273SAli.Bahrami@Sun.COM MSG_EM_FIREPATH_NF, MSG_EM_ZSP_NF, 294*9273SAli.Bahrami@Sun.COM MSG_EM_MMIX_NF, MSG_EM_HUANY_NF, 295*9273SAli.Bahrami@Sun.COM MSG_EM_PRISM_NF, MSG_EM_AVR_NF, 296*9273SAli.Bahrami@Sun.COM MSG_EM_FR30_NF, MSG_EM_D10V_NF, 297*9273SAli.Bahrami@Sun.COM MSG_EM_D30V_NF, MSG_EM_V850_NF, 298*9273SAli.Bahrami@Sun.COM MSG_EM_M32R_NF, MSG_EM_MN10300_NF, 299*9273SAli.Bahrami@Sun.COM MSG_EM_MN10200_NF, MSG_EM_PJ_NF, 300*9273SAli.Bahrami@Sun.COM MSG_EM_OPENRISC_NF, MSG_EM_ARC_A5_NF, 301*9273SAli.Bahrami@Sun.COM MSG_EM_XTENSA_NF 302*9273SAli.Bahrami@Sun.COM }; 303*9273SAli.Bahrami@Sun.COM static const Msg mach_66_94_dmp[] = { 304*9273SAli.Bahrami@Sun.COM MSG_EM_FX66_CF, MSG_EM_ST9PLUS_CF, 305*9273SAli.Bahrami@Sun.COM MSG_EM_ST7_CF, MSG_EM_68HC16_CF, 306*9273SAli.Bahrami@Sun.COM MSG_EM_68HC11_CF, MSG_EM_68HC08_CF, 307*9273SAli.Bahrami@Sun.COM MSG_EM_68HC05_CF, MSG_EM_SVX_CF, 308*9273SAli.Bahrami@Sun.COM MSG_EM_ST19_CF, MSG_EM_VAX_DMP, 309*9273SAli.Bahrami@Sun.COM MSG_EM_CRIS_CF, MSG_EM_JAVELIN_CF, 310*9273SAli.Bahrami@Sun.COM MSG_EM_FIREPATH_CF, MSG_EM_ZSP_CF, 311*9273SAli.Bahrami@Sun.COM MSG_EM_MMIX_CF, MSG_EM_HUANY_CF, 312*9273SAli.Bahrami@Sun.COM MSG_EM_PRISM_CF, MSG_EM_AVR_CF, 313*9273SAli.Bahrami@Sun.COM MSG_EM_FR30_CF, MSG_EM_D10V_CF, 314*9273SAli.Bahrami@Sun.COM MSG_EM_D30V_CF, MSG_EM_V850_CF, 315*9273SAli.Bahrami@Sun.COM MSG_EM_M32R_CF, MSG_EM_MN10300_CF, 316*9273SAli.Bahrami@Sun.COM MSG_EM_MN10200_CF, MSG_EM_PJ_CF, 317*9273SAli.Bahrami@Sun.COM MSG_EM_OPENRISC_CF, MSG_EM_ARC_A5_CF, 318*9273SAli.Bahrami@Sun.COM MSG_EM_XTENSA_CF 319*9273SAli.Bahrami@Sun.COM }; 3200Sstevel@tonic-gate #if (EM_NUM != (EM_XTENSA + 1)) 3210Sstevel@tonic-gate #error "EM_NUM has grown" 3220Sstevel@tonic-gate #endif 323*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_66_94_cf = { 324*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_FX66, mach_66_94_cf) }; 325*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_66_94_nf = { 326*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_FX66, mach_66_94_nf) }; 327*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mach_66_94_dmp = { 328*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EM_FX66, mach_66_94_dmp) }; 329*9273SAli.Bahrami@Sun.COM 330*9273SAli.Bahrami@Sun.COM 331*9273SAli.Bahrami@Sun.COM /* Build NULL terminated return arrays for each string style */ 332*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_cf[] = { 333*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_mach_0_11_cf), CONV_DS_ADDR(ds_mach_15_22_cf), 334*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_mach_36_63_cf), CONV_DS_ADDR(ds_mach_66_94_cf), 335*9273SAli.Bahrami@Sun.COM NULL 336*9273SAli.Bahrami@Sun.COM }; 337*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_nf[] = { 338*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_mach_0_11_nf), CONV_DS_ADDR(ds_mach_15_22_nf), 339*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_mach_36_63_nf), CONV_DS_ADDR(ds_mach_66_94_nf), 340*9273SAli.Bahrami@Sun.COM NULL 341*9273SAli.Bahrami@Sun.COM }; 342*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_dmp[] = { 343*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_mach_0_11_dmp), CONV_DS_ADDR(ds_mach_15_22_dmp), 344*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_mach_36_63_dmp), 345*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_mach_66_94_dmp), NULL 346*9273SAli.Bahrami@Sun.COM }; 347*9273SAli.Bahrami@Sun.COM 348*9273SAli.Bahrami@Sun.COM 349*9273SAli.Bahrami@Sun.COM /* Select the strings to use */ 350*9273SAli.Bahrami@Sun.COM switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 351*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_DUMP: 352*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_FILE: 353*9273SAli.Bahrami@Sun.COM return (ds_dmp); 354*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 355*9273SAli.Bahrami@Sun.COM return (ds_nf); 356*9273SAli.Bahrami@Sun.COM } 357*9273SAli.Bahrami@Sun.COM 358*9273SAli.Bahrami@Sun.COM return (ds_cf); 359*9273SAli.Bahrami@Sun.COM } 3601618Srie 3611618Srie const char * 3625088Sab196087 conv_ehdr_mach(Half machine, Conv_fmt_flags_t fmt_flags, 3635088Sab196087 Conv_inv_buf_t *inv_buf) 3641618Srie { 365*9273SAli.Bahrami@Sun.COM return (conv_map_ds(ELFOSABI_NONE, EM_NONE, machine, 366*9273SAli.Bahrami@Sun.COM ehdr_mach_strings(fmt_flags), fmt_flags, inv_buf)); 367*9273SAli.Bahrami@Sun.COM } 3685088Sab196087 369*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 370*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_mach(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 371*9273SAli.Bahrami@Sun.COM void *uvalue) 372*9273SAli.Bahrami@Sun.COM { 373*9273SAli.Bahrami@Sun.COM static const Val_desc extra_dmp_nf[] = { 374*9273SAli.Bahrami@Sun.COM { EM_M32, MSG_EM_M32_DMP}, 375*9273SAli.Bahrami@Sun.COM { EM_386, MSG_EM_386_DMP }, 376*9273SAli.Bahrami@Sun.COM { EM_68K, MSG_EM_68K_DMP }, 377*9273SAli.Bahrami@Sun.COM { EM_88K, MSG_EM_88K_DMP }, 378*9273SAli.Bahrami@Sun.COM { EM_486, MSG_EM_486_DMP }, 379*9273SAli.Bahrami@Sun.COM { EM_860, MSG_EM_860_DMP }, 380*9273SAli.Bahrami@Sun.COM { EM_MIPS, MSG_EM_MIPS_DMP }, 381*9273SAli.Bahrami@Sun.COM { EM_MIPS_RS3_LE, MSG_EM_MIPS_RS3_LE_DMP }, 382*9273SAli.Bahrami@Sun.COM { EM_PPC, MSG_EM_PPC_DMP }, 383*9273SAli.Bahrami@Sun.COM { EM_PPC64, MSG_EM_PPC64_DMP }, 384*9273SAli.Bahrami@Sun.COM 385*9273SAli.Bahrami@Sun.COM { 0 } 386*9273SAli.Bahrami@Sun.COM }; 387*9273SAli.Bahrami@Sun.COM 388*9273SAli.Bahrami@Sun.COM if (conv_iter_ds(ELFOSABI_NONE, EM_NONE, 389*9273SAli.Bahrami@Sun.COM ehdr_mach_strings(fmt_flags), func, uvalue) == CONV_ITER_DONE) 390*9273SAli.Bahrami@Sun.COM return (CONV_ITER_DONE); 391*9273SAli.Bahrami@Sun.COM 392*9273SAli.Bahrami@Sun.COM /* 393*9273SAli.Bahrami@Sun.COM * For the NF style, we also supply a few of the traditional 394*9273SAli.Bahrami@Sun.COM * dump versions for iteration, but not for display. 395*9273SAli.Bahrami@Sun.COM */ 396*9273SAli.Bahrami@Sun.COM if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF) 397*9273SAli.Bahrami@Sun.COM return (conv_iter_vd(extra_dmp_nf, func, uvalue)); 398*9273SAli.Bahrami@Sun.COM 399*9273SAli.Bahrami@Sun.COM return (CONV_ITER_CONT); 4000Sstevel@tonic-gate } 4010Sstevel@tonic-gate 4021976Sab196087 403*9273SAli.Bahrami@Sun.COM 404*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 405*9273SAli.Bahrami@Sun.COM ehdr_eident_strings(Conv_fmt_flags_t fmt_flags) 4060Sstevel@tonic-gate { 407*9273SAli.Bahrami@Sun.COM static const Msg eident_cf[] = { 408*9273SAli.Bahrami@Sun.COM MSG_EI_MAG0_CF, MSG_EI_MAG1_CF, 409*9273SAli.Bahrami@Sun.COM MSG_EI_MAG2_CF, MSG_EI_MAG3_CF, 410*9273SAli.Bahrami@Sun.COM MSG_EI_CLASS_CF, MSG_EI_DATA_CF, 411*9273SAli.Bahrami@Sun.COM MSG_EI_VERSION_CF, MSG_EI_OSABI_CF, 412*9273SAli.Bahrami@Sun.COM MSG_EI_ABIVERSION_CF 413*9273SAli.Bahrami@Sun.COM }; 414*9273SAli.Bahrami@Sun.COM static const Msg eident_nf[] = { 415*9273SAli.Bahrami@Sun.COM MSG_EI_MAG0_NF, MSG_EI_MAG1_NF, 416*9273SAli.Bahrami@Sun.COM MSG_EI_MAG2_NF, MSG_EI_MAG3_NF, 417*9273SAli.Bahrami@Sun.COM MSG_EI_CLASS_NF, MSG_EI_DATA_NF, 418*9273SAli.Bahrami@Sun.COM MSG_EI_VERSION_NF, MSG_EI_OSABI_NF, 419*9273SAli.Bahrami@Sun.COM MSG_EI_ABIVERSION_NF 420*9273SAli.Bahrami@Sun.COM }; 421*9273SAli.Bahrami@Sun.COM #if EI_PAD != (EI_ABIVERSION + 1) 422*9273SAli.Bahrami@Sun.COM error "EI_PAD has grown. Update etypes[]" 423*9273SAli.Bahrami@Sun.COM #endif 424*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_eident_cf = { 425*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EI_MAG0, eident_cf) }; 426*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_eident_nf = { 427*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EI_MAG0, eident_nf) }; 428*9273SAli.Bahrami@Sun.COM 429*9273SAli.Bahrami@Sun.COM /* Build NULL terminated return arrays for each string style */ 430*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_cf[] = { 431*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_eident_cf), NULL }; 432*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_nf[] = { 433*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_eident_nf), NULL }; 434*9273SAli.Bahrami@Sun.COM 435*9273SAli.Bahrami@Sun.COM /* Select the strings to use */ 436*9273SAli.Bahrami@Sun.COM return ((CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_CF) ? 437*9273SAli.Bahrami@Sun.COM ds_cf : ds_nf); 438*9273SAli.Bahrami@Sun.COM } 439*9273SAli.Bahrami@Sun.COM 440*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 441*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_eident(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 442*9273SAli.Bahrami@Sun.COM void *uvalue) 443*9273SAli.Bahrami@Sun.COM { 444*9273SAli.Bahrami@Sun.COM return (conv_iter_ds(ELFOSABI_NONE, EM_NONE, 445*9273SAli.Bahrami@Sun.COM ehdr_eident_strings(fmt_flags), func, uvalue)); 446*9273SAli.Bahrami@Sun.COM } 447*9273SAli.Bahrami@Sun.COM 448*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 449*9273SAli.Bahrami@Sun.COM ehdr_type_strings(Conv_fmt_flags_t fmt_flags) 450*9273SAli.Bahrami@Sun.COM { 451*9273SAli.Bahrami@Sun.COM #define SOL ELFOSABI_SOLARIS, EM_NONE 452*9273SAli.Bahrami@Sun.COM 453*9273SAli.Bahrami@Sun.COM static const Msg type_cf[] = { 454*9273SAli.Bahrami@Sun.COM MSG_ET_NONE_CF, MSG_ET_REL_CF, MSG_ET_EXEC_CF, 455*9273SAli.Bahrami@Sun.COM MSG_ET_DYN_CF, MSG_ET_CORE_CF 4561618Srie }; 457*9273SAli.Bahrami@Sun.COM static const Msg type_nf[] = { 458*9273SAli.Bahrami@Sun.COM MSG_ET_NONE_NF, MSG_ET_REL_NF, MSG_ET_EXEC_NF, 459*9273SAli.Bahrami@Sun.COM MSG_ET_DYN_NF, MSG_ET_CORE_NF 460*9273SAli.Bahrami@Sun.COM }; 461*9273SAli.Bahrami@Sun.COM static const Msg type_dmp[] = { 462*9273SAli.Bahrami@Sun.COM MSG_ET_NONE_DMP, MSG_ET_REL_DMP, MSG_ET_EXEC_DMP, 463*9273SAli.Bahrami@Sun.COM MSG_ET_DYN_DMP, MSG_ET_CORE_DMP 4641976Sab196087 }; 465*9273SAli.Bahrami@Sun.COM #if ET_NUM != (ET_CORE + 1) 466*9273SAli.Bahrami@Sun.COM error "ET_NUM has grown. Update types[]" 467*9273SAli.Bahrami@Sun.COM #endif 468*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_type_cf = { 469*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ET_NONE, type_cf) }; 470*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_type_nf = { 471*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ET_NONE, type_nf) }; 472*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_type_dmp = { 473*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ET_NONE, type_dmp) }; 4740Sstevel@tonic-gate 475*9273SAli.Bahrami@Sun.COM static const Val_desc2 type_osabi_cf[] = { 476*9273SAli.Bahrami@Sun.COM { ET_SUNWPSEUDO, SOL, MSG_ET_SUNWPSEUDO_CF }, 477*9273SAli.Bahrami@Sun.COM { 0 } 478*9273SAli.Bahrami@Sun.COM }; 479*9273SAli.Bahrami@Sun.COM static const Val_desc2 type_osabi_nf[] = { 480*9273SAli.Bahrami@Sun.COM { ET_SUNWPSEUDO, SOL, MSG_ET_SUNWPSEUDO_NF }, 481*9273SAli.Bahrami@Sun.COM { 0 } 482*9273SAli.Bahrami@Sun.COM }; 483*9273SAli.Bahrami@Sun.COM static const Val_desc2 type_osabi_dmp[] = { 484*9273SAli.Bahrami@Sun.COM { ET_SUNWPSEUDO, SOL, MSG_ET_SUNWPSEUDO_DMP }, 485*9273SAli.Bahrami@Sun.COM { 0 } 486*9273SAli.Bahrami@Sun.COM }; 487*9273SAli.Bahrami@Sun.COM #if ET_LOSUNW != ET_SUNWPSEUDO 488*9273SAli.Bahrami@Sun.COM error "ET_LOSUNW has grown. Update type_osabi[]" 489*9273SAli.Bahrami@Sun.COM #endif 490*9273SAli.Bahrami@Sun.COM static const conv_ds_vd2_t ds_type_osabi_cf = { 491*9273SAli.Bahrami@Sun.COM CONV_DS_VD2, ET_LOOS, ET_HIOS, type_osabi_cf }; 492*9273SAli.Bahrami@Sun.COM static const conv_ds_vd2_t ds_type_osabi_nf = { 493*9273SAli.Bahrami@Sun.COM CONV_DS_VD2, ET_LOOS, ET_HIOS, type_osabi_nf }; 494*9273SAli.Bahrami@Sun.COM static const conv_ds_vd2_t ds_type_osabi_dmp = { 495*9273SAli.Bahrami@Sun.COM CONV_DS_VD2, ET_LOOS, ET_HIOS, type_osabi_dmp }; 496*9273SAli.Bahrami@Sun.COM 497*9273SAli.Bahrami@Sun.COM 498*9273SAli.Bahrami@Sun.COM /* Build NULL terminated return arrays for each string style */ 499*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_cf[] = { 500*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_type_cf), CONV_DS_ADDR(ds_type_osabi_cf), 501*9273SAli.Bahrami@Sun.COM NULL }; 502*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_nf[] = { 503*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_type_nf), CONV_DS_ADDR(ds_type_osabi_nf), 504*9273SAli.Bahrami@Sun.COM NULL }; 505*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_dmp[] = { 506*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_type_dmp), CONV_DS_ADDR(ds_type_osabi_dmp), 507*9273SAli.Bahrami@Sun.COM NULL }; 508*9273SAli.Bahrami@Sun.COM 509*9273SAli.Bahrami@Sun.COM /* Select the strings to use */ 510*9273SAli.Bahrami@Sun.COM switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 511*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_DUMP: 512*9273SAli.Bahrami@Sun.COM return (ds_dmp); 513*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 514*9273SAli.Bahrami@Sun.COM return (ds_nf); 5151976Sab196087 } 5161976Sab196087 517*9273SAli.Bahrami@Sun.COM return (ds_cf); 518*9273SAli.Bahrami@Sun.COM 519*9273SAli.Bahrami@Sun.COM #undef SOL 520*9273SAli.Bahrami@Sun.COM } 521*9273SAli.Bahrami@Sun.COM 522*9273SAli.Bahrami@Sun.COM const char * 523*9273SAli.Bahrami@Sun.COM conv_ehdr_type(uchar_t osabi, Half etype, Conv_fmt_flags_t fmt_flags, 524*9273SAli.Bahrami@Sun.COM Conv_inv_buf_t *inv_buf) 525*9273SAli.Bahrami@Sun.COM { 526*9273SAli.Bahrami@Sun.COM return (conv_map_ds(osabi, EM_NONE, etype, 527*9273SAli.Bahrami@Sun.COM ehdr_type_strings(fmt_flags), fmt_flags, inv_buf)); 528*9273SAli.Bahrami@Sun.COM } 529*9273SAli.Bahrami@Sun.COM 530*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 531*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_type(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags, 532*9273SAli.Bahrami@Sun.COM conv_iter_cb_t func, void *uvalue) 533*9273SAli.Bahrami@Sun.COM { 534*9273SAli.Bahrami@Sun.COM return (conv_iter_ds(osabi, EM_NONE, 535*9273SAli.Bahrami@Sun.COM ehdr_type_strings(fmt_flags), func, uvalue)); 536*9273SAli.Bahrami@Sun.COM } 537*9273SAli.Bahrami@Sun.COM 538*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 539*9273SAli.Bahrami@Sun.COM ehdr_vers_strings(Conv_fmt_flags_t fmt_flags) 540*9273SAli.Bahrami@Sun.COM { 541*9273SAli.Bahrami@Sun.COM static const Msg versions_cf[] = { 542*9273SAli.Bahrami@Sun.COM MSG_EV_NONE_CF, MSG_EV_CURRENT_CF 543*9273SAli.Bahrami@Sun.COM }; 544*9273SAli.Bahrami@Sun.COM static const Msg versions_nf[] = { 545*9273SAli.Bahrami@Sun.COM MSG_EV_NONE_NF, MSG_EV_CURRENT_NF 546*9273SAli.Bahrami@Sun.COM }; 547*9273SAli.Bahrami@Sun.COM static const Msg versions_dmp[] = { 548*9273SAli.Bahrami@Sun.COM MSG_EV_NONE_DMP, MSG_EV_CURRENT_DMP 549*9273SAli.Bahrami@Sun.COM }; 550*9273SAli.Bahrami@Sun.COM #if EV_NUM != 2 551*9273SAli.Bahrami@Sun.COM error "EV_NUM has grown. Update versions[]" 552*9273SAli.Bahrami@Sun.COM #endif 553*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_versions_cf = { 554*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EV_NONE, versions_cf) }; 555*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_versions_nf = { 556*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EV_NONE, versions_nf) }; 557*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_versions_dmp = { 558*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EV_NONE, versions_dmp) }; 559*9273SAli.Bahrami@Sun.COM 560*9273SAli.Bahrami@Sun.COM /* Build NULL terminated return arrays for each string style */ 561*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_cf[] = { 562*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_versions_cf), NULL }; 563*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_nf[] = { 564*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_versions_nf), NULL }; 565*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_dmp[] = { 566*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_versions_dmp), NULL }; 567*9273SAli.Bahrami@Sun.COM 568*9273SAli.Bahrami@Sun.COM /* Select the strings to use */ 5695088Sab196087 switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 5705088Sab196087 case CONV_FMT_ALT_DUMP: 571*9273SAli.Bahrami@Sun.COM return (ds_dmp); 572*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 573*9273SAli.Bahrami@Sun.COM return (ds_nf); 5745088Sab196087 } 5755088Sab196087 576*9273SAli.Bahrami@Sun.COM return (ds_cf); 5770Sstevel@tonic-gate } 5780Sstevel@tonic-gate 5790Sstevel@tonic-gate const char * 5805088Sab196087 conv_ehdr_vers(Word version, Conv_fmt_flags_t fmt_flags, 5815088Sab196087 Conv_inv_buf_t *inv_buf) 5820Sstevel@tonic-gate { 583*9273SAli.Bahrami@Sun.COM return (conv_map_ds(ELFOSABI_NONE, EM_NONE, version, 584*9273SAli.Bahrami@Sun.COM ehdr_vers_strings(fmt_flags), fmt_flags, inv_buf)); 585*9273SAli.Bahrami@Sun.COM } 5860Sstevel@tonic-gate 587*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 588*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_vers(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 589*9273SAli.Bahrami@Sun.COM void *uvalue) 590*9273SAli.Bahrami@Sun.COM { 591*9273SAli.Bahrami@Sun.COM return (conv_iter_ds(ELFOSABI_NONE, EM_NONE, 592*9273SAli.Bahrami@Sun.COM ehdr_vers_strings(fmt_flags), func, uvalue)); 5930Sstevel@tonic-gate } 5940Sstevel@tonic-gate 595*9273SAli.Bahrami@Sun.COM static void 596*9273SAli.Bahrami@Sun.COM conv_ehdr_sparc_flags_strings(Conv_fmt_flags_t fmt_flags, 597*9273SAli.Bahrami@Sun.COM const conv_ds_msg_t **mm_msg, const Val_desc **flag_desc) 598*9273SAli.Bahrami@Sun.COM { 5992352Sab196087 #define EFLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 600*9273SAli.Bahrami@Sun.COM MSG_EF_SPARCV9_TSO_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 601*9273SAli.Bahrami@Sun.COM MSG_EF_SPARC_SUN_US1_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 602*9273SAli.Bahrami@Sun.COM MSG_EF_SPARC_HAL_R1_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 603*9273SAli.Bahrami@Sun.COM MSG_EF_SPARC_SUN_US3_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 604*9273SAli.Bahrami@Sun.COM CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 6054734Sab196087 606*9273SAli.Bahrami@Sun.COM /* 607*9273SAli.Bahrami@Sun.COM * Ensure that Conv_ehdr_flags_buf_t is large enough: 608*9273SAli.Bahrami@Sun.COM * 609*9273SAli.Bahrami@Sun.COM * EFLAGSZ is the real minimum size of the buffer required by 610*9273SAli.Bahrami@Sun.COM * conv_ehdr_flags(). However, Conv_ehdr_flags_buf_t uses 611*9273SAli.Bahrami@Sun.COM * CONV_EHDR_FLAG_BUFSIZE to set the buffer size. We do things 612*9273SAli.Bahrami@Sun.COM * this way because the definition of EFLAGSZ uses information 613*9273SAli.Bahrami@Sun.COM * that is not available in the environment of other programs 614*9273SAli.Bahrami@Sun.COM * that include the conv.h header file. 615*9273SAli.Bahrami@Sun.COM */ 6165152Sab196087 #if (CONV_EHDR_FLAGS_BUFSIZE != EFLAGSZ) && !defined(__lint) 6175152Sab196087 #define REPORT_BUFSIZE EFLAGSZ 6185152Sab196087 #include "report_bufsize.h" 6195152Sab196087 #error "CONV_EHDR_FLAGS_BUFSIZE does not match EFLAGSZ" 6204734Sab196087 #endif 6210Sstevel@tonic-gate 622*9273SAli.Bahrami@Sun.COM static const Msg mm_flags_cf[] = { 623*9273SAli.Bahrami@Sun.COM MSG_EF_SPARCV9_TSO_CF, MSG_EF_SPARCV9_PSO_CF, 624*9273SAli.Bahrami@Sun.COM MSG_EF_SPARCV9_RMO_CF 625*9273SAli.Bahrami@Sun.COM }; 626*9273SAli.Bahrami@Sun.COM static const Msg mm_flags_nf[] = { 627*9273SAli.Bahrami@Sun.COM MSG_EF_SPARCV9_TSO_NF, MSG_EF_SPARCV9_PSO_NF, 628*9273SAli.Bahrami@Sun.COM MSG_EF_SPARCV9_RMO_NF 629*9273SAli.Bahrami@Sun.COM }; 630*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mm_flags_cf = { 631*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EF_SPARCV9_TSO, mm_flags_cf) }; 632*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_mm_flags_nf = { 633*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EF_SPARCV9_TSO, mm_flags_nf) }; 634*9273SAli.Bahrami@Sun.COM 635*9273SAli.Bahrami@Sun.COM 636*9273SAli.Bahrami@Sun.COM static const Val_desc vda_cf[] = { 637*9273SAli.Bahrami@Sun.COM { EF_SPARC_32PLUS, MSG_EF_SPARC_32PLUS_CF }, 638*9273SAli.Bahrami@Sun.COM { EF_SPARC_SUN_US1, MSG_EF_SPARC_SUN_US1_CF }, 639*9273SAli.Bahrami@Sun.COM { EF_SPARC_HAL_R1, MSG_EF_SPARC_HAL_R1_CF }, 640*9273SAli.Bahrami@Sun.COM { EF_SPARC_SUN_US3, MSG_EF_SPARC_SUN_US3_CF }, 641*9273SAli.Bahrami@Sun.COM { 0 } 642*9273SAli.Bahrami@Sun.COM }; 643*9273SAli.Bahrami@Sun.COM static const Val_desc vda_nf[] = { 644*9273SAli.Bahrami@Sun.COM { EF_SPARC_32PLUS, MSG_EF_SPARC_32PLUS_NF }, 645*9273SAli.Bahrami@Sun.COM { EF_SPARC_SUN_US1, MSG_EF_SPARC_SUN_US1_NF }, 646*9273SAli.Bahrami@Sun.COM { EF_SPARC_HAL_R1, MSG_EF_SPARC_HAL_R1_NF }, 647*9273SAli.Bahrami@Sun.COM { EF_SPARC_SUN_US3, MSG_EF_SPARC_SUN_US3_NF }, 648*9273SAli.Bahrami@Sun.COM { 0 } 649*9273SAli.Bahrami@Sun.COM }; 650*9273SAli.Bahrami@Sun.COM 651*9273SAli.Bahrami@Sun.COM switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 652*9273SAli.Bahrami@Sun.COM default: 653*9273SAli.Bahrami@Sun.COM *mm_msg = &ds_mm_flags_cf; 654*9273SAli.Bahrami@Sun.COM *flag_desc = vda_cf; 655*9273SAli.Bahrami@Sun.COM break; 656*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 657*9273SAli.Bahrami@Sun.COM *mm_msg = &ds_mm_flags_nf; 658*9273SAli.Bahrami@Sun.COM *flag_desc = vda_nf; 659*9273SAli.Bahrami@Sun.COM break; 660*9273SAli.Bahrami@Sun.COM } 661*9273SAli.Bahrami@Sun.COM } 662*9273SAli.Bahrami@Sun.COM 6630Sstevel@tonic-gate /* 6641618Srie * Make a string representation of the e_flags field. 6650Sstevel@tonic-gate */ 6660Sstevel@tonic-gate const char * 6675088Sab196087 conv_ehdr_flags(Half mach, Word flags, Conv_fmt_flags_t fmt_flags, 6685088Sab196087 Conv_ehdr_flags_buf_t *flags_buf) 6690Sstevel@tonic-gate { 6702352Sab196087 static const char *leading_str_arr[2]; 6714734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 672*9273SAli.Bahrami@Sun.COM NULL, sizeof (flags_buf->buf), leading_str_arr }; 6732352Sab196087 674*9273SAli.Bahrami@Sun.COM const char **lstr; 675*9273SAli.Bahrami@Sun.COM const conv_ds_msg_t *mm_msg; 676*9273SAli.Bahrami@Sun.COM const Val_desc *vdp; 677*9273SAli.Bahrami@Sun.COM Word mm; 6784734Sab196087 6790Sstevel@tonic-gate /* 6801618Srie * Non-SPARC architectures presently provide no known flags. 6810Sstevel@tonic-gate */ 682*9273SAli.Bahrami@Sun.COM if ((mach != EM_SPARCV9) && (((mach != EM_SPARC) && 683*9273SAli.Bahrami@Sun.COM (mach != EM_SPARC32PLUS)) || (flags == 0))) 684*9273SAli.Bahrami@Sun.COM return (conv_invalid_val(&flags_buf->inv_buf, flags, 685*9273SAli.Bahrami@Sun.COM CONV_FMT_DECIMAL)); 686*9273SAli.Bahrami@Sun.COM 687*9273SAli.Bahrami@Sun.COM conv_arg.buf = flags_buf->buf; 688*9273SAli.Bahrami@Sun.COM conv_ehdr_sparc_flags_strings(fmt_flags, &mm_msg, &vdp); 689*9273SAli.Bahrami@Sun.COM conv_arg.oflags = conv_arg.rflags = flags; 690*9273SAli.Bahrami@Sun.COM 691*9273SAli.Bahrami@Sun.COM mm = flags & EF_SPARCV9_MM; 692*9273SAli.Bahrami@Sun.COM lstr = leading_str_arr; 693*9273SAli.Bahrami@Sun.COM if ((mach == EM_SPARCV9) && (mm <= mm_msg->ds_topval)) { 694*9273SAli.Bahrami@Sun.COM *lstr++ = MSG_ORIG(mm_msg->ds_msg[mm]); 695*9273SAli.Bahrami@Sun.COM conv_arg.rflags &= ~EF_SPARCV9_MM; 696*9273SAli.Bahrami@Sun.COM } 697*9273SAli.Bahrami@Sun.COM *lstr = NULL; 698*9273SAli.Bahrami@Sun.COM 699*9273SAli.Bahrami@Sun.COM (void) conv_expn_field(&conv_arg, vdp, fmt_flags); 700*9273SAli.Bahrami@Sun.COM 701*9273SAli.Bahrami@Sun.COM return (conv_arg.buf); 702*9273SAli.Bahrami@Sun.COM } 7030Sstevel@tonic-gate 704*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 705*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_flags(Half mach, Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 706*9273SAli.Bahrami@Sun.COM void *uvalue) 707*9273SAli.Bahrami@Sun.COM { 708*9273SAli.Bahrami@Sun.COM 709*9273SAli.Bahrami@Sun.COM if ((mach == EM_SPARCV9) || (mach == EM_SPARC) || 710*9273SAli.Bahrami@Sun.COM (mach == EM_SPARC32PLUS) || (mach == CONV_MACH_ALL)) { 711*9273SAli.Bahrami@Sun.COM const conv_ds_msg_t *ds_msg_mm; 712*9273SAli.Bahrami@Sun.COM const Val_desc *vdp; 713*9273SAli.Bahrami@Sun.COM 714*9273SAli.Bahrami@Sun.COM conv_ehdr_sparc_flags_strings(fmt_flags, &ds_msg_mm, &vdp); 715*9273SAli.Bahrami@Sun.COM 716*9273SAli.Bahrami@Sun.COM if (mach == EM_SPARCV9) { 717*9273SAli.Bahrami@Sun.COM const conv_ds_t *ds[2]; 718*9273SAli.Bahrami@Sun.COM 719*9273SAli.Bahrami@Sun.COM ds[0] = CONV_DS_ADDR(ds_msg_mm); 720*9273SAli.Bahrami@Sun.COM ds[1] = NULL; 721*9273SAli.Bahrami@Sun.COM 722*9273SAli.Bahrami@Sun.COM if (conv_iter_ds(ELFOSABI_NONE, mach, ds, 723*9273SAli.Bahrami@Sun.COM func, uvalue) == CONV_ITER_DONE) 724*9273SAli.Bahrami@Sun.COM return (CONV_ITER_DONE); 7250Sstevel@tonic-gate } 7260Sstevel@tonic-gate 727*9273SAli.Bahrami@Sun.COM return (conv_iter_vd(vdp, func, uvalue)); 7281618Srie } 7294734Sab196087 730*9273SAli.Bahrami@Sun.COM return (CONV_ITER_CONT); 731*9273SAli.Bahrami@Sun.COM } 732*9273SAli.Bahrami@Sun.COM 733*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 734*9273SAli.Bahrami@Sun.COM ehdr_osabi_strings(Conv_fmt_flags_t fmt_flags) 735*9273SAli.Bahrami@Sun.COM { 736*9273SAli.Bahrami@Sun.COM 737*9273SAli.Bahrami@Sun.COM static const Msg osabi_0_3_cf[] = { 738*9273SAli.Bahrami@Sun.COM MSG_OSABI_NONE_CF, MSG_OSABI_HPUX_CF, 739*9273SAli.Bahrami@Sun.COM MSG_OSABI_NETBSD_CF, MSG_OSABI_LINUX_CF 740*9273SAli.Bahrami@Sun.COM }; 741*9273SAli.Bahrami@Sun.COM static const Msg osabi_0_3_nf[] = { 742*9273SAli.Bahrami@Sun.COM MSG_OSABI_NONE_NF, MSG_OSABI_HPUX_NF, 743*9273SAli.Bahrami@Sun.COM MSG_OSABI_NETBSD_NF, MSG_OSABI_LINUX_NF 744*9273SAli.Bahrami@Sun.COM }; 745*9273SAli.Bahrami@Sun.COM static const Msg osabi_0_3_dmp[] = { 746*9273SAli.Bahrami@Sun.COM MSG_OSABI_NONE_DMP, MSG_OSABI_HPUX_DMP, 747*9273SAli.Bahrami@Sun.COM MSG_OSABI_NETBSD_DMP, MSG_OSABI_LINUX_DMP 748*9273SAli.Bahrami@Sun.COM }; 749*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_osabi_0_3_cf = { 750*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFOSABI_NONE, osabi_0_3_cf) }; 751*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_osabi_0_3_nf = { 752*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFOSABI_NONE, osabi_0_3_nf) }; 753*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_osabi_0_3_dmp = { 754*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFOSABI_NONE, osabi_0_3_dmp) }; 755*9273SAli.Bahrami@Sun.COM 756*9273SAli.Bahrami@Sun.COM 757*9273SAli.Bahrami@Sun.COM static const Msg osabi_6_15_cf[] = { 758*9273SAli.Bahrami@Sun.COM MSG_OSABI_SOLARIS_CF, MSG_OSABI_AIX_CF, 759*9273SAli.Bahrami@Sun.COM MSG_OSABI_IRIX_CF, MSG_OSABI_FREEBSD_CF, 760*9273SAli.Bahrami@Sun.COM MSG_OSABI_TRU64_CF, MSG_OSABI_MODESTO_CF, 761*9273SAli.Bahrami@Sun.COM MSG_OSABI_OPENBSD_CF, MSG_OSABI_OPENVMS_CF, 762*9273SAli.Bahrami@Sun.COM MSG_OSABI_NSK_CF, MSG_OSABI_AROS_CF 763*9273SAli.Bahrami@Sun.COM }; 764*9273SAli.Bahrami@Sun.COM static const Msg osabi_6_15_nf[] = { 765*9273SAli.Bahrami@Sun.COM MSG_OSABI_SOLARIS_NF, MSG_OSABI_AIX_NF, 766*9273SAli.Bahrami@Sun.COM MSG_OSABI_IRIX_NF, MSG_OSABI_FREEBSD_NF, 767*9273SAli.Bahrami@Sun.COM MSG_OSABI_TRU64_NF, MSG_OSABI_MODESTO_NF, 768*9273SAli.Bahrami@Sun.COM MSG_OSABI_OPENBSD_NF, MSG_OSABI_OPENVMS_NF, 769*9273SAli.Bahrami@Sun.COM MSG_OSABI_NSK_NF, MSG_OSABI_AROS_NF 770*9273SAli.Bahrami@Sun.COM }; 771*9273SAli.Bahrami@Sun.COM static const Msg osabi_6_15_dmp[] = { 772*9273SAli.Bahrami@Sun.COM MSG_OSABI_SOLARIS_DMP, MSG_OSABI_AIX_DMP, 773*9273SAli.Bahrami@Sun.COM MSG_OSABI_IRIX_DMP, MSG_OSABI_FREEBSD_DMP, 774*9273SAli.Bahrami@Sun.COM MSG_OSABI_TRU64_DMP, MSG_OSABI_MODESTO_DMP, 775*9273SAli.Bahrami@Sun.COM MSG_OSABI_OPENBSD_DMP, MSG_OSABI_OPENVMS_DMP, 776*9273SAli.Bahrami@Sun.COM MSG_OSABI_NSK_DMP, MSG_OSABI_AROS_DMP 777*9273SAli.Bahrami@Sun.COM }; 778*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_osabi_6_15_cf = { 779*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFOSABI_SOLARIS, osabi_6_15_cf) }; 780*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_osabi_6_15_nf = { 781*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFOSABI_SOLARIS, osabi_6_15_nf) }; 782*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_osabi_6_15_dmp = { 783*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(ELFOSABI_SOLARIS, osabi_6_15_dmp) }; 784*9273SAli.Bahrami@Sun.COM 785*9273SAli.Bahrami@Sun.COM 786*9273SAli.Bahrami@Sun.COM static const Val_desc osabi_misc_cf[] = { 787*9273SAli.Bahrami@Sun.COM { ELFOSABI_ARM, MSG_OSABI_ARM_CF }, 788*9273SAli.Bahrami@Sun.COM { ELFOSABI_STANDALONE, MSG_OSABI_STANDALONE_CF }, 789*9273SAli.Bahrami@Sun.COM { 0 } 790*9273SAli.Bahrami@Sun.COM }; 791*9273SAli.Bahrami@Sun.COM static const Val_desc osabi_misc_nf[] = { 792*9273SAli.Bahrami@Sun.COM { ELFOSABI_ARM, MSG_OSABI_ARM_NF }, 793*9273SAli.Bahrami@Sun.COM { ELFOSABI_STANDALONE, MSG_OSABI_STANDALONE_NF }, 794*9273SAli.Bahrami@Sun.COM { 0 } 795*9273SAli.Bahrami@Sun.COM }; 796*9273SAli.Bahrami@Sun.COM static const Val_desc osabi_misc_dmp[] = { 797*9273SAli.Bahrami@Sun.COM { ELFOSABI_ARM, MSG_OSABI_ARM_DMP }, 798*9273SAli.Bahrami@Sun.COM { ELFOSABI_STANDALONE, MSG_OSABI_STANDALONE_DMP }, 799*9273SAli.Bahrami@Sun.COM { 0 } 800*9273SAli.Bahrami@Sun.COM }; 801*9273SAli.Bahrami@Sun.COM static const conv_ds_vd_t ds_osabi_misc_cf = { 802*9273SAli.Bahrami@Sun.COM CONV_DS_VD, ELFOSABI_ARM, ELFOSABI_STANDALONE, osabi_misc_cf }; 803*9273SAli.Bahrami@Sun.COM static const conv_ds_vd_t ds_osabi_misc_nf = { 804*9273SAli.Bahrami@Sun.COM CONV_DS_VD, ELFOSABI_ARM, ELFOSABI_STANDALONE, osabi_misc_nf }; 805*9273SAli.Bahrami@Sun.COM static const conv_ds_vd_t ds_osabi_misc_dmp = { 806*9273SAli.Bahrami@Sun.COM CONV_DS_VD, ELFOSABI_ARM, ELFOSABI_STANDALONE, osabi_misc_dmp }; 807*9273SAli.Bahrami@Sun.COM 808*9273SAli.Bahrami@Sun.COM /* Build NULL terminated return arrays for each string style */ 809*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_cf[] = { 810*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_osabi_0_3_cf), CONV_DS_ADDR(ds_osabi_6_15_cf), 811*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_osabi_misc_cf), NULL }; 812*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_nf[] = { 813*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_osabi_0_3_nf), CONV_DS_ADDR(ds_osabi_6_15_nf), 814*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_osabi_misc_nf), NULL }; 815*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_dmp[] = { 816*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_osabi_0_3_dmp), CONV_DS_ADDR(ds_osabi_6_15_dmp), 817*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_osabi_misc_dmp), NULL }; 818*9273SAli.Bahrami@Sun.COM 819*9273SAli.Bahrami@Sun.COM /* Select the strings to use */ 820*9273SAli.Bahrami@Sun.COM switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 821*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_DUMP: 822*9273SAli.Bahrami@Sun.COM return (ds_dmp); 823*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 824*9273SAli.Bahrami@Sun.COM return (ds_nf); 825*9273SAli.Bahrami@Sun.COM } 826*9273SAli.Bahrami@Sun.COM 827*9273SAli.Bahrami@Sun.COM return (ds_cf); 8280Sstevel@tonic-gate } 8290Sstevel@tonic-gate 8300Sstevel@tonic-gate /* 8313850Sab196087 * Make a string representation of the e_ident[EI_OSABI] field. 8323850Sab196087 */ 8333850Sab196087 const char * 8345088Sab196087 conv_ehdr_osabi(uchar_t osabi, Conv_fmt_flags_t fmt_flags, 8355088Sab196087 Conv_inv_buf_t *inv_buf) 8363850Sab196087 { 837*9273SAli.Bahrami@Sun.COM return (conv_map_ds(ELFOSABI_NONE, EM_NONE, osabi, 838*9273SAli.Bahrami@Sun.COM ehdr_osabi_strings(fmt_flags), fmt_flags, inv_buf)); 839*9273SAli.Bahrami@Sun.COM } 8403850Sab196087 841*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 842*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_osabi(Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, 843*9273SAli.Bahrami@Sun.COM void *uvalue) 844*9273SAli.Bahrami@Sun.COM { 845*9273SAli.Bahrami@Sun.COM if (conv_iter_ds(ELFOSABI_NONE, EM_NONE, ehdr_osabi_strings(fmt_flags), 846*9273SAli.Bahrami@Sun.COM func, uvalue) == CONV_ITER_DONE) 847*9273SAli.Bahrami@Sun.COM return (CONV_ITER_DONE); 8483850Sab196087 849*9273SAli.Bahrami@Sun.COM /* 850*9273SAli.Bahrami@Sun.COM * ELFOSABI_NONE might have been better named ELFOSABI_SYSV. For the 851*9273SAli.Bahrami@Sun.COM * CF and NF sytles, we supply that name for 0 in addition to NONE. 852*9273SAli.Bahrami@Sun.COM */ 853*9273SAli.Bahrami@Sun.COM switch (CONV_TYPE_FMT_ALT(fmt_flags)) { 854*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_CF: 855*9273SAli.Bahrami@Sun.COM return ((* func)(MSG_ORIG(MSG_OSABI_SYSV_CF), 856*9273SAli.Bahrami@Sun.COM ELFOSABI_NONE, uvalue)); 857*9273SAli.Bahrami@Sun.COM case CONV_FMT_ALT_NF: 858*9273SAli.Bahrami@Sun.COM return ((* func)(MSG_ORIG(MSG_OSABI_SYSV_NF), 859*9273SAli.Bahrami@Sun.COM ELFOSABI_NONE, uvalue)); 8603850Sab196087 } 8613850Sab196087 862*9273SAli.Bahrami@Sun.COM return (CONV_ITER_CONT); 863*9273SAli.Bahrami@Sun.COM } 864*9273SAli.Bahrami@Sun.COM 865*9273SAli.Bahrami@Sun.COM static const conv_ds_t ** 866*9273SAli.Bahrami@Sun.COM ehdr_abivers_strings(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags) 867*9273SAli.Bahrami@Sun.COM { 868*9273SAli.Bahrami@Sun.COM static const Msg abiversions_cf[] = { 869*9273SAli.Bahrami@Sun.COM MSG_EAV_SUNW_NONE_CF, MSG_EAV_SUNW_CURRENT_CF 870*9273SAli.Bahrami@Sun.COM }; 871*9273SAli.Bahrami@Sun.COM static const Msg abiversions_nf[] = { 872*9273SAli.Bahrami@Sun.COM MSG_EAV_SUNW_NONE_NF, MSG_EAV_SUNW_CURRENT_NF 873*9273SAli.Bahrami@Sun.COM }; 874*9273SAli.Bahrami@Sun.COM #if EAV_SUNW_NUM != 2 875*9273SAli.Bahrami@Sun.COM error "EAV_SUNW_NUM has grown. Update abiversions[]" 876*9273SAli.Bahrami@Sun.COM #endif 877*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_abiversions_cf = { 878*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EV_NONE, abiversions_cf) }; 879*9273SAli.Bahrami@Sun.COM static const conv_ds_msg_t ds_abiversions_nf = { 880*9273SAli.Bahrami@Sun.COM CONV_DS_MSG_INIT(EV_NONE, abiversions_nf) }; 881*9273SAli.Bahrami@Sun.COM 882*9273SAli.Bahrami@Sun.COM /* Build NULL terminated return arrays for each string style */ 883*9273SAli.Bahrami@Sun.COM static const const conv_ds_t *ds_cf[] = { 884*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_abiversions_cf), NULL }; 885*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_nf[] = { 886*9273SAli.Bahrami@Sun.COM CONV_DS_ADDR(ds_abiversions_nf), NULL }; 887*9273SAli.Bahrami@Sun.COM 888*9273SAli.Bahrami@Sun.COM /* For non-Solaris OSABI, we don't have symbolic names */ 889*9273SAli.Bahrami@Sun.COM static const conv_ds_t *ds_none[] = { NULL }; 890*9273SAli.Bahrami@Sun.COM 891*9273SAli.Bahrami@Sun.COM 892*9273SAli.Bahrami@Sun.COM /* 893*9273SAli.Bahrami@Sun.COM * Select the strings to use. This is a rare case where 894*9273SAli.Bahrami@Sun.COM * we don't treat ELFOSABI_NONE and ELFOSABI_SOLARIS 895*9273SAli.Bahrami@Sun.COM * as the same thing. We should never create a Solaris 896*9273SAli.Bahrami@Sun.COM * object tagged as ELFOSABI_NONE for which the abiversion 897*9273SAli.Bahrami@Sun.COM * is non-zero. 898*9273SAli.Bahrami@Sun.COM */ 899*9273SAli.Bahrami@Sun.COM if ((osabi == ELFOSABI_SOLARIS) || (osabi == CONV_OSABI_ALL)) 900*9273SAli.Bahrami@Sun.COM return ((CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF) ? 901*9273SAli.Bahrami@Sun.COM ds_nf : ds_cf); 902*9273SAli.Bahrami@Sun.COM 903*9273SAli.Bahrami@Sun.COM return (ds_none); 904*9273SAli.Bahrami@Sun.COM } 905*9273SAli.Bahrami@Sun.COM 906*9273SAli.Bahrami@Sun.COM const char * 907*9273SAli.Bahrami@Sun.COM conv_ehdr_abivers(uchar_t osabi, Word version, Conv_fmt_flags_t fmt_flags, 908*9273SAli.Bahrami@Sun.COM Conv_inv_buf_t *inv_buf) 909*9273SAli.Bahrami@Sun.COM { 910*9273SAli.Bahrami@Sun.COM return (conv_map_ds(osabi, EM_NONE, version, 911*9273SAli.Bahrami@Sun.COM ehdr_abivers_strings(osabi, fmt_flags), fmt_flags, inv_buf)); 912*9273SAli.Bahrami@Sun.COM } 913*9273SAli.Bahrami@Sun.COM 914*9273SAli.Bahrami@Sun.COM conv_iter_ret_t 915*9273SAli.Bahrami@Sun.COM conv_iter_ehdr_abivers(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags, 916*9273SAli.Bahrami@Sun.COM conv_iter_cb_t func, void *uvalue) 917*9273SAli.Bahrami@Sun.COM { 918*9273SAli.Bahrami@Sun.COM return (conv_iter_ds(osabi, EM_NONE, 919*9273SAli.Bahrami@Sun.COM ehdr_abivers_strings(osabi, fmt_flags), func, uvalue)); 9203850Sab196087 } 9213850Sab196087 9223850Sab196087 /* 9230Sstevel@tonic-gate * A generic means of returning additional information for a rejected file in 924*9273SAli.Bahrami@Sun.COM * terms of a string. ELFOSABI_SOLARIS is assummed. 9250Sstevel@tonic-gate */ 9260Sstevel@tonic-gate const char * 9276206Sab196087 conv_reject_desc(Rej_desc * rej, Conv_reject_desc_buf_t *reject_desc_buf, 9286206Sab196087 Half mach) 9290Sstevel@tonic-gate { 9304734Sab196087 ushort_t type = rej->rej_type; 9314734Sab196087 uint_t info = rej->rej_info; 9320Sstevel@tonic-gate 9337833SRod.Evans@Sun.COM switch (type) { 9347833SRod.Evans@Sun.COM case SGS_REJ_MACH: 9354734Sab196087 return (conv_ehdr_mach((Half)info, 0, 9364734Sab196087 &reject_desc_buf->inv_buf)); 9377833SRod.Evans@Sun.COM case SGS_REJ_CLASS: 9384734Sab196087 return (conv_ehdr_class((uchar_t)info, 0, 9394734Sab196087 &reject_desc_buf->inv_buf)); 9407833SRod.Evans@Sun.COM case SGS_REJ_DATA: 9414734Sab196087 return (conv_ehdr_data((uchar_t)info, 0, 9424734Sab196087 &reject_desc_buf->inv_buf)); 9437833SRod.Evans@Sun.COM case SGS_REJ_TYPE: 944*9273SAli.Bahrami@Sun.COM return (conv_ehdr_type(ELFOSABI_SOLARIS, (Half)info, 0, 9454734Sab196087 &reject_desc_buf->inv_buf)); 9467833SRod.Evans@Sun.COM case SGS_REJ_BADFLAG: 9477833SRod.Evans@Sun.COM case SGS_REJ_MISFLAG: 9487833SRod.Evans@Sun.COM case SGS_REJ_HAL: 9497833SRod.Evans@Sun.COM case SGS_REJ_US3: 9506206Sab196087 return (conv_ehdr_flags(mach, (Word)info, 0, 9514734Sab196087 &reject_desc_buf->flags_buf)); 9527833SRod.Evans@Sun.COM case SGS_REJ_UNKFILE: 9530Sstevel@tonic-gate return ((const char *)0); 9547833SRod.Evans@Sun.COM case SGS_REJ_STR: 9557833SRod.Evans@Sun.COM case SGS_REJ_HWCAP_1: 9567833SRod.Evans@Sun.COM case SGS_REJ_SFCAP_1: 9570Sstevel@tonic-gate if (rej->rej_str) 9580Sstevel@tonic-gate return ((const char *)rej->rej_str); 9590Sstevel@tonic-gate else 9600Sstevel@tonic-gate return (MSG_ORIG(MSG_STR_EMPTY)); 9617833SRod.Evans@Sun.COM default: 9624734Sab196087 return (conv_invalid_val(&reject_desc_buf->inv_buf, info, 9631976Sab196087 CONV_FMT_DECIMAL)); 9647833SRod.Evans@Sun.COM } 9650Sstevel@tonic-gate } 966