xref: /titanic_52/usr/src/cmd/sgs/libconv/common/phdr.c (revision 59d2069ddd7c958bf6bc689cf44c975cc4070945)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
215aefb655Srie 
227c478bd9Sstevel@tonic-gate /*
237e16fca0SAli Bahrami  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * String conversion routines for program header attributes.
297c478bd9Sstevel@tonic-gate  */
304f680cc6SAli Bahrami #include	<stdio.h>
317c478bd9Sstevel@tonic-gate #include	<string.h>
327c478bd9Sstevel@tonic-gate #include	<_conv.h>
337c478bd9Sstevel@tonic-gate #include	<phdr_msg.h>
347c478bd9Sstevel@tonic-gate 
354f680cc6SAli Bahrami static const conv_ds_t **
conv_phdr_type_strings(Conv_fmt_flags_t fmt_flags)364f680cc6SAli Bahrami conv_phdr_type_strings(Conv_fmt_flags_t fmt_flags)
377c478bd9Sstevel@tonic-gate {
384f680cc6SAli Bahrami #define	ALL	ELFOSABI_NONE, EM_NONE
394f680cc6SAli Bahrami #define	SOL	ELFOSABI_SOLARIS, EM_NONE
404f680cc6SAli Bahrami #define	LIN	ELFOSABI_LINUX, EM_NONE
414f680cc6SAli Bahrami 
424f680cc6SAli Bahrami 	static const Msg	phdrs_def[] = {
438521e5e6Srie 		MSG_PT_NULL,			MSG_PT_LOAD,
448521e5e6Srie 		MSG_PT_DYNAMIC,			MSG_PT_INTERP,
458521e5e6Srie 		MSG_PT_NOTE,			MSG_PT_SHLIB,
465aefb655Srie 		MSG_PT_PHDR,			MSG_PT_TLS
475aefb655Srie 	};
484f680cc6SAli Bahrami 	static const Msg	phdrs_dmp[] = {
494f680cc6SAli Bahrami 		MSG_PT_NULL_CFNP,		MSG_PT_LOAD_CFNP,
504f680cc6SAli Bahrami 		MSG_PT_DYNAMIC_DMP,		MSG_PT_INTERP_CFNP,
514f680cc6SAli Bahrami 		MSG_PT_NOTE_CFNP,		MSG_PT_SHLIB_CFNP,
524f680cc6SAli Bahrami 		MSG_PT_PHDR_CFNP,		MSG_PT_TLS_CFNP
534f680cc6SAli Bahrami 	};
544f680cc6SAli Bahrami 	static const Msg	phdrs_cf[] = {
554f680cc6SAli Bahrami 		MSG_PT_NULL_CF,			MSG_PT_LOAD_CF,
564f680cc6SAli Bahrami 		MSG_PT_DYNAMIC_CF,		MSG_PT_INTERP_CF,
574f680cc6SAli Bahrami 		MSG_PT_NOTE_CF,			MSG_PT_SHLIB_CF,
584f680cc6SAli Bahrami 		MSG_PT_PHDR_CF,			MSG_PT_TLS_CF
594f680cc6SAli Bahrami 	};
604f680cc6SAli Bahrami 	static const Msg	phdrs_cfnp[] = {
614f680cc6SAli Bahrami 		MSG_PT_NULL_CFNP,		MSG_PT_LOAD_CFNP,
624f680cc6SAli Bahrami 		MSG_PT_DYNAMIC_CFNP,		MSG_PT_INTERP_CFNP,
634f680cc6SAli Bahrami 		MSG_PT_NOTE_CFNP,		MSG_PT_SHLIB_CFNP,
644f680cc6SAli Bahrami 		MSG_PT_PHDR_CFNP,		MSG_PT_TLS_CFNP
654f680cc6SAli Bahrami 	};
664f680cc6SAli Bahrami 	static const Msg	phdrs_nf[] = {
674f680cc6SAli Bahrami 		MSG_PT_NULL_NF,			MSG_PT_LOAD_NF,
684f680cc6SAli Bahrami 		MSG_PT_DYNAMIC_NF,		MSG_PT_INTERP_NF,
694f680cc6SAli Bahrami 		MSG_PT_NOTE_NF,			MSG_PT_SHLIB_NF,
704f680cc6SAli Bahrami 		MSG_PT_PHDR_NF,			MSG_PT_TLS_NF
718521e5e6Srie 	};
728521e5e6Srie #if PT_NUM != (PT_TLS + 1)
738521e5e6Srie error "PT_NUM has grown. Update phdrs[]"
748521e5e6Srie #endif
754f680cc6SAli Bahrami 	static const conv_ds_msg_t ds_phdrs_def = {
764f680cc6SAli Bahrami 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_def) };
774f680cc6SAli Bahrami 	static const conv_ds_msg_t ds_phdrs_dmp = {
784f680cc6SAli Bahrami 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_dmp) };
794f680cc6SAli Bahrami 	static const conv_ds_msg_t ds_phdrs_cf = {
804f680cc6SAli Bahrami 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_cf) };
814f680cc6SAli Bahrami 	static const conv_ds_msg_t ds_phdrs_cfnp = {
824f680cc6SAli Bahrami 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_cfnp) };
834f680cc6SAli Bahrami 	static const conv_ds_msg_t ds_phdrs_nf = {
844f680cc6SAli Bahrami 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_nf) };
854f680cc6SAli Bahrami 
864f680cc6SAli Bahrami 
874f680cc6SAli Bahrami 	static const Val_desc2 phdrs_osabi_def[] = {
884f680cc6SAli Bahrami 		{ PT_SUNWBSS,		SOL,	MSG_PT_SUNWBSS },
894f680cc6SAli Bahrami 		{ PT_SUNWSTACK, 	SOL,	MSG_PT_SUNWSTACK },
904f680cc6SAli Bahrami 		{ PT_SUNWDTRACE,	SOL,	MSG_PT_SUNWDTRACE },
914f680cc6SAli Bahrami 		{ PT_SUNWCAP,		SOL,	MSG_PT_SUNWCAP },
924f680cc6SAli Bahrami 		{ PT_SUNW_UNWIND,	SOL,	MSG_PT_SUNW_UNWIND },
934f680cc6SAli Bahrami 		{ PT_SUNW_EH_FRAME,	SOL,	MSG_PT_SUNW_EH_FRAME },
944f680cc6SAli Bahrami 
954f680cc6SAli Bahrami 		{ PT_GNU_EH_FRAME,	LIN,	MSG_PT_GNU_EH_FRAME },
964f680cc6SAli Bahrami 		{ PT_GNU_STACK,		LIN,	MSG_PT_GNU_STACK },
974f680cc6SAli Bahrami 		{ PT_GNU_RELRO,		LIN,	MSG_PT_GNU_RELRO },
984f680cc6SAli Bahrami 
994f680cc6SAli Bahrami 		{ 0 }
1008521e5e6Srie 	};
1014f680cc6SAli Bahrami 	static const Val_desc2 phdrs_osabi_cf[] = {
1024f680cc6SAli Bahrami 		{ PT_SUNWBSS,		SOL,	MSG_PT_SUNWBSS_CF },
1034f680cc6SAli Bahrami 		{ PT_SUNWSTACK, 	SOL,	MSG_PT_SUNWSTACK_CF },
1044f680cc6SAli Bahrami 		{ PT_SUNWDTRACE,	SOL,	MSG_PT_SUNWDTRACE_CF },
1054f680cc6SAli Bahrami 		{ PT_SUNWCAP,		SOL,	MSG_PT_SUNWCAP_CF },
1064f680cc6SAli Bahrami 		{ PT_SUNW_UNWIND,	SOL,	MSG_PT_SUNW_UNWIND_CF },
1074f680cc6SAli Bahrami 		{ PT_SUNW_EH_FRAME,	SOL,	MSG_PT_SUNW_EH_FRAME_CF },
1084f680cc6SAli Bahrami 
1094f680cc6SAli Bahrami 		{ PT_GNU_EH_FRAME,	LIN,	MSG_PT_GNU_EH_FRAME_CF },
1104f680cc6SAli Bahrami 		{ PT_GNU_STACK,		LIN,	MSG_PT_GNU_STACK_CF },
1114f680cc6SAli Bahrami 		{ PT_GNU_RELRO,		LIN,	MSG_PT_GNU_RELRO_CF },
1124f680cc6SAli Bahrami 
1134f680cc6SAli Bahrami 		{ 0 }
1144f680cc6SAli Bahrami 	};
1154f680cc6SAli Bahrami 	static const Val_desc2 phdrs_osabi_cfnp[] = {
1164f680cc6SAli Bahrami 		{ PT_SUNWBSS,		SOL,	MSG_PT_SUNWBSS_CFNP },
1174f680cc6SAli Bahrami 		{ PT_SUNWSTACK, 	SOL,	MSG_PT_SUNWSTACK_CFNP },
1184f680cc6SAli Bahrami 		{ PT_SUNWDTRACE,	SOL,	MSG_PT_SUNWDTRACE_CFNP },
1194f680cc6SAli Bahrami 		{ PT_SUNWCAP,		SOL,	MSG_PT_SUNWCAP_CFNP },
1204f680cc6SAli Bahrami 		{ PT_SUNW_UNWIND,	SOL,	MSG_PT_SUNW_UNWIND_CFNP },
1214f680cc6SAli Bahrami 		{ PT_SUNW_EH_FRAME,	SOL,	MSG_PT_SUNW_EH_FRAME_CFNP },
1224f680cc6SAli Bahrami 
1234f680cc6SAli Bahrami 		{ PT_GNU_EH_FRAME,	LIN,	MSG_PT_GNU_EH_FRAME_CFNP },
1244f680cc6SAli Bahrami 		{ PT_GNU_STACK,		LIN,	MSG_PT_GNU_STACK_CFNP },
1254f680cc6SAli Bahrami 		{ PT_GNU_RELRO,		LIN,	MSG_PT_GNU_RELRO_CFNP },
1264f680cc6SAli Bahrami 
1274f680cc6SAli Bahrami 		{ 0 }
1284f680cc6SAli Bahrami 	};
1294f680cc6SAli Bahrami 	static const Val_desc2 phdrs_osabi_nf[] = {
1304f680cc6SAli Bahrami 		{ PT_SUNWBSS,		SOL,	MSG_PT_SUNWBSS_NF },
1314f680cc6SAli Bahrami 		{ PT_SUNWSTACK, 	SOL,	MSG_PT_SUNWSTACK_NF },
1324f680cc6SAli Bahrami 		{ PT_SUNWDTRACE,	SOL,	MSG_PT_SUNWDTRACE_NF },
1334f680cc6SAli Bahrami 		{ PT_SUNWCAP,		SOL,	MSG_PT_SUNWCAP_NF },
1344f680cc6SAli Bahrami 		{ PT_SUNW_UNWIND,	SOL,	MSG_PT_SUNW_UNWIND_NF },
1354f680cc6SAli Bahrami 		{ PT_SUNW_EH_FRAME,	SOL,	MSG_PT_SUNW_EH_FRAME_NF },
1364f680cc6SAli Bahrami 
1374f680cc6SAli Bahrami 		{ PT_GNU_EH_FRAME,	LIN,	MSG_PT_GNU_EH_FRAME_NF },
1384f680cc6SAli Bahrami 		{ PT_GNU_STACK,		LIN,	MSG_PT_GNU_STACK_NF },
1394f680cc6SAli Bahrami 		{ PT_GNU_RELRO,		LIN,	MSG_PT_GNU_RELRO_NF },
1404f680cc6SAli Bahrami 
1414f680cc6SAli Bahrami 		{ 0 }
1428521e5e6Srie 	};
1438521e5e6Srie #if PT_LOSUNW != PT_SUNWBSS
1444f680cc6SAli Bahrami #error "PT_LOSUNW has grown. Update phdrs_osabi[]"
1458521e5e6Srie #endif
1464f680cc6SAli Bahrami 	static const conv_ds_vd2_t ds_phdrs_osabi_def = {
1474f680cc6SAli Bahrami 	    CONV_DS_VD2, PT_LOOS, PT_HIOS, phdrs_osabi_def };
1484f680cc6SAli Bahrami 	static const conv_ds_vd2_t ds_phdrs_osabi_cf = {
1494f680cc6SAli Bahrami 	    CONV_DS_VD2, PT_LOOS, PT_HIOS, phdrs_osabi_cf };
1504f680cc6SAli Bahrami 	static const conv_ds_vd2_t ds_phdrs_osabi_cfnp = {
1514f680cc6SAli Bahrami 	    CONV_DS_VD2, PT_LOOS, PT_HIOS, phdrs_osabi_cfnp };
1524f680cc6SAli Bahrami 	static const conv_ds_vd2_t ds_phdrs_osabi_nf = {
1534f680cc6SAli Bahrami 	    CONV_DS_VD2, PT_LOOS, PT_HIOS, phdrs_osabi_nf };
1547c478bd9Sstevel@tonic-gate 
1554f680cc6SAli Bahrami 
1564f680cc6SAli Bahrami 	/* Build NULL terminated return arrays for each string style */
157*59d2069dSToomas Soome 	static const conv_ds_t	*ds_def[] = {
1584f680cc6SAli Bahrami 		CONV_DS_ADDR(ds_phdrs_def), CONV_DS_ADDR(ds_phdrs_osabi_def),
1594f680cc6SAli Bahrami 		NULL };
1604f680cc6SAli Bahrami 	static const conv_ds_t	*ds_dmp[] = {
1614f680cc6SAli Bahrami 		CONV_DS_ADDR(ds_phdrs_dmp), CONV_DS_ADDR(ds_phdrs_osabi_cfnp),
1624f680cc6SAli Bahrami 		NULL };
1634f680cc6SAli Bahrami 	static const conv_ds_t	*ds_cf[] = {
1644f680cc6SAli Bahrami 		CONV_DS_ADDR(ds_phdrs_cf), CONV_DS_ADDR(ds_phdrs_osabi_cf),
1654f680cc6SAli Bahrami 		NULL };
1664f680cc6SAli Bahrami 	static const conv_ds_t	*ds_cfnp[] = {
1674f680cc6SAli Bahrami 		CONV_DS_ADDR(ds_phdrs_cfnp), CONV_DS_ADDR(ds_phdrs_osabi_cfnp),
1684f680cc6SAli Bahrami 		NULL };
1694f680cc6SAli Bahrami 	static const conv_ds_t	*ds_nf[] = {
1704f680cc6SAli Bahrami 		CONV_DS_ADDR(ds_phdrs_nf), CONV_DS_ADDR(ds_phdrs_osabi_nf),
1714f680cc6SAli Bahrami 		NULL };
1724f680cc6SAli Bahrami 
1734f680cc6SAli Bahrami 	/* Select the strings to use */
174d29b2c44Sab196087 	switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
175d29b2c44Sab196087 	case CONV_FMT_ALT_DUMP:
1764f680cc6SAli Bahrami 		return (ds_dmp);
1774f680cc6SAli Bahrami 	case CONV_FMT_ALT_CF:
1784f680cc6SAli Bahrami 		return (ds_cf);
1794f680cc6SAli Bahrami 	case CONV_FMT_ALT_CFNP:
1804f680cc6SAli Bahrami 		return (ds_cfnp);
1814f680cc6SAli Bahrami 	case CONV_FMT_ALT_NF:
1824f680cc6SAli Bahrami 		return (ds_nf);
1837c478bd9Sstevel@tonic-gate 	}
1847c478bd9Sstevel@tonic-gate 
1854f680cc6SAli Bahrami 	return (ds_def);
1864f680cc6SAli Bahrami 
1874f680cc6SAli Bahrami #undef ALL
1884f680cc6SAli Bahrami #undef SOL
1894f680cc6SAli Bahrami #undef LIN
1904f680cc6SAli Bahrami }
1914f680cc6SAli Bahrami 
1924f680cc6SAli Bahrami const char *
conv_phdr_type(uchar_t osabi,Half mach,Word type,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)1934f680cc6SAli Bahrami conv_phdr_type(uchar_t osabi, Half mach, Word type, Conv_fmt_flags_t fmt_flags,
1944f680cc6SAli Bahrami     Conv_inv_buf_t *inv_buf)
1954f680cc6SAli Bahrami {
1964f680cc6SAli Bahrami 	return (conv_map_ds(osabi, mach, type,
1974f680cc6SAli Bahrami 	    conv_phdr_type_strings(fmt_flags), fmt_flags, inv_buf));
1984f680cc6SAli Bahrami }
1994f680cc6SAli Bahrami 
2004f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_phdr_type(conv_iter_osabi_t osabi,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)2014f680cc6SAli Bahrami conv_iter_phdr_type(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags,
2024f680cc6SAli Bahrami     conv_iter_cb_t func, void *uvalue)
2034f680cc6SAli Bahrami {
2044f680cc6SAli Bahrami 	return (conv_iter_ds(osabi, EM_NONE,
2054f680cc6SAli Bahrami 	    conv_phdr_type_strings(fmt_flags), func, uvalue));
2064f680cc6SAli Bahrami }
2074f680cc6SAli Bahrami 
2084f680cc6SAli Bahrami 
2094f680cc6SAli Bahrami static const Val_desc2 *
conv_phdr_flags_strings(Conv_fmt_flags_t fmt_flags)2104f680cc6SAli Bahrami conv_phdr_flags_strings(Conv_fmt_flags_t fmt_flags)
2114f680cc6SAli Bahrami {
2124f680cc6SAli Bahrami 	/* The CF style has the longest strings */
213ba4e3c84Sab196087 #define	PHDRSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
2144f680cc6SAli Bahrami 		MSG_PF_X_CF_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2154f680cc6SAli Bahrami 		MSG_PF_W_CF_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2164f680cc6SAli Bahrami 		MSG_PF_R_CF_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2174f680cc6SAli Bahrami 		MSG_PF_SUNW_FAILURE_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
218f971a346SBryan Cantrill 		MSG_PF_SUNW_KILLED_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
219f971a346SBryan Cantrill 		MSG_PF_SUNW_SIGINFO_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
220de777a60Sab196087 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
221de777a60Sab196087 
222de777a60Sab196087 	/*
223de777a60Sab196087 	 * Ensure that Conv_phdr_flags_buf_t is large enough:
224de777a60Sab196087 	 *
2254f680cc6SAli Bahrami 	 * PHDRSZ is the real minimum size of the buffer required by
2264f680cc6SAli Bahrami 	 * conv_phdr_flags(). However, Conv_phdr_flags_buf_t uses
2274f680cc6SAli Bahrami 	 * CONV_PHDR_FLAGS_BUFSIZE to set the buffer size. We do things this
2284f680cc6SAli Bahrami 	 * way because the definition of PHDRSZ uses information that is not
2294f680cc6SAli Bahrami 	 * available in the environment of other programs that include the
2304f680cc6SAli Bahrami 	 * conv.h header file.
231de777a60Sab196087 	 */
2326a074c93Sab196087 #if (CONV_PHDR_FLAGS_BUFSIZE != PHDRSZ) && !defined(__lint)
2336a074c93Sab196087 #define	REPORT_BUFSIZE PHDRSZ
2346a074c93Sab196087 #include "report_bufsize.h"
2356a074c93Sab196087 #error "CONV_PHDR_FLAGS_BUFSIZE does not match PHDRSZ"
236de777a60Sab196087 #endif
2377c478bd9Sstevel@tonic-gate 
2384f680cc6SAli Bahrami #define	ALL	ELFOSABI_NONE, EM_NONE
2394f680cc6SAli Bahrami #define	SOL	ELFOSABI_SOLARIS, EM_NONE
2404f680cc6SAli Bahrami 
2414f680cc6SAli Bahrami 	static const Val_desc2 vda_cf[] = {
2424f680cc6SAli Bahrami 		{ PF_X,			ALL,	MSG_PF_X_CF },
2434f680cc6SAli Bahrami 		{ PF_W,			ALL,	MSG_PF_W_CF },
2444f680cc6SAli Bahrami 		{ PF_R,			ALL,	MSG_PF_R_CF },
2454f680cc6SAli Bahrami 		{ PF_SUNW_FAILURE,	SOL,	MSG_PF_SUNW_FAILURE_CF },
246f971a346SBryan Cantrill 		{ PF_SUNW_KILLED,	SOL,	MSG_PF_SUNW_KILLED_CF },
247f971a346SBryan Cantrill 		{ PF_SUNW_SIGINFO,	SOL,	MSG_PF_SUNW_SIGINFO_CF },
2484f680cc6SAli Bahrami 		{ 0 }
2494f680cc6SAli Bahrami 	};
2504f680cc6SAli Bahrami 	static const Val_desc2 vda_nf[] = {
2514f680cc6SAli Bahrami 		{ PF_X,			ALL,	MSG_PF_X_NF },
2524f680cc6SAli Bahrami 		{ PF_W,			ALL,	MSG_PF_W_NF },
2534f680cc6SAli Bahrami 		{ PF_R,			ALL,	MSG_PF_R_NF },
2544f680cc6SAli Bahrami 		{ PF_SUNW_FAILURE,	SOL,	MSG_PF_SUNW_FAILURE_NF },
255f971a346SBryan Cantrill 		{ PF_SUNW_KILLED,	SOL,	MSG_PF_SUNW_KILLED_NF },
256f971a346SBryan Cantrill 		{ PF_SUNW_SIGINFO,	SOL,	MSG_PF_SUNW_SIGINFO_NF },
2574f680cc6SAli Bahrami 		{ 0 }
2584f680cc6SAli Bahrami 	};
2594f680cc6SAli Bahrami 
2604f680cc6SAli Bahrami 	return ((CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF) ?
2614f680cc6SAli Bahrami 	    vda_nf : vda_cf);
2624f680cc6SAli Bahrami 
2634f680cc6SAli Bahrami #undef ALL
2644f680cc6SAli Bahrami #undef SOL
2654f680cc6SAli Bahrami }
2664f680cc6SAli Bahrami 
2677c478bd9Sstevel@tonic-gate const char *
conv_phdr_flags(uchar_t osabi,Word flags,Conv_fmt_flags_t fmt_flags,Conv_phdr_flags_buf_t * phdr_flags_buf)2684f680cc6SAli Bahrami conv_phdr_flags(uchar_t osabi, Word flags, Conv_fmt_flags_t fmt_flags,
269d29b2c44Sab196087     Conv_phdr_flags_buf_t *phdr_flags_buf)
2707c478bd9Sstevel@tonic-gate {
271de777a60Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
2724f680cc6SAli Bahrami 	    NULL, sizeof (phdr_flags_buf->buf) };
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate 	if (flags == 0)
2757c478bd9Sstevel@tonic-gate 		return (MSG_ORIG(MSG_GBL_ZERO));
2765aefb655Srie 
277de777a60Sab196087 	conv_arg.buf = phdr_flags_buf->buf;
278ba4e3c84Sab196087 	conv_arg.oflags = conv_arg.rflags = flags;
2794f680cc6SAli Bahrami 	(void) conv_expn_field2(&conv_arg, osabi, EM_NONE,
2804f680cc6SAli Bahrami 	    conv_phdr_flags_strings(fmt_flags), fmt_flags);
2817c478bd9Sstevel@tonic-gate 
282de777a60Sab196087 	return ((const char *)phdr_flags_buf->buf);
2837c478bd9Sstevel@tonic-gate }
2844f680cc6SAli Bahrami 
2854f680cc6SAli Bahrami conv_iter_ret_t
conv_iter_phdr_flags(conv_iter_osabi_t osabi,Conv_fmt_flags_t fmt_flags,conv_iter_cb_t func,void * uvalue)2864f680cc6SAli Bahrami conv_iter_phdr_flags(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags,
2874f680cc6SAli Bahrami     conv_iter_cb_t func, void *uvalue)
2884f680cc6SAli Bahrami {
2894f680cc6SAli Bahrami 	if (conv_iter_vd2(osabi, EM_NONE,
2904f680cc6SAli Bahrami 	    conv_phdr_flags_strings(fmt_flags),
2914f680cc6SAli Bahrami 	    func, uvalue) == CONV_ITER_DONE)
2924f680cc6SAli Bahrami 		return (CONV_ITER_DONE);
2934f680cc6SAli Bahrami 
2944f680cc6SAli Bahrami 	return (CONV_ITER_CONT);
2954f680cc6SAli Bahrami }
296