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 */
2111a2bb38Srie
227c478bd9Sstevel@tonic-gate /*
23*08278a5eSRod Evans * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate * String conversion routines for section attributes.
297c478bd9Sstevel@tonic-gate */
307c478bd9Sstevel@tonic-gate #include <string.h>
317c478bd9Sstevel@tonic-gate #include <sys/param.h>
327c478bd9Sstevel@tonic-gate #include <sys/elf_SPARC.h>
337c478bd9Sstevel@tonic-gate #include <sys/elf_amd64.h>
347c478bd9Sstevel@tonic-gate #include <_conv.h>
357c478bd9Sstevel@tonic-gate #include <sections_msg.h>
367c478bd9Sstevel@tonic-gate
37c13de8f6Sab196087
384f680cc6SAli Bahrami static const conv_ds_t **
sec_type_strings(conv_iter_osabi_t osabi,Half mach,Conv_fmt_flags_t fmt_flags)394f680cc6SAli Bahrami sec_type_strings(conv_iter_osabi_t osabi, Half mach, Conv_fmt_flags_t fmt_flags)
404f680cc6SAli Bahrami {
414f680cc6SAli Bahrami /*
424f680cc6SAli Bahrami * This routine can return an array with 1 generic array, up to
434f680cc6SAli Bahrami * three osabi arrays, two machine arrays, plus the NULL termination.
444f680cc6SAli Bahrami */
454f680cc6SAli Bahrami #define MAX_RET 7
46c13de8f6Sab196087
474f680cc6SAli Bahrami static const Msg secs_def[SHT_NUM] = {
484f680cc6SAli Bahrami MSG_SHT_NULL, MSG_SHT_PROGBITS,
494f680cc6SAli Bahrami MSG_SHT_SYMTAB, MSG_SHT_STRTAB,
504f680cc6SAli Bahrami MSG_SHT_RELA, MSG_SHT_HASH,
514f680cc6SAli Bahrami MSG_SHT_DYNAMIC, MSG_SHT_NOTE,
524f680cc6SAli Bahrami MSG_SHT_NOBITS, MSG_SHT_REL,
534f680cc6SAli Bahrami MSG_SHT_SHLIB, MSG_SHT_DYNSYM,
544f680cc6SAli Bahrami MSG_SHT_UNKNOWN12, MSG_SHT_UNKNOWN13,
554f680cc6SAli Bahrami MSG_SHT_INIT_ARRAY, MSG_SHT_FINI_ARRAY,
564f680cc6SAli Bahrami MSG_SHT_PREINIT_ARRAY, MSG_SHT_GROUP,
577c478bd9Sstevel@tonic-gate MSG_SHT_SYMTAB_SHNDX
587c478bd9Sstevel@tonic-gate };
594f680cc6SAli Bahrami static const Msg secs_dmp[SHT_NUM] = {
604f680cc6SAli Bahrami MSG_SHT_NULL_DMP, MSG_SHT_PROGBITS_DMP,
614f680cc6SAli Bahrami MSG_SHT_SYMTAB_DMP, MSG_SHT_STRTAB_DMP,
624f680cc6SAli Bahrami MSG_SHT_RELA_DMP, MSG_SHT_HASH_DMP,
634f680cc6SAli Bahrami MSG_SHT_DYNAMIC_DMP, MSG_SHT_NOTE_DMP,
644f680cc6SAli Bahrami MSG_SHT_NOBITS_DMP, MSG_SHT_REL_DMP,
654f680cc6SAli Bahrami MSG_SHT_SHLIB_DMP, MSG_SHT_DYNSYM_DMP,
664f680cc6SAli Bahrami MSG_SHT_UNKNOWN12_DMP, MSG_SHT_UNKNOWN13_DMP,
674f680cc6SAli Bahrami MSG_SHT_INIT_ARRAY_DMP, MSG_SHT_FINI_ARRAY_DMP,
684f680cc6SAli Bahrami MSG_SHT_PREINIT_ARRAY_DMP, MSG_SHT_GROUP_DMP,
694f680cc6SAli Bahrami MSG_SHT_SYMTAB_SHNDX_DMP
704f680cc6SAli Bahrami };
714f680cc6SAli Bahrami static const Msg secs_cf[SHT_NUM] = {
724f680cc6SAli Bahrami MSG_SHT_NULL_CF, MSG_SHT_PROGBITS_CF,
734f680cc6SAli Bahrami MSG_SHT_SYMTAB_CF, MSG_SHT_STRTAB_CF,
744f680cc6SAli Bahrami MSG_SHT_RELA_CF, MSG_SHT_HASH_CF,
754f680cc6SAli Bahrami MSG_SHT_DYNAMIC_CF, MSG_SHT_NOTE_CF,
764f680cc6SAli Bahrami MSG_SHT_NOBITS_CF, MSG_SHT_REL_CF,
774f680cc6SAli Bahrami MSG_SHT_SHLIB_CF, MSG_SHT_DYNSYM_CF,
784f680cc6SAli Bahrami MSG_SHT_UNKNOWN12_CF, MSG_SHT_UNKNOWN13_CF,
794f680cc6SAli Bahrami MSG_SHT_INIT_ARRAY_CF, MSG_SHT_FINI_ARRAY_CF,
804f680cc6SAli Bahrami MSG_SHT_PREINIT_ARRAY_CF, MSG_SHT_GROUP_CF,
814f680cc6SAli Bahrami MSG_SHT_SYMTAB_SHNDX_CF
824f680cc6SAli Bahrami };
834f680cc6SAli Bahrami static const Msg secs_nf[SHT_NUM] = {
844f680cc6SAli Bahrami MSG_SHT_NULL_NF, MSG_SHT_PROGBITS_NF,
854f680cc6SAli Bahrami MSG_SHT_SYMTAB_NF, MSG_SHT_STRTAB_NF,
864f680cc6SAli Bahrami MSG_SHT_RELA_NF, MSG_SHT_HASH_NF,
874f680cc6SAli Bahrami MSG_SHT_DYNAMIC_NF, MSG_SHT_NOTE_NF,
884f680cc6SAli Bahrami MSG_SHT_NOBITS_NF, MSG_SHT_REL_NF,
894f680cc6SAli Bahrami MSG_SHT_SHLIB_NF, MSG_SHT_DYNSYM_NF,
904f680cc6SAli Bahrami MSG_SHT_UNKNOWN12_NF, MSG_SHT_UNKNOWN13_NF,
914f680cc6SAli Bahrami MSG_SHT_INIT_ARRAY_NF, MSG_SHT_FINI_ARRAY_NF,
924f680cc6SAli Bahrami MSG_SHT_PREINIT_ARRAY_NF, MSG_SHT_GROUP_NF,
934f680cc6SAli Bahrami MSG_SHT_SYMTAB_SHNDX_NF
94c13de8f6Sab196087 };
957c478bd9Sstevel@tonic-gate #if (SHT_NUM != (SHT_SYMTAB_SHNDX + 1))
967c478bd9Sstevel@tonic-gate #error "SHT_NUM has grown"
977c478bd9Sstevel@tonic-gate #endif
984f680cc6SAli Bahrami static const conv_ds_msg_t ds_secs_def = {
994f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_NULL, secs_def) };
1004f680cc6SAli Bahrami static const conv_ds_msg_t ds_secs_dmp = {
1014f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_NULL, secs_dmp) };
1024f680cc6SAli Bahrami static const conv_ds_msg_t ds_secs_cf = {
1034f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_NULL, secs_cf) };
1044f680cc6SAli Bahrami static const conv_ds_msg_t ds_secs_nf = {
1054f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_NULL, secs_nf) };
1067c478bd9Sstevel@tonic-gate
1074f680cc6SAli Bahrami
1084f680cc6SAli Bahrami static const Msg usecs_def[SHT_HISUNW - SHT_LOSUNW + 1] = {
109*08278a5eSRod Evans MSG_SHT_SUNW_CAPCHAIN, MSG_SHT_SUNW_CAPINFO,
1104f680cc6SAli Bahrami MSG_SHT_SUNW_SYMSORT, MSG_SHT_SUNW_TLSSORT,
1114f680cc6SAli Bahrami MSG_SHT_SUNW_LDYNSYM, MSG_SHT_SUNW_DOF,
1124f680cc6SAli Bahrami MSG_SHT_SUNW_CAP, MSG_SHT_SUNW_SIGNATURE,
1139039eeafSab196087 MSG_SHT_SUNW_ANNOTATE, MSG_SHT_SUNW_DEBUGSTR,
1144f680cc6SAli Bahrami MSG_SHT_SUNW_DEBUG, MSG_SHT_SUNW_MOVE,
1154f680cc6SAli Bahrami MSG_SHT_SUNW_COMDAT, MSG_SHT_SUNW_SYMINFO,
1164f680cc6SAli Bahrami MSG_SHT_SUNW_VERDEF, MSG_SHT_SUNW_VERNEED,
1174f680cc6SAli Bahrami MSG_SHT_SUNW_VERSYM
118c13de8f6Sab196087 };
1194f680cc6SAli Bahrami static const Msg usecs_dmp[SHT_HISUNW - SHT_LOSUNW + 1] = {
120*08278a5eSRod Evans MSG_SHT_SUNW_CAPCHAIN_DMP, MSG_SHT_SUNW_CAPINFO_DMP,
1214f680cc6SAli Bahrami MSG_SHT_SUNW_SYMSORT_DMP, MSG_SHT_SUNW_TLSSORT_DMP,
1224f680cc6SAli Bahrami MSG_SHT_SUNW_LDYNSYM_DMP, MSG_SHT_SUNW_DOF_DMP,
1234f680cc6SAli Bahrami MSG_SHT_SUNW_CAP_DMP, MSG_SHT_SUNW_SIGNATURE_DMP,
1244f680cc6SAli Bahrami MSG_SHT_SUNW_ANNOTATE_DMP, MSG_SHT_SUNW_DEBUGSTR_DMP,
1254f680cc6SAli Bahrami MSG_SHT_SUNW_DEBUG_DMP, MSG_SHT_SUNW_MOVE_DMP,
1264f680cc6SAli Bahrami MSG_SHT_SUNW_COMDAT_DMP, MSG_SHT_SUNW_SYMINFO_DMP,
1274f680cc6SAli Bahrami MSG_SHT_SUNW_VERDEF_DMP, MSG_SHT_SUNW_VERNEED_DMP,
1284f680cc6SAli Bahrami MSG_SHT_SUNW_VERSYM_DMP
1294f680cc6SAli Bahrami };
1304f680cc6SAli Bahrami static const Msg usecs_cf[SHT_HISUNW - SHT_LOSUNW + 1] = {
131*08278a5eSRod Evans MSG_SHT_SUNW_CAPCHAIN_CF, MSG_SHT_SUNW_CAPINFO_CF,
1324f680cc6SAli Bahrami MSG_SHT_SUNW_SYMSORT_CF, MSG_SHT_SUNW_TLSSORT_CF,
1334f680cc6SAli Bahrami MSG_SHT_SUNW_LDYNSYM_CF, MSG_SHT_SUNW_DOF_CF,
1344f680cc6SAli Bahrami MSG_SHT_SUNW_CAP_CF, MSG_SHT_SUNW_SIGNATURE_CF,
1354f680cc6SAli Bahrami MSG_SHT_SUNW_ANNOTATE_CF, MSG_SHT_SUNW_DEBUGSTR_CF,
1364f680cc6SAli Bahrami MSG_SHT_SUNW_DEBUG_CF, MSG_SHT_SUNW_MOVE_CF,
1374f680cc6SAli Bahrami MSG_SHT_SUNW_COMDAT_CF, MSG_SHT_SUNW_SYMINFO_CF,
1384f680cc6SAli Bahrami MSG_SHT_SUNW_VERDEF_CF, MSG_SHT_SUNW_VERNEED_CF,
1394f680cc6SAli Bahrami MSG_SHT_SUNW_VERSYM_CF
1404f680cc6SAli Bahrami };
1414f680cc6SAli Bahrami static const Msg usecs_nf[SHT_HISUNW - SHT_LOSUNW + 1] = {
142*08278a5eSRod Evans MSG_SHT_SUNW_CAPCHAIN_NF, MSG_SHT_SUNW_CAPINFO_NF,
1434f680cc6SAli Bahrami MSG_SHT_SUNW_SYMSORT_NF, MSG_SHT_SUNW_TLSSORT_NF,
1444f680cc6SAli Bahrami MSG_SHT_SUNW_LDYNSYM_NF, MSG_SHT_SUNW_DOF_NF,
1454f680cc6SAli Bahrami MSG_SHT_SUNW_CAP_NF, MSG_SHT_SUNW_SIGNATURE_NF,
1464f680cc6SAli Bahrami MSG_SHT_SUNW_ANNOTATE_NF, MSG_SHT_SUNW_DEBUGSTR_NF,
1474f680cc6SAli Bahrami MSG_SHT_SUNW_DEBUG_NF, MSG_SHT_SUNW_MOVE_NF,
1484f680cc6SAli Bahrami MSG_SHT_SUNW_COMDAT_NF, MSG_SHT_SUNW_SYMINFO_NF,
1494f680cc6SAli Bahrami MSG_SHT_SUNW_VERDEF_NF, MSG_SHT_SUNW_VERNEED_NF,
1504f680cc6SAli Bahrami MSG_SHT_SUNW_VERSYM_NF
1517c478bd9Sstevel@tonic-gate };
152*08278a5eSRod Evans #if (SHT_LOSUNW != SHT_SUNW_capchain)
1537c478bd9Sstevel@tonic-gate #error "SHT_LOSUNW has moved"
1547c478bd9Sstevel@tonic-gate #endif
1554f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_def = {
156*08278a5eSRod Evans CONV_DS_MSG_INIT(SHT_SUNW_capchain, usecs_def) };
1574f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_dmp = {
158*08278a5eSRod Evans CONV_DS_MSG_INIT(SHT_SUNW_capchain, usecs_dmp) };
1594f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_cf = {
160*08278a5eSRod Evans CONV_DS_MSG_INIT(SHT_SUNW_capchain, usecs_cf) };
1614f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_nf = {
162*08278a5eSRod Evans CONV_DS_MSG_INIT(SHT_SUNW_capchain, usecs_nf) };
1637c478bd9Sstevel@tonic-gate
164c13de8f6Sab196087
1654f680cc6SAli Bahrami /* The Linux osabi range has two separate sequences */
1664f680cc6SAli Bahrami static const Msg usecs_gnu1_def[] = {
1674f680cc6SAli Bahrami MSG_SHT_GNU_ATTRIBUTES, MSG_SHT_GNU_HASH,
1684f680cc6SAli Bahrami MSG_SHT_GNU_LIBLIST, MSG_SHT_CHECKSUM,
1694f680cc6SAli Bahrami };
1704f680cc6SAli Bahrami static const Msg usecs_gnu1_dmp[] = {
1714f680cc6SAli Bahrami MSG_SHT_GNU_ATTRIBUTES_DMP, MSG_SHT_GNU_HASH_DMP,
1724f680cc6SAli Bahrami MSG_SHT_GNU_LIBLIST_DMP, MSG_SHT_CHECKSUM_DMP,
1734f680cc6SAli Bahrami };
1744f680cc6SAli Bahrami static const Msg usecs_gnu1_cf[] = {
1754f680cc6SAli Bahrami MSG_SHT_GNU_ATTRIBUTES_CF, MSG_SHT_GNU_HASH_CF,
1764f680cc6SAli Bahrami MSG_SHT_GNU_LIBLIST_CF, MSG_SHT_CHECKSUM_CF,
1774f680cc6SAli Bahrami };
1784f680cc6SAli Bahrami static const Msg usecs_gnu1_nf[] = {
1794f680cc6SAli Bahrami MSG_SHT_GNU_ATTRIBUTES_NF, MSG_SHT_GNU_HASH_NF,
1804f680cc6SAli Bahrami MSG_SHT_GNU_LIBLIST_NF, MSG_SHT_CHECKSUM_NF,
1814f680cc6SAli Bahrami };
1824f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_gnu1_def = {
1834f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_GNU_ATTRIBUTES, usecs_gnu1_def) };
1844f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_gnu1_dmp = {
1854f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_GNU_ATTRIBUTES, usecs_gnu1_dmp) };
1864f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_gnu1_cf = {
1874f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_GNU_ATTRIBUTES, usecs_gnu1_cf) };
1884f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_gnu1_nf = {
1894f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_GNU_ATTRIBUTES, usecs_gnu1_nf) };
1904f680cc6SAli Bahrami
1914f680cc6SAli Bahrami
1924f680cc6SAli Bahrami static const Msg usecs_gnu2_def[] = {
1934f680cc6SAli Bahrami MSG_SHT_GNU_VERDEF, MSG_SHT_GNU_VERNEED,
1944f680cc6SAli Bahrami MSG_SHT_GNU_VERSYM
1954f680cc6SAli Bahrami };
1964f680cc6SAli Bahrami static const Msg usecs_gnu2_dmp[] = {
1974f680cc6SAli Bahrami MSG_SHT_GNU_VERDEF_DMP, MSG_SHT_GNU_VERNEED_DMP,
1984f680cc6SAli Bahrami MSG_SHT_GNU_VERSYM_DMP
1994f680cc6SAli Bahrami };
2004f680cc6SAli Bahrami static const Msg usecs_gnu2_cf[] = {
2014f680cc6SAli Bahrami MSG_SHT_GNU_VERDEF_CF, MSG_SHT_GNU_VERNEED_CF,
2024f680cc6SAli Bahrami MSG_SHT_GNU_VERSYM_CF
2034f680cc6SAli Bahrami };
2044f680cc6SAli Bahrami static const Msg usecs_gnu2_nf[] = {
2054f680cc6SAli Bahrami MSG_SHT_GNU_VERDEF_NF, MSG_SHT_GNU_VERNEED_NF,
2064f680cc6SAli Bahrami MSG_SHT_GNU_VERSYM_NF
2074f680cc6SAli Bahrami };
2084f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_gnu2_def = {
2094f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_GNU_verdef, usecs_gnu2_def) };
2104f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_gnu2_dmp = {
2114f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_GNU_verdef, usecs_gnu2_dmp) };
2124f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_gnu2_cf = {
2134f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_GNU_verdef, usecs_gnu2_cf) };
2144f680cc6SAli Bahrami static const conv_ds_msg_t ds_usecs_gnu2_nf = {
2154f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_GNU_verdef, usecs_gnu2_nf) };
2164f680cc6SAli Bahrami
2174f680cc6SAli Bahrami
2184f680cc6SAli Bahrami /* sparc processor range */
2194f680cc6SAli Bahrami static const Msg sparc_def[] = { MSG_SHT_SPARC_GOTDATA };
2204f680cc6SAli Bahrami static const Msg sparc_dmp[] = { MSG_SHT_SPARC_GOTDATA_DMP };
2214f680cc6SAli Bahrami static const Msg sparc_cf[] = { MSG_SHT_SPARC_GOTDATA_CF };
2224f680cc6SAli Bahrami static const Msg sparc_nf[] = { MSG_SHT_SPARC_GOTDATA_NF };
2234f680cc6SAli Bahrami static const conv_ds_msg_t ds_sparc_def = {
2244f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_SPARC_GOTDATA, sparc_def) };
2254f680cc6SAli Bahrami static const conv_ds_msg_t ds_sparc_dmp = {
2264f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_SPARC_GOTDATA, sparc_dmp) };
2274f680cc6SAli Bahrami static const conv_ds_msg_t ds_sparc_cf = {
2284f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_SPARC_GOTDATA, sparc_cf) };
2294f680cc6SAli Bahrami static const conv_ds_msg_t ds_sparc_nf = {
2304f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_SPARC_GOTDATA, sparc_nf) };
2314f680cc6SAli Bahrami
2324f680cc6SAli Bahrami /* amd64 processor range */
2334f680cc6SAli Bahrami static const Msg amd64_def[] = { MSG_SHT_AMD64_UNWIND };
2344f680cc6SAli Bahrami static const Msg amd64_dmp[] = { MSG_SHT_AMD64_UNWIND_DMP };
2354f680cc6SAli Bahrami static const Msg amd64_cf[] = { MSG_SHT_AMD64_UNWIND_CF };
2364f680cc6SAli Bahrami static const Msg amd64_nf[] = { MSG_SHT_AMD64_UNWIND_NF };
2374f680cc6SAli Bahrami static const conv_ds_msg_t ds_amd64_def = {
2384f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_AMD64_UNWIND, amd64_def) };
2394f680cc6SAli Bahrami static const conv_ds_msg_t ds_amd64_dmp = {
2404f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_AMD64_UNWIND, amd64_dmp) };
2414f680cc6SAli Bahrami static const conv_ds_msg_t ds_amd64_cf = {
2424f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_AMD64_UNWIND, amd64_cf) };
2434f680cc6SAli Bahrami static const conv_ds_msg_t ds_amd64_nf = {
2444f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHT_AMD64_UNWIND, amd64_nf) };
2454f680cc6SAli Bahrami
2464f680cc6SAli Bahrami
2474f680cc6SAli Bahrami static const conv_ds_t *retarr[MAX_RET];
2484f680cc6SAli Bahrami int retndx = 0;
2494f680cc6SAli Bahrami
2504f680cc6SAli Bahrami /* Select the strings to use, based on string style and OSABI */
2514f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
2524f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
2534f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_secs_dmp);
2544f680cc6SAli Bahrami break;
2554f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
2564f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_secs_cf);
2574f680cc6SAli Bahrami break;
2584f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
2594f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_secs_nf);
2604f680cc6SAli Bahrami break;
2614f680cc6SAli Bahrami default:
2624f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_secs_def);
2634f680cc6SAli Bahrami break;
2644f680cc6SAli Bahrami }
2654f680cc6SAli Bahrami
2664f680cc6SAli Bahrami if ((osabi == ELFOSABI_NONE) || (osabi == ELFOSABI_SOLARIS) ||
2674f680cc6SAli Bahrami (osabi == CONV_OSABI_ALL)) {
2684f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
2694f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
2704f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_dmp);
2714f680cc6SAli Bahrami break;
2724f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
2734f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_cf);
2744f680cc6SAli Bahrami break;
2754f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
2764f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_nf);
2774f680cc6SAli Bahrami break;
2784f680cc6SAli Bahrami default:
2794f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_def);
2804f680cc6SAli Bahrami break;
2814f680cc6SAli Bahrami }
2824f680cc6SAli Bahrami }
2834f680cc6SAli Bahrami
2844f680cc6SAli Bahrami if ((osabi == ELFOSABI_LINUX) || (osabi == CONV_OSABI_ALL)) {
2854f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
2864f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
2874f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_gnu1_dmp);
2884f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_gnu2_dmp);
2894f680cc6SAli Bahrami break;
2904f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
2914f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_gnu1_cf);
2924f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_gnu2_cf);
2934f680cc6SAli Bahrami break;
2944f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
2954f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_gnu1_nf);
2964f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_gnu2_nf);
2974f680cc6SAli Bahrami break;
2984f680cc6SAli Bahrami default:
2994f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_gnu1_def);
3004f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_usecs_gnu2_def);
3014f680cc6SAli Bahrami break;
3024f680cc6SAli Bahrami }
3034f680cc6SAli Bahrami }
3044f680cc6SAli Bahrami
3054f680cc6SAli Bahrami if ((mach == EM_SPARC) || (mach == EM_SPARC32PLUS) ||
3064f680cc6SAli Bahrami (mach == EM_SPARCV9) || (mach == CONV_MACH_ALL)) {
3074f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
3084f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
3094f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_sparc_dmp);
3104f680cc6SAli Bahrami break;
3114f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
3124f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_sparc_cf);
3134f680cc6SAli Bahrami break;
3144f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
3154f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_sparc_nf);
3164f680cc6SAli Bahrami break;
3174f680cc6SAli Bahrami default:
3184f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_sparc_def);
3194f680cc6SAli Bahrami break;
3204f680cc6SAli Bahrami }
3214f680cc6SAli Bahrami }
3224f680cc6SAli Bahrami
3234f680cc6SAli Bahrami if ((mach == EM_AMD64) || (mach == CONV_MACH_ALL)) {
3244f680cc6SAli Bahrami switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
3254f680cc6SAli Bahrami case CONV_FMT_ALT_DUMP:
3264f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_amd64_dmp);
3274f680cc6SAli Bahrami break;
3284f680cc6SAli Bahrami case CONV_FMT_ALT_CF:
3294f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_amd64_cf);
3304f680cc6SAli Bahrami break;
3314f680cc6SAli Bahrami case CONV_FMT_ALT_NF:
3324f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_amd64_nf);
3334f680cc6SAli Bahrami break;
3344f680cc6SAli Bahrami default:
3354f680cc6SAli Bahrami retarr[retndx++] = CONV_DS_ADDR(ds_amd64_def);
3364f680cc6SAli Bahrami break;
3374f680cc6SAli Bahrami }
3384f680cc6SAli Bahrami }
3394f680cc6SAli Bahrami
3404f680cc6SAli Bahrami retarr[retndx++] = NULL;
3414f680cc6SAli Bahrami assert(retndx <= MAX_RET);
3424f680cc6SAli Bahrami return (retarr);
3434f680cc6SAli Bahrami
3444f680cc6SAli Bahrami #undef MAX_RET
3454f680cc6SAli Bahrami }
3464f680cc6SAli Bahrami
3477c478bd9Sstevel@tonic-gate const char *
conv_sec_type(uchar_t osabi,Half mach,Word sec,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)3484f680cc6SAli Bahrami conv_sec_type(uchar_t osabi, Half mach, Word sec, Conv_fmt_flags_t fmt_flags,
349d29b2c44Sab196087 Conv_inv_buf_t *inv_buf)
3507c478bd9Sstevel@tonic-gate {
3514f680cc6SAli Bahrami return (conv_map_ds(osabi, mach, sec,
3524f680cc6SAli Bahrami sec_type_strings(osabi, mach, fmt_flags), fmt_flags, inv_buf));
353c13de8f6Sab196087 }
354c13de8f6Sab196087
3554f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_sec_type(conv_iter_osabi_t osabi,Half mach,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)3564f680cc6SAli Bahrami conv_iter_sec_type(conv_iter_osabi_t osabi, Half mach,
3574f680cc6SAli Bahrami Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, void *uvalue)
3584f680cc6SAli Bahrami {
3594f680cc6SAli Bahrami return (conv_iter_ds(osabi, mach,
3604f680cc6SAli Bahrami sec_type_strings(osabi, mach, fmt_flags), func, uvalue));
3617c478bd9Sstevel@tonic-gate }
3627c478bd9Sstevel@tonic-gate
3634f680cc6SAli Bahrami
3644f680cc6SAli Bahrami /*
3654f680cc6SAli Bahrami * Special iteration routine that returns strings for all symbol table
3664f680cc6SAli Bahrami * sections.
3674f680cc6SAli Bahrami */
3684f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_sec_symtab(conv_iter_osabi_t osabi,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)3694f680cc6SAli Bahrami conv_iter_sec_symtab(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags,
3704f680cc6SAli Bahrami conv_iter_cb_t func, void *uvalue)
3714f680cc6SAli Bahrami {
3724f680cc6SAli Bahrami static const Val_desc2 symtab_cf[] = {
3734f680cc6SAli Bahrami { SHT_SYMTAB, 0, 0, MSG_SHT_SYMTAB_CF },
3744f680cc6SAli Bahrami { SHT_DYNSYM, 0, 0, MSG_SHT_DYNSYM_CF },
3754f680cc6SAli Bahrami { SHT_SUNW_LDYNSYM, ELFOSABI_SOLARIS, 0,
3764f680cc6SAli Bahrami MSG_SHT_SUNW_LDYNSYM_CF },
3774f680cc6SAli Bahrami
3784f680cc6SAli Bahrami { 0 }
3794f680cc6SAli Bahrami };
3804f680cc6SAli Bahrami static const Val_desc2 symtab_nf[] = {
3814f680cc6SAli Bahrami { SHT_SYMTAB, 0, 0, MSG_SHT_SYMTAB_NF },
3824f680cc6SAli Bahrami { SHT_DYNSYM, 0, 0, MSG_SHT_DYNSYM_NF },
3834f680cc6SAli Bahrami { SHT_SUNW_LDYNSYM, ELFOSABI_SOLARIS, 0,
3844f680cc6SAli Bahrami MSG_SHT_SUNW_LDYNSYM_NF },
3854f680cc6SAli Bahrami
3864f680cc6SAli Bahrami { 0 }
3874f680cc6SAli Bahrami };
3884f680cc6SAli Bahrami
3894f680cc6SAli Bahrami const Val_desc2 *vdp;
3904f680cc6SAli Bahrami
3914f680cc6SAli Bahrami vdp = (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF) ?
3924f680cc6SAli Bahrami symtab_nf : symtab_cf;
3934f680cc6SAli Bahrami
3944f680cc6SAli Bahrami return (conv_iter_vd2(osabi, EM_NONE, vdp, func, uvalue));
3954f680cc6SAli Bahrami }
3964f680cc6SAli Bahrami
3974f680cc6SAli Bahrami
3984f680cc6SAli Bahrami const Val_desc2 *
conv_sec_flags_strings(Conv_fmt_flags_t fmt_flags)3994f680cc6SAli Bahrami conv_sec_flags_strings(Conv_fmt_flags_t fmt_flags)
4004f680cc6SAli Bahrami {
401ba4e3c84Sab196087 #define FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
4024f680cc6SAli Bahrami MSG_SHF_WRITE_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4034f680cc6SAli Bahrami MSG_SHF_ALLOC_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4044f680cc6SAli Bahrami MSG_SHF_EXECINSTR_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4054f680cc6SAli Bahrami MSG_SHF_MERGE_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4064f680cc6SAli Bahrami MSG_SHF_STRINGS_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4074f680cc6SAli Bahrami MSG_SHF_INFO_LINK_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4084f680cc6SAli Bahrami MSG_SHF_LINK_ORDER_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4094f680cc6SAli Bahrami MSG_SHF_OS_NONCONFORMING_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4104f680cc6SAli Bahrami MSG_SHF_GROUP_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4114f680cc6SAli Bahrami MSG_SHF_TLS_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4124f680cc6SAli Bahrami MSG_SHF_EXCLUDE_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4134f680cc6SAli Bahrami MSG_SHF_ORDERED_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4144f680cc6SAli Bahrami MSG_SHF_AMD64_LARGE_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
415de777a60Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
416de777a60Sab196087
417de777a60Sab196087 /*
418de777a60Sab196087 * Ensure that Conv_sec_flags_buf_t is large enough:
419de777a60Sab196087 *
4204f680cc6SAli Bahrami * FLAGSZ is the real minimum size of the buffer required by
4214f680cc6SAli Bahrami * conv_sec_flags(). However, Conv_sec_flags_buf_t uses
4224f680cc6SAli Bahrami * CONV_SEC_FLAGS_BUFSIZE to set the buffer size. We do things this
4234f680cc6SAli Bahrami * way because the definition of FLAGSZ uses information that is not
4244f680cc6SAli Bahrami * available in the environment of other programs that include the
4254f680cc6SAli Bahrami * conv.h header file.
426de777a60Sab196087 */
4276a074c93Sab196087 #if (CONV_SEC_FLAGS_BUFSIZE != FLAGSZ) && !defined(__lint)
4286a074c93Sab196087 #define REPORT_BUFSIZE FLAGSZ
4296a074c93Sab196087 #include "report_bufsize.h"
4306a074c93Sab196087 #error "CONV_SEC_FLAGS_BUFSIZE does not match FLAGSZ"
431de777a60Sab196087 #endif
4327c478bd9Sstevel@tonic-gate
4334f680cc6SAli Bahrami #define ALL ELFOSABI_NONE, EM_NONE
4344f680cc6SAli Bahrami #define SOL ELFOSABI_SOLARIS, EM_NONE
4354f680cc6SAli Bahrami #define AMD ELFOSABI_NONE, EM_AMD64
4364f680cc6SAli Bahrami
4374f680cc6SAli Bahrami static const Val_desc2 vda_cf[] = {
4384f680cc6SAli Bahrami { SHF_WRITE, ALL, MSG_SHF_WRITE_CF },
4394f680cc6SAli Bahrami { SHF_ALLOC, ALL, MSG_SHF_ALLOC_CF },
4404f680cc6SAli Bahrami { SHF_EXECINSTR, ALL, MSG_SHF_EXECINSTR_CF },
4414f680cc6SAli Bahrami { SHF_MERGE, ALL, MSG_SHF_MERGE_CF },
4424f680cc6SAli Bahrami { SHF_STRINGS, ALL, MSG_SHF_STRINGS_CF },
4434f680cc6SAli Bahrami { SHF_INFO_LINK, ALL, MSG_SHF_INFO_LINK_CF },
4444f680cc6SAli Bahrami { SHF_LINK_ORDER, ALL, MSG_SHF_LINK_ORDER_CF },
4454f680cc6SAli Bahrami { SHF_OS_NONCONFORMING, ALL, MSG_SHF_OS_NONCONFORMING_CF },
4464f680cc6SAli Bahrami { SHF_GROUP, ALL, MSG_SHF_GROUP_CF },
4474f680cc6SAli Bahrami { SHF_TLS, ALL, MSG_SHF_TLS_CF },
4484f680cc6SAli Bahrami { SHF_EXCLUDE, SOL, MSG_SHF_EXCLUDE_CF },
4494f680cc6SAli Bahrami { SHF_ORDERED, SOL, MSG_SHF_ORDERED_CF },
4504f680cc6SAli Bahrami { SHF_AMD64_LARGE, AMD, MSG_SHF_AMD64_LARGE_CF },
4515aefb655Srie { 0, 0 }
4525aefb655Srie };
4534f680cc6SAli Bahrami static const Val_desc2 vda_nf[] = {
4544f680cc6SAli Bahrami { SHF_WRITE, ALL, MSG_SHF_WRITE_NF },
4554f680cc6SAli Bahrami { SHF_ALLOC, ALL, MSG_SHF_ALLOC_NF },
4564f680cc6SAli Bahrami { SHF_EXECINSTR, ALL, MSG_SHF_EXECINSTR_NF },
4574f680cc6SAli Bahrami { SHF_MERGE, ALL, MSG_SHF_MERGE_NF },
4584f680cc6SAli Bahrami { SHF_STRINGS, ALL, MSG_SHF_STRINGS_NF },
4594f680cc6SAli Bahrami { SHF_INFO_LINK, ALL, MSG_SHF_INFO_LINK_NF },
4604f680cc6SAli Bahrami { SHF_LINK_ORDER, ALL, MSG_SHF_LINK_ORDER_NF },
4614f680cc6SAli Bahrami { SHF_OS_NONCONFORMING, ALL, MSG_SHF_OS_NONCONFORMING_NF },
4624f680cc6SAli Bahrami { SHF_GROUP, ALL, MSG_SHF_GROUP_NF },
4634f680cc6SAli Bahrami { SHF_TLS, ALL, MSG_SHF_TLS_NF },
4644f680cc6SAli Bahrami { SHF_EXCLUDE, SOL, MSG_SHF_EXCLUDE_NF },
4654f680cc6SAli Bahrami { SHF_ORDERED, SOL, MSG_SHF_ORDERED_NF },
4664f680cc6SAli Bahrami { SHF_AMD64_LARGE, AMD, MSG_SHF_AMD64_LARGE_NF },
4674f680cc6SAli Bahrami { 0, 0 }
4684f680cc6SAli Bahrami };
4697c478bd9Sstevel@tonic-gate
4704f680cc6SAli Bahrami return ((CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF) ?
4714f680cc6SAli Bahrami vda_nf : vda_cf);
4727c478bd9Sstevel@tonic-gate
4734f680cc6SAli Bahrami #undef ALL
4744f680cc6SAli Bahrami #undef SOL
4754f680cc6SAli Bahrami #undef AMD
4767c478bd9Sstevel@tonic-gate }
4777c478bd9Sstevel@tonic-gate
4784f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_sec_flags(conv_iter_osabi_t osabi,Half mach,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)4794f680cc6SAli Bahrami conv_iter_sec_flags(conv_iter_osabi_t osabi, Half mach,
4804f680cc6SAli Bahrami Conv_fmt_flags_t fmt_flags, conv_iter_cb_t func, void *uvalue)
4817c478bd9Sstevel@tonic-gate {
4824f680cc6SAli Bahrami static const Msg amd64_alias_cf[] = { MSG_SHF_X86_64_LARGE_CF };
4834f680cc6SAli Bahrami static const conv_ds_msg_t ds_msg_amd64_alias_cf = {
4844f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHF_X86_64_LARGE, amd64_alias_cf) };
4854f680cc6SAli Bahrami static const conv_ds_t *ds_amd64_alias_cf[] = {
4864f680cc6SAli Bahrami CONV_DS_ADDR(ds_msg_amd64_alias_cf), NULL };
4874f680cc6SAli Bahrami
4884f680cc6SAli Bahrami static const Msg amd64_alias_nf[] = { MSG_SHF_X86_64_LARGE_NF };
4894f680cc6SAli Bahrami static const conv_ds_msg_t ds_msg_amd64_alias_nf = {
4904f680cc6SAli Bahrami CONV_DS_MSG_INIT(SHF_X86_64_LARGE, amd64_alias_nf) };
4914f680cc6SAli Bahrami static const conv_ds_t *ds_amd64_alias_nf[] = {
4924f680cc6SAli Bahrami CONV_DS_ADDR(ds_msg_amd64_alias_nf), NULL };
4934f680cc6SAli Bahrami
4944f680cc6SAli Bahrami
4954f680cc6SAli Bahrami if (conv_iter_vd2(osabi, mach, conv_sec_flags_strings(fmt_flags),
4964f680cc6SAli Bahrami func, uvalue) == CONV_ITER_DONE)
4974f680cc6SAli Bahrami return (CONV_ITER_DONE);
4984f680cc6SAli Bahrami
4994f680cc6SAli Bahrami /* SHF_AMD64_LARGE is also known as SHF_X86_64_LARGE */
5004f680cc6SAli Bahrami if (mach == EM_AMD64) {
5014f680cc6SAli Bahrami const conv_ds_t **ds;
5024f680cc6SAli Bahrami
5034f680cc6SAli Bahrami ds = (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF) ?
5044f680cc6SAli Bahrami ds_amd64_alias_nf : ds_amd64_alias_cf;
5054f680cc6SAli Bahrami
5064f680cc6SAli Bahrami return (conv_iter_ds(ELFOSABI_NONE, mach, ds, func, uvalue));
5077c478bd9Sstevel@tonic-gate }
508de777a60Sab196087
5094f680cc6SAli Bahrami return (CONV_ITER_CONT);
5107c478bd9Sstevel@tonic-gate }
511