xref: /onnv-gate/usr/src/cmd/sgs/libconv/common/phdr.c (revision 9273:9a0603d78ad3)
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 /*
239085SAli.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 program header attributes.
290Sstevel@tonic-gate  */
30*9273SAli.Bahrami@Sun.COM #include	<stdio.h>
310Sstevel@tonic-gate #include	<string.h>
320Sstevel@tonic-gate #include	<_conv.h>
330Sstevel@tonic-gate #include	<phdr_msg.h>
340Sstevel@tonic-gate 
35*9273SAli.Bahrami@Sun.COM static const conv_ds_t **
conv_phdr_type_strings(Conv_fmt_flags_t fmt_flags)36*9273SAli.Bahrami@Sun.COM conv_phdr_type_strings(Conv_fmt_flags_t fmt_flags)
370Sstevel@tonic-gate {
38*9273SAli.Bahrami@Sun.COM #define	ALL	ELFOSABI_NONE, EM_NONE
39*9273SAli.Bahrami@Sun.COM #define	SOL	ELFOSABI_SOLARIS, EM_NONE
40*9273SAli.Bahrami@Sun.COM #define	LIN	ELFOSABI_LINUX, EM_NONE
41*9273SAli.Bahrami@Sun.COM 
42*9273SAli.Bahrami@Sun.COM 	static const Msg	phdrs_def[] = {
43*9273SAli.Bahrami@Sun.COM 		MSG_PT_NULL,			MSG_PT_LOAD,
44*9273SAli.Bahrami@Sun.COM 		MSG_PT_DYNAMIC,			MSG_PT_INTERP,
45*9273SAli.Bahrami@Sun.COM 		MSG_PT_NOTE,			MSG_PT_SHLIB,
46*9273SAli.Bahrami@Sun.COM 		MSG_PT_PHDR,			MSG_PT_TLS
47*9273SAli.Bahrami@Sun.COM 	};
48*9273SAli.Bahrami@Sun.COM 	static const Msg	phdrs_dmp[] = {
49*9273SAli.Bahrami@Sun.COM 		MSG_PT_NULL_CFNP,		MSG_PT_LOAD_CFNP,
50*9273SAli.Bahrami@Sun.COM 		MSG_PT_DYNAMIC_DMP,		MSG_PT_INTERP_CFNP,
51*9273SAli.Bahrami@Sun.COM 		MSG_PT_NOTE_CFNP,		MSG_PT_SHLIB_CFNP,
52*9273SAli.Bahrami@Sun.COM 		MSG_PT_PHDR_CFNP,		MSG_PT_TLS_CFNP
531618Srie 	};
54*9273SAli.Bahrami@Sun.COM 	static const Msg	phdrs_cf[] = {
55*9273SAli.Bahrami@Sun.COM 		MSG_PT_NULL_CF,			MSG_PT_LOAD_CF,
56*9273SAli.Bahrami@Sun.COM 		MSG_PT_DYNAMIC_CF,		MSG_PT_INTERP_CF,
57*9273SAli.Bahrami@Sun.COM 		MSG_PT_NOTE_CF,			MSG_PT_SHLIB_CF,
58*9273SAli.Bahrami@Sun.COM 		MSG_PT_PHDR_CF,			MSG_PT_TLS_CF
59*9273SAli.Bahrami@Sun.COM 	};
60*9273SAli.Bahrami@Sun.COM 	static const Msg	phdrs_cfnp[] = {
61*9273SAli.Bahrami@Sun.COM 		MSG_PT_NULL_CFNP,		MSG_PT_LOAD_CFNP,
62*9273SAli.Bahrami@Sun.COM 		MSG_PT_DYNAMIC_CFNP,		MSG_PT_INTERP_CFNP,
63*9273SAli.Bahrami@Sun.COM 		MSG_PT_NOTE_CFNP,		MSG_PT_SHLIB_CFNP,
64*9273SAli.Bahrami@Sun.COM 		MSG_PT_PHDR_CFNP,		MSG_PT_TLS_CFNP
65*9273SAli.Bahrami@Sun.COM 	};
66*9273SAli.Bahrami@Sun.COM 	static const Msg	phdrs_nf[] = {
67*9273SAli.Bahrami@Sun.COM 		MSG_PT_NULL_NF,			MSG_PT_LOAD_NF,
68*9273SAli.Bahrami@Sun.COM 		MSG_PT_DYNAMIC_NF,		MSG_PT_INTERP_NF,
69*9273SAli.Bahrami@Sun.COM 		MSG_PT_NOTE_NF,			MSG_PT_SHLIB_NF,
70*9273SAli.Bahrami@Sun.COM 		MSG_PT_PHDR_NF,			MSG_PT_TLS_NF
714031Srie 	};
724031Srie #if PT_NUM != (PT_TLS + 1)
734031Srie error "PT_NUM has grown. Update phdrs[]"
744031Srie #endif
75*9273SAli.Bahrami@Sun.COM 	static const conv_ds_msg_t ds_phdrs_def = {
76*9273SAli.Bahrami@Sun.COM 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_def) };
77*9273SAli.Bahrami@Sun.COM 	static const conv_ds_msg_t ds_phdrs_dmp = {
78*9273SAli.Bahrami@Sun.COM 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_dmp) };
79*9273SAli.Bahrami@Sun.COM 	static const conv_ds_msg_t ds_phdrs_cf = {
80*9273SAli.Bahrami@Sun.COM 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_cf) };
81*9273SAli.Bahrami@Sun.COM 	static const conv_ds_msg_t ds_phdrs_cfnp = {
82*9273SAli.Bahrami@Sun.COM 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_cfnp) };
83*9273SAli.Bahrami@Sun.COM 	static const conv_ds_msg_t ds_phdrs_nf = {
84*9273SAli.Bahrami@Sun.COM 	    CONV_DS_MSG_INIT(PT_NULL, phdrs_nf) };
85*9273SAli.Bahrami@Sun.COM 
86*9273SAli.Bahrami@Sun.COM 
87*9273SAli.Bahrami@Sun.COM 	static const Val_desc2 phdrs_osabi_def[] = {
88*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWBSS,		SOL,	MSG_PT_SUNWBSS },
89*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWSTACK, 	SOL,	MSG_PT_SUNWSTACK },
90*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWDTRACE,	SOL,	MSG_PT_SUNWDTRACE },
91*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWCAP,		SOL,	MSG_PT_SUNWCAP },
92*9273SAli.Bahrami@Sun.COM 		{ PT_SUNW_UNWIND,	SOL,	MSG_PT_SUNW_UNWIND },
93*9273SAli.Bahrami@Sun.COM 		{ PT_SUNW_EH_FRAME,	SOL,	MSG_PT_SUNW_EH_FRAME },
94*9273SAli.Bahrami@Sun.COM 
95*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_EH_FRAME,	LIN,	MSG_PT_GNU_EH_FRAME },
96*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_STACK,		LIN,	MSG_PT_GNU_STACK },
97*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_RELRO,		LIN,	MSG_PT_GNU_RELRO },
98*9273SAli.Bahrami@Sun.COM 
99*9273SAli.Bahrami@Sun.COM 		{ 0 }
1004031Srie 	};
101*9273SAli.Bahrami@Sun.COM 	static const Val_desc2 phdrs_osabi_cf[] = {
102*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWBSS,		SOL,	MSG_PT_SUNWBSS_CF },
103*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWSTACK, 	SOL,	MSG_PT_SUNWSTACK_CF },
104*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWDTRACE,	SOL,	MSG_PT_SUNWDTRACE_CF },
105*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWCAP,		SOL,	MSG_PT_SUNWCAP_CF },
106*9273SAli.Bahrami@Sun.COM 		{ PT_SUNW_UNWIND,	SOL,	MSG_PT_SUNW_UNWIND_CF },
107*9273SAli.Bahrami@Sun.COM 		{ PT_SUNW_EH_FRAME,	SOL,	MSG_PT_SUNW_EH_FRAME_CF },
108*9273SAli.Bahrami@Sun.COM 
109*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_EH_FRAME,	LIN,	MSG_PT_GNU_EH_FRAME_CF },
110*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_STACK,		LIN,	MSG_PT_GNU_STACK_CF },
111*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_RELRO,		LIN,	MSG_PT_GNU_RELRO_CF },
112*9273SAli.Bahrami@Sun.COM 
113*9273SAli.Bahrami@Sun.COM 		{ 0 }
114*9273SAli.Bahrami@Sun.COM 	};
115*9273SAli.Bahrami@Sun.COM 	static const Val_desc2 phdrs_osabi_cfnp[] = {
116*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWBSS,		SOL,	MSG_PT_SUNWBSS_CFNP },
117*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWSTACK, 	SOL,	MSG_PT_SUNWSTACK_CFNP },
118*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWDTRACE,	SOL,	MSG_PT_SUNWDTRACE_CFNP },
119*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWCAP,		SOL,	MSG_PT_SUNWCAP_CFNP },
120*9273SAli.Bahrami@Sun.COM 		{ PT_SUNW_UNWIND,	SOL,	MSG_PT_SUNW_UNWIND_CFNP },
121*9273SAli.Bahrami@Sun.COM 		{ PT_SUNW_EH_FRAME,	SOL,	MSG_PT_SUNW_EH_FRAME_CFNP },
122*9273SAli.Bahrami@Sun.COM 
123*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_EH_FRAME,	LIN,	MSG_PT_GNU_EH_FRAME_CFNP },
124*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_STACK,		LIN,	MSG_PT_GNU_STACK_CFNP },
125*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_RELRO,		LIN,	MSG_PT_GNU_RELRO_CFNP },
126*9273SAli.Bahrami@Sun.COM 
127*9273SAli.Bahrami@Sun.COM 		{ 0 }
128*9273SAli.Bahrami@Sun.COM 	};
129*9273SAli.Bahrami@Sun.COM 	static const Val_desc2 phdrs_osabi_nf[] = {
130*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWBSS,		SOL,	MSG_PT_SUNWBSS_NF },
131*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWSTACK, 	SOL,	MSG_PT_SUNWSTACK_NF },
132*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWDTRACE,	SOL,	MSG_PT_SUNWDTRACE_NF },
133*9273SAli.Bahrami@Sun.COM 		{ PT_SUNWCAP,		SOL,	MSG_PT_SUNWCAP_NF },
134*9273SAli.Bahrami@Sun.COM 		{ PT_SUNW_UNWIND,	SOL,	MSG_PT_SUNW_UNWIND_NF },
135*9273SAli.Bahrami@Sun.COM 		{ PT_SUNW_EH_FRAME,	SOL,	MSG_PT_SUNW_EH_FRAME_NF },
136*9273SAli.Bahrami@Sun.COM 
137*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_EH_FRAME,	LIN,	MSG_PT_GNU_EH_FRAME_NF },
138*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_STACK,		LIN,	MSG_PT_GNU_STACK_NF },
139*9273SAli.Bahrami@Sun.COM 		{ PT_GNU_RELRO,		LIN,	MSG_PT_GNU_RELRO_NF },
140*9273SAli.Bahrami@Sun.COM 
141*9273SAli.Bahrami@Sun.COM 		{ 0 }
1424031Srie 	};
1434031Srie #if PT_LOSUNW != PT_SUNWBSS
144*9273SAli.Bahrami@Sun.COM #error "PT_LOSUNW has grown. Update phdrs_osabi[]"
1454031Srie #endif
146*9273SAli.Bahrami@Sun.COM 	static const conv_ds_vd2_t ds_phdrs_osabi_def = {
147*9273SAli.Bahrami@Sun.COM 	    CONV_DS_VD2, PT_LOOS, PT_HIOS, phdrs_osabi_def };
148*9273SAli.Bahrami@Sun.COM 	static const conv_ds_vd2_t ds_phdrs_osabi_cf = {
149*9273SAli.Bahrami@Sun.COM 	    CONV_DS_VD2, PT_LOOS, PT_HIOS, phdrs_osabi_cf };
150*9273SAli.Bahrami@Sun.COM 	static const conv_ds_vd2_t ds_phdrs_osabi_cfnp = {
151*9273SAli.Bahrami@Sun.COM 	    CONV_DS_VD2, PT_LOOS, PT_HIOS, phdrs_osabi_cfnp };
152*9273SAli.Bahrami@Sun.COM 	static const conv_ds_vd2_t ds_phdrs_osabi_nf = {
153*9273SAli.Bahrami@Sun.COM 	    CONV_DS_VD2, PT_LOOS, PT_HIOS, phdrs_osabi_nf };
154*9273SAli.Bahrami@Sun.COM 
1550Sstevel@tonic-gate 
156*9273SAli.Bahrami@Sun.COM 	/* Build NULL terminated return arrays for each string style */
157*9273SAli.Bahrami@Sun.COM 	static const const conv_ds_t	*ds_def[] = {
158*9273SAli.Bahrami@Sun.COM 		CONV_DS_ADDR(ds_phdrs_def), CONV_DS_ADDR(ds_phdrs_osabi_def),
159*9273SAli.Bahrami@Sun.COM 		NULL };
160*9273SAli.Bahrami@Sun.COM 	static const conv_ds_t	*ds_dmp[] = {
161*9273SAli.Bahrami@Sun.COM 		CONV_DS_ADDR(ds_phdrs_dmp), CONV_DS_ADDR(ds_phdrs_osabi_cfnp),
162*9273SAli.Bahrami@Sun.COM 		NULL };
163*9273SAli.Bahrami@Sun.COM 	static const conv_ds_t	*ds_cf[] = {
164*9273SAli.Bahrami@Sun.COM 		CONV_DS_ADDR(ds_phdrs_cf), CONV_DS_ADDR(ds_phdrs_osabi_cf),
165*9273SAli.Bahrami@Sun.COM 		NULL };
166*9273SAli.Bahrami@Sun.COM 	static const conv_ds_t	*ds_cfnp[] = {
167*9273SAli.Bahrami@Sun.COM 		CONV_DS_ADDR(ds_phdrs_cfnp), CONV_DS_ADDR(ds_phdrs_osabi_cfnp),
168*9273SAli.Bahrami@Sun.COM 		NULL };
169*9273SAli.Bahrami@Sun.COM 	static const conv_ds_t	*ds_nf[] = {
170*9273SAli.Bahrami@Sun.COM 		CONV_DS_ADDR(ds_phdrs_nf), CONV_DS_ADDR(ds_phdrs_osabi_nf),
171*9273SAli.Bahrami@Sun.COM 		NULL };
172*9273SAli.Bahrami@Sun.COM 
173*9273SAli.Bahrami@Sun.COM 	/* Select the strings to use */
174*9273SAli.Bahrami@Sun.COM 	switch (CONV_TYPE_FMT_ALT(fmt_flags)) {
175*9273SAli.Bahrami@Sun.COM 	case CONV_FMT_ALT_DUMP:
176*9273SAli.Bahrami@Sun.COM 		return (ds_dmp);
177*9273SAli.Bahrami@Sun.COM 	case CONV_FMT_ALT_CF:
178*9273SAli.Bahrami@Sun.COM 		return (ds_cf);
179*9273SAli.Bahrami@Sun.COM 	case CONV_FMT_ALT_CFNP:
180*9273SAli.Bahrami@Sun.COM 		return (ds_cfnp);
181*9273SAli.Bahrami@Sun.COM 	case CONV_FMT_ALT_NF:
182*9273SAli.Bahrami@Sun.COM 		return (ds_nf);
183*9273SAli.Bahrami@Sun.COM 	}
184*9273SAli.Bahrami@Sun.COM 
185*9273SAli.Bahrami@Sun.COM 	return (ds_def);
186*9273SAli.Bahrami@Sun.COM 
187*9273SAli.Bahrami@Sun.COM #undef ALL
188*9273SAli.Bahrami@Sun.COM #undef SOL
189*9273SAli.Bahrami@Sun.COM #undef LIN
1900Sstevel@tonic-gate }
1910Sstevel@tonic-gate 
192*9273SAli.Bahrami@Sun.COM const char *
conv_phdr_type(uchar_t osabi,Half mach,Word type,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)193*9273SAli.Bahrami@Sun.COM conv_phdr_type(uchar_t osabi, Half mach, Word type, Conv_fmt_flags_t fmt_flags,
194*9273SAli.Bahrami@Sun.COM     Conv_inv_buf_t *inv_buf)
195*9273SAli.Bahrami@Sun.COM {
196*9273SAli.Bahrami@Sun.COM 	return (conv_map_ds(osabi, mach, type,
197*9273SAli.Bahrami@Sun.COM 	    conv_phdr_type_strings(fmt_flags), fmt_flags, inv_buf));
198*9273SAli.Bahrami@Sun.COM }
199*9273SAli.Bahrami@Sun.COM 
200*9273SAli.Bahrami@Sun.COM 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)201*9273SAli.Bahrami@Sun.COM conv_iter_phdr_type(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags,
202*9273SAli.Bahrami@Sun.COM     conv_iter_cb_t func, void *uvalue)
203*9273SAli.Bahrami@Sun.COM {
204*9273SAli.Bahrami@Sun.COM 	return (conv_iter_ds(osabi, EM_NONE,
205*9273SAli.Bahrami@Sun.COM 	    conv_phdr_type_strings(fmt_flags), func, uvalue));
206*9273SAli.Bahrami@Sun.COM }
207*9273SAli.Bahrami@Sun.COM 
208*9273SAli.Bahrami@Sun.COM 
209*9273SAli.Bahrami@Sun.COM static const Val_desc2 *
conv_phdr_flags_strings(Conv_fmt_flags_t fmt_flags)210*9273SAli.Bahrami@Sun.COM conv_phdr_flags_strings(Conv_fmt_flags_t fmt_flags)
211*9273SAli.Bahrami@Sun.COM {
212*9273SAli.Bahrami@Sun.COM 	/* The CF style has the longest strings */
2132352Sab196087 #define	PHDRSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
214*9273SAli.Bahrami@Sun.COM 		MSG_PF_X_CF_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
215*9273SAli.Bahrami@Sun.COM 		MSG_PF_W_CF_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
216*9273SAli.Bahrami@Sun.COM 		MSG_PF_R_CF_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
217*9273SAli.Bahrami@Sun.COM 		MSG_PF_SUNW_FAILURE_CF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2184734Sab196087 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
2194734Sab196087 
220*9273SAli.Bahrami@Sun.COM 	/*
221*9273SAli.Bahrami@Sun.COM 	 * Ensure that Conv_phdr_flags_buf_t is large enough:
222*9273SAli.Bahrami@Sun.COM 	 *
223*9273SAli.Bahrami@Sun.COM 	 * PHDRSZ is the real minimum size of the buffer required by
224*9273SAli.Bahrami@Sun.COM 	 * conv_phdr_flags(). However, Conv_phdr_flags_buf_t uses
225*9273SAli.Bahrami@Sun.COM 	 * CONV_PHDR_FLAGS_BUFSIZE to set the buffer size. We do things this
226*9273SAli.Bahrami@Sun.COM 	 * way because the definition of PHDRSZ uses information that is not
227*9273SAli.Bahrami@Sun.COM 	 * available in the environment of other programs that include the
228*9273SAli.Bahrami@Sun.COM 	 * conv.h header file.
229*9273SAli.Bahrami@Sun.COM 	 */
2305152Sab196087 #if (CONV_PHDR_FLAGS_BUFSIZE != PHDRSZ) && !defined(__lint)
2315152Sab196087 #define	REPORT_BUFSIZE PHDRSZ
2325152Sab196087 #include "report_bufsize.h"
2335152Sab196087 #error "CONV_PHDR_FLAGS_BUFSIZE does not match PHDRSZ"
2344734Sab196087 #endif
2350Sstevel@tonic-gate 
236*9273SAli.Bahrami@Sun.COM #define	ALL	ELFOSABI_NONE, EM_NONE
237*9273SAli.Bahrami@Sun.COM #define	SOL	ELFOSABI_SOLARIS, EM_NONE
238*9273SAli.Bahrami@Sun.COM 
239*9273SAli.Bahrami@Sun.COM 	static const Val_desc2 vda_cf[] = {
240*9273SAli.Bahrami@Sun.COM 		{ PF_X,			ALL,	MSG_PF_X_CF },
241*9273SAli.Bahrami@Sun.COM 		{ PF_W,			ALL,	MSG_PF_W_CF },
242*9273SAli.Bahrami@Sun.COM 		{ PF_R,			ALL,	MSG_PF_R_CF },
243*9273SAli.Bahrami@Sun.COM 		{ PF_SUNW_FAILURE,	SOL,	MSG_PF_SUNW_FAILURE_CF },
244*9273SAli.Bahrami@Sun.COM 		{ 0 }
245*9273SAli.Bahrami@Sun.COM 	};
246*9273SAli.Bahrami@Sun.COM 	static const Val_desc2 vda_nf[] = {
247*9273SAli.Bahrami@Sun.COM 		{ PF_X,			ALL,	MSG_PF_X_NF },
248*9273SAli.Bahrami@Sun.COM 		{ PF_W,			ALL,	MSG_PF_W_NF },
249*9273SAli.Bahrami@Sun.COM 		{ PF_R,			ALL,	MSG_PF_R_NF },
250*9273SAli.Bahrami@Sun.COM 		{ PF_SUNW_FAILURE,	SOL,	MSG_PF_SUNW_FAILURE_NF },
251*9273SAli.Bahrami@Sun.COM 		{ 0 }
252*9273SAli.Bahrami@Sun.COM 	};
253*9273SAli.Bahrami@Sun.COM 
254*9273SAli.Bahrami@Sun.COM 	return ((CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_NF) ?
255*9273SAli.Bahrami@Sun.COM 	    vda_nf : vda_cf);
256*9273SAli.Bahrami@Sun.COM 
257*9273SAli.Bahrami@Sun.COM #undef ALL
258*9273SAli.Bahrami@Sun.COM #undef SOL
259*9273SAli.Bahrami@Sun.COM }
260*9273SAli.Bahrami@Sun.COM 
2610Sstevel@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)262*9273SAli.Bahrami@Sun.COM conv_phdr_flags(uchar_t osabi, Word flags, Conv_fmt_flags_t fmt_flags,
2635088Sab196087     Conv_phdr_flags_buf_t *phdr_flags_buf)
2640Sstevel@tonic-gate {
2654734Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
266*9273SAli.Bahrami@Sun.COM 	    NULL, sizeof (phdr_flags_buf->buf) };
2670Sstevel@tonic-gate 
2680Sstevel@tonic-gate 	if (flags == 0)
2690Sstevel@tonic-gate 		return (MSG_ORIG(MSG_GBL_ZERO));
2700Sstevel@tonic-gate 
2714734Sab196087 	conv_arg.buf = phdr_flags_buf->buf;
2722352Sab196087 	conv_arg.oflags = conv_arg.rflags = flags;
273*9273SAli.Bahrami@Sun.COM 	(void) conv_expn_field2(&conv_arg, osabi, EM_NONE,
274*9273SAli.Bahrami@Sun.COM 	    conv_phdr_flags_strings(fmt_flags), fmt_flags);
2751618Srie 
2764734Sab196087 	return ((const char *)phdr_flags_buf->buf);
2770Sstevel@tonic-gate }
278*9273SAli.Bahrami@Sun.COM 
279*9273SAli.Bahrami@Sun.COM 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)280*9273SAli.Bahrami@Sun.COM conv_iter_phdr_flags(conv_iter_osabi_t osabi, Conv_fmt_flags_t fmt_flags,
281*9273SAli.Bahrami@Sun.COM     conv_iter_cb_t func, void *uvalue)
282*9273SAli.Bahrami@Sun.COM {
283*9273SAli.Bahrami@Sun.COM 	if (conv_iter_vd2(osabi, EM_NONE,
284*9273SAli.Bahrami@Sun.COM 	    conv_phdr_flags_strings(fmt_flags),
285*9273SAli.Bahrami@Sun.COM 	    func, uvalue) == CONV_ITER_DONE)
286*9273SAli.Bahrami@Sun.COM 		return (CONV_ITER_DONE);
287*9273SAli.Bahrami@Sun.COM 
288*9273SAli.Bahrami@Sun.COM 	return (CONV_ITER_CONT);
289*9273SAli.Bahrami@Sun.COM }
290