xref: /onnv-gate/usr/src/cmd/sgs/libconv/common/dynamic.c (revision 4734:a4708faa3e85)
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 /*
233466Srie  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * String conversion routine for .dynamic tag entries.
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate #include	<stdio.h>
320Sstevel@tonic-gate #include	<string.h>
330Sstevel@tonic-gate #include	<sys/elf_SPARC.h>
34280Srie #include	"rtld.h"
350Sstevel@tonic-gate #include	"_conv.h"
360Sstevel@tonic-gate #include	"dynamic_msg.h"
370Sstevel@tonic-gate 
383492Sab196087 
393492Sab196087 
403492Sab196087 /* Instantiate a local copy of conv_map2str() from _conv.h */
413492Sab196087 DEFINE_conv_map2str
423492Sab196087 
433492Sab196087 
443492Sab196087 
452352Sab196087 #define	POSSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
462352Sab196087 		MSG_DFP_LAZYLOAD_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
472352Sab196087 		MSG_DFP_GROUPPERM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
48*4734Sab196087 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
49*4734Sab196087 
50*4734Sab196087 /*
51*4734Sab196087  * Ensure that Conv_dyn_posflag1_buf_t is large enough:
52*4734Sab196087  *
53*4734Sab196087  * POSSZ is the real minimum size of the buffer required by conv_dyn_posflag1().
54*4734Sab196087  * However, Conv_dyn_posflag1_buf_t uses CONV_DYN_POSFLAG1_BUFSIZE to set the
55*4734Sab196087  * buffer size. We do things this way because the definition of POSSZ uses
56*4734Sab196087  * information that is not available in the environment of other programs
57*4734Sab196087  * that include the conv.h header file.
58*4734Sab196087  */
59*4734Sab196087 #if CONV_DYN_POSFLAG1_BUFSIZE < POSSZ
60*4734Sab196087 #error "CONV_DYN_POSFLAG1_BUFSIZE is not large enough"
61*4734Sab196087 #endif
620Sstevel@tonic-gate 
630Sstevel@tonic-gate const char *
64*4734Sab196087 conv_dyn_posflag1(Xword flags, int fmt_flags,
65*4734Sab196087     Conv_dyn_posflag1_buf_t *dyn_posflag1_buf)
660Sstevel@tonic-gate {
671618Srie 	static Val_desc vda[] = {
681618Srie 		{ DF_P1_LAZYLOAD,	MSG_ORIG(MSG_DFP_LAZYLOAD) },
691618Srie 		{ DF_P1_GROUPPERM,	MSG_ORIG(MSG_DFP_GROUPPERM) },
701618Srie 		{ 0,			0 }
711618Srie 	};
72*4734Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
73*4734Sab196087 	    NULL, sizeof (dyn_posflag1_buf->buf), vda };
742352Sab196087 	static Val_desc vda_alt[] = {
752352Sab196087 		{ DF_P1_LAZYLOAD,	MSG_ORIG(MSG_DFP_LAZYLOAD_ALT) },
762352Sab196087 		{ DF_P1_GROUPPERM,	MSG_ORIG(MSG_DFP_GROUPPERM) },
772352Sab196087 		{ 0,			0 }
782352Sab196087 	};
79*4734Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg_alt = {
80*4734Sab196087 	    NULL, sizeof (dyn_posflag1_buf->buf), vda_alt, NULL, 0, 0,
81*4734Sab196087 	    MSG_ORIG(MSG_STR_EMPTY), NULL, MSG_ORIG(MSG_STR_EMPTY) };
822352Sab196087 
832352Sab196087 	CONV_EXPN_FIELD_ARG *arg;
841618Srie 
850Sstevel@tonic-gate 	if (flags == 0)
860Sstevel@tonic-gate 		return (MSG_ORIG(MSG_GBL_ZERO));
870Sstevel@tonic-gate 
882352Sab196087 	arg = (fmt_flags & CONV_FMT_ALTDUMP) ? &conv_arg_alt : &conv_arg;
89*4734Sab196087 	arg->buf = dyn_posflag1_buf->buf;
902352Sab196087 	arg->oflags = arg->rflags = flags;
912352Sab196087 	(void) conv_expn_field(arg);
920Sstevel@tonic-gate 
93*4734Sab196087 	return ((const char *)dyn_posflag1_buf);
940Sstevel@tonic-gate }
950Sstevel@tonic-gate 
962352Sab196087 #define	FLAGSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
972352Sab196087 		MSG_DF_ORIGIN_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
982352Sab196087 		MSG_DF_SYMBOLIC_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
992352Sab196087 		MSG_DF_TEXTREL_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1002352Sab196087 		MSG_DF_BIND_NOW_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1012352Sab196087 		MSG_DF_STATIC_TLS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
102*4734Sab196087 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
103*4734Sab196087 
104*4734Sab196087 /*
105*4734Sab196087  * Ensure that Conv_dyn_flag_buf_t is large enough:
106*4734Sab196087  *
107*4734Sab196087  * FLAGSZ is the real minimum size of the buffer required by conv_dyn_flag().
108*4734Sab196087  * However, Conv_dyn_flag_buf_t uses CONV_DYN_FLAG_BUFSIZE to set the
109*4734Sab196087  * buffer size. We do things this way because the definition of FLAGSZ uses
110*4734Sab196087  * information that is not available in the environment of other programs
111*4734Sab196087  * that include the conv.h header file.
112*4734Sab196087  */
113*4734Sab196087 #if CONV_DYN_FLAG_BUFSIZE < FLAGSZ
114*4734Sab196087 #error "CONV_DYN_FLAG_BUFSIZE is not large enough"
115*4734Sab196087 #endif
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate const char *
118*4734Sab196087 conv_dyn_flag(Xword flags, int fmt_flags, Conv_dyn_flag_buf_t *dyn_flag_buf)
1190Sstevel@tonic-gate {
1201618Srie 	static Val_desc vda[] = {
1211618Srie 		{ DF_ORIGIN,		MSG_ORIG(MSG_DF_ORIGIN) },
1221618Srie 		{ DF_SYMBOLIC,		MSG_ORIG(MSG_DF_SYMBOLIC) },
1231618Srie 		{ DF_TEXTREL,		MSG_ORIG(MSG_DF_TEXTREL) },
1241618Srie 		{ DF_BIND_NOW,		MSG_ORIG(MSG_DF_BIND_NOW) },
1251618Srie 		{ DF_STATIC_TLS,	MSG_ORIG(MSG_DF_STATIC_TLS) },
1261618Srie 		{ 0,			0 }
1271618Srie 	};
128*4734Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
129*4734Sab196087 	    NULL, sizeof (dyn_flag_buf->buf), vda };
1301618Srie 
1310Sstevel@tonic-gate 	if (flags == 0)
1320Sstevel@tonic-gate 		return (MSG_ORIG(MSG_GBL_ZERO));
1330Sstevel@tonic-gate 
134*4734Sab196087 	conv_arg.buf = dyn_flag_buf->buf;
1352352Sab196087 	conv_arg.oflags = conv_arg.rflags = flags;
1362352Sab196087 	if (fmt_flags & CONV_FMT_ALTDUMP) {
1372352Sab196087 		conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY);
1382352Sab196087 	} else {
1392352Sab196087 		conv_arg.prefix = conv_arg.suffix = NULL;
1402352Sab196087 	}
1412352Sab196087 	(void) conv_expn_field(&conv_arg);
1420Sstevel@tonic-gate 
143*4734Sab196087 	return ((const char *)dyn_flag_buf->buf);
1440Sstevel@tonic-gate }
1450Sstevel@tonic-gate 
1462352Sab196087 #define	FLAG1SZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1472352Sab196087 		MSG_DF1_NOW_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1482352Sab196087 		MSG_DF1_GLOBAL_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1492352Sab196087 		MSG_DF1_GROUP_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1502352Sab196087 		MSG_DF1_NODELETE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1512352Sab196087 		MSG_DF1_LOADFLTR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1522352Sab196087 		MSG_DF1_INITFIRST_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1532352Sab196087 		MSG_DF1_NOOPEN_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1542352Sab196087 		MSG_DF1_ORIGIN_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1552352Sab196087 		MSG_DF1_DIRECT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1562352Sab196087 		MSG_DF1_TRANS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1572352Sab196087 		MSG_DF1_INTERPOSE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1582352Sab196087 		MSG_DF1_NODEFLIB_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1592352Sab196087 		MSG_DF1_NODUMP_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1602352Sab196087 		MSG_DF1_CONFALT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1612352Sab196087 		MSG_DF1_ENDFILTEE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1622352Sab196087 		MSG_DF1_DISPRELPND_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1632352Sab196087 		MSG_DF1_DISPRELDNE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1642352Sab196087 		MSG_DF1_NODIRECT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1652352Sab196087 		MSG_DF1_IGNMULDEF_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1662352Sab196087 		MSG_DF1_NOKSYMS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1673466Srie 		MSG_DF1_NOHDR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1682352Sab196087 		MSG_DF1_NORELOC_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1693466Srie 		MSG_DF1_SYMINTPOSE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1704679Srie 		MSG_DF1_GLOBAUDIT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
171*4734Sab196087 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
172*4734Sab196087 
173*4734Sab196087 /*
174*4734Sab196087  * Ensure that Conv_dyn_flag1_buf_t is large enough:
175*4734Sab196087  *
176*4734Sab196087  * FLAG1SZ is the real minimum size of the buffer required by conv_dyn_flag1().
177*4734Sab196087  * However, Conv_dyn_flag1_buf_t uses CONV_DYN_FLAG1_BUFSIZE to set the
178*4734Sab196087  * buffer size. We do things this way because the definition of FLAG1SZ uses
179*4734Sab196087  * information that is not available in the environment of other programs
180*4734Sab196087  * that include the conv.h header file.
181*4734Sab196087  */
182*4734Sab196087 #if CONV_DYN_FLAG1_BUFSIZE < FLAG1SZ
183*4734Sab196087 #error "CONV_DYN_FLAG1_BUFSIZE is not large enough"
184*4734Sab196087 #endif
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate const char *
187*4734Sab196087 conv_dyn_flag1(Xword flags, Conv_dyn_flag1_buf_t *dyn_flag1_buf)
1880Sstevel@tonic-gate {
1891618Srie 	static Val_desc vda[] = {
1902352Sab196087 		{ DF_1_NOW,		MSG_ORIG(MSG_DF1_NOW) },
1911618Srie 		{ DF_1_GLOBAL,		MSG_ORIG(MSG_DF1_GLOBAL) },
1921618Srie 		{ DF_1_GROUP,		MSG_ORIG(MSG_DF1_GROUP) },
1931618Srie 		{ DF_1_NODELETE,	MSG_ORIG(MSG_DF1_NODELETE) },
1941618Srie 		{ DF_1_LOADFLTR,	MSG_ORIG(MSG_DF1_LOADFLTR) },
1951618Srie 		{ DF_1_INITFIRST,	MSG_ORIG(MSG_DF1_INITFIRST) },
1961618Srie 		{ DF_1_NOOPEN,		MSG_ORIG(MSG_DF1_NOOPEN) },
1971618Srie 		{ DF_1_ORIGIN,		MSG_ORIG(MSG_DF1_ORIGIN) },
1981618Srie 		{ DF_1_DIRECT,		MSG_ORIG(MSG_DF1_DIRECT) },
1991618Srie 		{ DF_1_TRANS,		MSG_ORIG(MSG_DF1_TRANS) },
2001618Srie 		{ DF_1_INTERPOSE,	MSG_ORIG(MSG_DF1_INTERPOSE) },
2011618Srie 		{ DF_1_NODEFLIB,	MSG_ORIG(MSG_DF1_NODEFLIB) },
2021618Srie 		{ DF_1_NODUMP,		MSG_ORIG(MSG_DF1_NODUMP) },
2031618Srie 		{ DF_1_CONFALT,		MSG_ORIG(MSG_DF1_CONFALT) },
2041618Srie 		{ DF_1_ENDFILTEE,	MSG_ORIG(MSG_DF1_ENDFILTEE) },
2053850Sab196087 		{ DF_1_DISPRELDNE,	MSG_ORIG(MSG_DF1_DISPRELDNE) },
2061618Srie 		{ DF_1_DISPRELPND,	MSG_ORIG(MSG_DF1_DISPRELPND) },
2071618Srie 		{ DF_1_NODIRECT,	MSG_ORIG(MSG_DF1_NODIRECT) },
2081618Srie 		{ DF_1_IGNMULDEF,	MSG_ORIG(MSG_DF1_IGNMULDEF) },
2091618Srie 		{ DF_1_NOKSYMS,		MSG_ORIG(MSG_DF1_NOKSYMS) },
2103466Srie 		{ DF_1_NOHDR,		MSG_ORIG(MSG_DF1_NOHDR) },
2113850Sab196087 		{ DF_1_EDITED,		MSG_ORIG(MSG_DF1_EDITED) },
2121618Srie 		{ DF_1_NORELOC,		MSG_ORIG(MSG_DF1_NORELOC) },
2133466Srie 		{ DF_1_SYMINTPOSE,	MSG_ORIG(MSG_DF1_SYMINTPOSE) },
2144679Srie 		{ DF_1_GLOBAUDIT,	MSG_ORIG(MSG_DF1_GLOBAUDIT) },
2151618Srie 		{ 0,			0 }
2161618Srie 	};
217*4734Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
218*4734Sab196087 	    NULL, sizeof (dyn_flag1_buf->buf), vda };
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate 	if (flags == 0)
2210Sstevel@tonic-gate 		return (MSG_ORIG(MSG_GBL_ZERO));
2220Sstevel@tonic-gate 
2232352Sab196087 	conv_arg.oflags = conv_arg.rflags = flags;
224*4734Sab196087 	conv_arg.buf = dyn_flag1_buf->buf;
2252352Sab196087 	(void) conv_expn_field(&conv_arg);
2260Sstevel@tonic-gate 
227*4734Sab196087 	return ((const char *)dyn_flag1_buf->buf);
2280Sstevel@tonic-gate }
2290Sstevel@tonic-gate 
2302352Sab196087 #define	FEATSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
2312352Sab196087 		MSG_DTF_PARINIT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2322352Sab196087 		MSG_DTF_CONFEXP_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
233*4734Sab196087 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
234*4734Sab196087 
235*4734Sab196087 /*
236*4734Sab196087  * Ensure that Conv_dyn_feature1_buf_t is large enough:
237*4734Sab196087  *
238*4734Sab196087  * FEATSZ is the real min size of the buffer required by conv_dyn_feature1().
239*4734Sab196087  * However, Conv_dyn_feature1_buf_t uses CONV_DYN_FEATURE1_BUFSIZE to set the
240*4734Sab196087  * buffer size. We do things this way because the definition of FEATSZ uses
241*4734Sab196087  * information that is not available in the environment of other programs
242*4734Sab196087  * that include the conv.h header file.
243*4734Sab196087  */
244*4734Sab196087 #if CONV_DYN_FEATURE1_BUFSIZE < FEATSZ
245*4734Sab196087 #error "CONV_DYN_FEATURE1_BUFSIZE is not large enough"
246*4734Sab196087 #endif
2470Sstevel@tonic-gate 
2480Sstevel@tonic-gate const char *
249*4734Sab196087 conv_dyn_feature1(Xword flags, int fmt_flags,
250*4734Sab196087     Conv_dyn_feature1_buf_t *dyn_feature1_buf)
2510Sstevel@tonic-gate {
2521618Srie 	static Val_desc vda[] = {
2531618Srie 		{ DTF_1_PARINIT,	MSG_ORIG(MSG_DTF_PARINIT) },
2541618Srie 		{ DTF_1_CONFEXP,	MSG_ORIG(MSG_DTF_CONFEXP) },
2551618Srie 		{ 0,			0 }
2561618Srie 	};
257*4734Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
258*4734Sab196087 	    NULL, sizeof (dyn_feature1_buf->buf), vda };
2590Sstevel@tonic-gate 
2600Sstevel@tonic-gate 	if (flags == 0)
2610Sstevel@tonic-gate 		return (MSG_ORIG(MSG_GBL_ZERO));
2620Sstevel@tonic-gate 
263*4734Sab196087 	conv_arg.buf = dyn_feature1_buf->buf;
2642352Sab196087 	conv_arg.oflags = conv_arg.rflags = flags;
2652352Sab196087 	if (fmt_flags & CONV_FMT_ALTDUMP) {
2662352Sab196087 		conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY);
2672352Sab196087 	} else {
2682352Sab196087 		conv_arg.prefix = conv_arg.suffix = NULL;
2692352Sab196087 	}
2702352Sab196087 	(void) conv_expn_field(&conv_arg);
2710Sstevel@tonic-gate 
272*4734Sab196087 	return ((const char *)dyn_feature1_buf->buf);
2730Sstevel@tonic-gate }
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate const char *
276*4734Sab196087 conv_dyn_tag(Xword tag, Half mach, int fmt_flags, Conv_inv_buf_t *inv_buf)
2770Sstevel@tonic-gate {
2783492Sab196087 	/*
2793492Sab196087 	 * Dynamic tag values are sparse, cover a wide range, and have
2803492Sab196087 	 * holes. To handle this efficiently, we fall through a series
2813492Sab196087 	 * of tests below, in increasing tag order, returning at the first
2823492Sab196087 	 * match.
2833492Sab196087 	 *
2843492Sab196087 	 * If we fall all the way to the end, the tag is unknown,
2853492Sab196087 	 * and its numeric value is printed.
2863492Sab196087 	 */
2873492Sab196087 
2883492Sab196087 	/*
2893492Sab196087 	 * Most of the tag values are clustered in contiguous ranges.
2903492Sab196087 	 * Each contiguous range of defined values is handled with
2913492Sab196087 	 * an array that contains the message index corresponding to
2923492Sab196087 	 * each value in that range. The DYN_RANGE macro checks the
2933492Sab196087 	 * tag value against range of values starting at _start_tag.
2943492Sab196087 	 * If there is a match, the index of the appropriate name is
2953492Sab196087 	 * pulled from _array and returned to the caller.
2963492Sab196087 	 */
2973492Sab196087 #define	DYN_RANGE(_start_tag, _array) \
2983492Sab196087 	if ((tag >= _start_tag) && (tag < (_start_tag + ARRAY_NELTS(_array)))) \
2993492Sab196087 		return (MSG_ORIG(_array[tag - _start_tag]));
3003492Sab196087 
3013492Sab196087 
3023492Sab196087 	/*
3033492Sab196087 	 * Generic dynamic tags:
3043492Sab196087 	 *	- Note hole between DT_FLAGS and DT_PREINIT_ARRAY
3053492Sab196087 	 *	- The first range has alternative names for dump,
3063492Sab196087 	 *	  requiring a second array.
3073492Sab196087 	 */
3083492Sab196087 	static const Msg	tags_null[] = {
3091618Srie 		MSG_DYN_NULL,		MSG_DYN_NEEDED,
3101618Srie 		MSG_DYN_PLTRELSZ,	MSG_DYN_PLTGOT,
3111618Srie 		MSG_DYN_HASH,		MSG_DYN_STRTAB,
3121618Srie 		MSG_DYN_SYMTAB,		MSG_DYN_RELA,
3131618Srie 		MSG_DYN_RELASZ,		MSG_DYN_RELAENT,
3141618Srie 		MSG_DYN_STRSZ,		MSG_DYN_SYMENT,
3151618Srie 		MSG_DYN_INIT,		MSG_DYN_FINI,
3161618Srie 		MSG_DYN_SONAME,		MSG_DYN_RPATH,
3171618Srie 		MSG_DYN_SYMBOLIC,	MSG_DYN_REL,
3181618Srie 		MSG_DYN_RELSZ,		MSG_DYN_RELENT,
3191618Srie 		MSG_DYN_PLTREL,		MSG_DYN_DEBUG,
3201618Srie 		MSG_DYN_TEXTREL,	MSG_DYN_JMPREL,
3211618Srie 		MSG_DYN_BIND_NOW,	MSG_DYN_INIT_ARRAY,
3221618Srie 		MSG_DYN_FINI_ARRAY,	MSG_DYN_INIT_ARRAYSZ,
3231618Srie 		MSG_DYN_FINI_ARRAYSZ,	MSG_DYN_RUNPATH,
3243492Sab196087 		MSG_DYN_FLAGS
3251618Srie 	};
3263492Sab196087 	static const Msg	tags_null_alt[] = {
3271976Sab196087 		MSG_DYN_NULL,		MSG_DYN_NEEDED,
3281976Sab196087 		MSG_DYN_PLTRELSZ_ALT,	MSG_DYN_PLTGOT,
3291976Sab196087 		MSG_DYN_HASH,		MSG_DYN_STRTAB,
3301976Sab196087 		MSG_DYN_SYMTAB,		MSG_DYN_RELA,
3311976Sab196087 		MSG_DYN_RELASZ,		MSG_DYN_RELAENT,
3321976Sab196087 		MSG_DYN_STRSZ,		MSG_DYN_SYMENT,
3331976Sab196087 		MSG_DYN_INIT,		MSG_DYN_FINI,
3341976Sab196087 		MSG_DYN_SONAME,		MSG_DYN_RPATH,
3351976Sab196087 		MSG_DYN_SYMBOLIC_ALT,	MSG_DYN_REL,
3361976Sab196087 		MSG_DYN_RELSZ,		MSG_DYN_RELENT,
3371976Sab196087 		MSG_DYN_PLTREL,		MSG_DYN_DEBUG,
3381976Sab196087 		MSG_DYN_TEXTREL,	MSG_DYN_JMPREL,
3391976Sab196087 		MSG_DYN_BIND_NOW,	MSG_DYN_INIT_ARRAY,
3401976Sab196087 		MSG_DYN_FINI_ARRAY,	MSG_DYN_INIT_ARRAYSZ,
3411976Sab196087 		MSG_DYN_FINI_ARRAYSZ,	MSG_DYN_RUNPATH,
3423492Sab196087 		MSG_DYN_FLAGS
3433492Sab196087 	};
3443492Sab196087 	static const Msg	tags_preinit_array[] = {
3451976Sab196087 		MSG_DYN_PREINIT_ARRAY,	MSG_DYN_PREINIT_ARRAYSZ
3461976Sab196087 	};
3470Sstevel@tonic-gate 
3483492Sab196087 	/*
3493850Sab196087 	 * SUNW: DT_LOOS -> DT_HIOS range. Note hole between DT_SUNW_TLSSORTSZ
3503850Sab196087 	 * and DT_SUNW_STRPAD. We handle DT_SUNW_STRPAD as a single value below.
3513492Sab196087 	 */
3523492Sab196087 	static const Msg	tags_sunw_auxiliary[] = {
3533492Sab196087 		MSG_DYN_SUNW_AUXILIARY,	MSG_DYN_SUNW_RTLDINF,
3543492Sab196087 		MSG_DYN_SUNW_FILTER,	MSG_DYN_SUNW_CAP,
3553492Sab196087 		MSG_DYN_SUNW_SYMTAB,	MSG_DYN_SUNW_SYMSZ,
3563731Srie 		MSG_DYN_SUNW_SORTENT,	MSG_DYN_SUNW_SYMSORT,
3573731Srie 		MSG_DYN_SUNW_SYMSORTSZ,	MSG_DYN_SUNW_TLSSORT,
3583731Srie 		MSG_DYN_SUNW_TLSSORTSZ
3593492Sab196087 	};
3600Sstevel@tonic-gate 
3613492Sab196087 	/*
3623492Sab196087 	 * SUNW: DT_VALRNGLO - DT_VALRNGHI range.
3633492Sab196087 	 */
3643492Sab196087 	static const Msg	tags_checksum[] = {
3653492Sab196087 		MSG_DYN_CHECKSUM,	MSG_DYN_PLTPADSZ,
3663492Sab196087 		MSG_DYN_MOVEENT,	MSG_DYN_MOVESZ,
3673492Sab196087 		MSG_DYN_FEATURE_1,	MSG_DYN_POSFLAG_1,
3683492Sab196087 		MSG_DYN_SYMINSZ,	MSG_DYN_SYMINENT
3693492Sab196087 	};
3703492Sab196087 
3713492Sab196087 	/*
3723492Sab196087 	 * SUNW: DT_ADDRRNGLO - DT_ADDRRNGHI range.
3733492Sab196087 	 */
3743492Sab196087 	static const Msg	tags_config[] = {
3753492Sab196087 		MSG_DYN_CONFIG,		MSG_DYN_DEPAUDIT,
3763492Sab196087 		MSG_DYN_AUDIT,		MSG_DYN_PLTPAD,
3773492Sab196087 		MSG_DYN_MOVETAB,	MSG_DYN_SYMINFO
3783492Sab196087 	};
3790Sstevel@tonic-gate 
3803492Sab196087 	/*
3813492Sab196087 	 * SUNW: generic range. Note hole between DT_VERSYM and DT_RELACOUNT.
3823492Sab196087 	 * We handle DT_VERSYM as a single value below.
3833492Sab196087 	 */
3843492Sab196087 	static const Msg	tags_relacount[] = {
3853492Sab196087 		MSG_DYN_RELACOUNT,	MSG_DYN_RELCOUNT,
3863492Sab196087 		MSG_DYN_FLAGS_1,	MSG_DYN_VERDEF,
3873492Sab196087 		MSG_DYN_VERDEFNUM,	MSG_DYN_VERNEED,
3883492Sab196087 		MSG_DYN_VERNEEDNUM
3893492Sab196087 	};
3903492Sab196087 
3913492Sab196087 	/*
3923492Sab196087 	 * DT_LOPROC - DT_HIPROC range.
3933492Sab196087 	 */
3943492Sab196087 	static const Msg	tags_auxiliary[] = {
3953492Sab196087 		MSG_DYN_AUXILIARY,	MSG_DYN_USED,
3963492Sab196087 		MSG_DYN_FILTER
3973492Sab196087 	};
3983492Sab196087 
3993492Sab196087 
4003492Sab196087 
4010Sstevel@tonic-gate 
4023492Sab196087 	if (tag <= DT_FLAGS)
403*4734Sab196087 		return (conv_map2str(inv_buf, tag, fmt_flags,
404*4734Sab196087 		    ARRAY_NELTS(tags_null), tags_null, tags_null_alt, NULL));
4053492Sab196087 	DYN_RANGE(DT_PREINIT_ARRAY, tags_preinit_array);
4063492Sab196087 	DYN_RANGE(DT_SUNW_AUXILIARY, tags_sunw_auxiliary);
4073850Sab196087 	if (tag == DT_SUNW_STRPAD)
4083850Sab196087 		return (MSG_ORIG(MSG_DYN_SUNW_STRPAD));
4093492Sab196087 	DYN_RANGE(DT_CHECKSUM, tags_checksum);
4103492Sab196087 	DYN_RANGE(DT_CONFIG, tags_config);
4113492Sab196087 	if (tag == DT_VERSYM)
4123492Sab196087 		return (MSG_ORIG(MSG_DYN_VERSYM));
4133492Sab196087 	DYN_RANGE(DT_RELACOUNT, tags_relacount);
4143492Sab196087 	DYN_RANGE(DT_AUXILIARY, tags_auxiliary);
4150Sstevel@tonic-gate 
4163492Sab196087 	/*
4173492Sab196087 	 * SUNW: machine specific range.
4183492Sab196087 	 */
4193492Sab196087 	if (((mach == EM_SPARC) || (mach == EM_SPARCV9) ||
4203492Sab196087 	    (mach == EM_SPARC32PLUS)) && (tag == DT_SPARC_REGISTER))
4213492Sab196087 		/* this is so x86 can display a sparc binary */
4223492Sab196087 		return (MSG_ORIG(MSG_DYN_REGISTER));
4233492Sab196087 
4243492Sab196087 	if (tag == DT_DEPRECATED_SPARC_REGISTER)
4253492Sab196087 		return (MSG_ORIG(MSG_DYN_REGISTER));
4263492Sab196087 
4273492Sab196087 	/* Unknown item */
428*4734Sab196087 	return (conv_invalid_val(inv_buf, tag, fmt_flags));
4293492Sab196087 
4303492Sab196087 #undef DYN_RANGE
4310Sstevel@tonic-gate }
432280Srie 
4332352Sab196087 #define	BINDTSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
4342352Sab196087 		MSG_BND_NEEDED_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4352352Sab196087 		MSG_BND_REFER_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4362352Sab196087 		MSG_BND_FILTER_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
437*4734Sab196087 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
438*4734Sab196087 
439*4734Sab196087 /*
440*4734Sab196087  * Ensure that Conv_bnd_type_buf_t is large enough:
441*4734Sab196087  *
442*4734Sab196087  * BINDTSZ is the real minimum size of the buffer required by conv_bnd_type().
443*4734Sab196087  * However, Conv_bnd_type_buf_t uses CONV_BND_TYPE_BUFSIZE to set the
444*4734Sab196087  * buffer size. We do things this way because the definition of BINDTSZ uses
445*4734Sab196087  * information that is not available in the environment of other programs
446*4734Sab196087  * that include the conv.h header file.
447*4734Sab196087  */
448*4734Sab196087 #if CONV_BND_TYPE_BUFSIZE < BINDTSZ
449*4734Sab196087 #error "CONV_BND_TYPE_BUFSIZE is not large enough"
450*4734Sab196087 #endif
451280Srie 
452280Srie const char *
453*4734Sab196087 conv_bnd_type(uint_t flags, Conv_bnd_type_buf_t *bnd_type_buf)
454280Srie {
4551618Srie 	static Val_desc vda[] = {
4561618Srie 		{ BND_NEEDED,		MSG_ORIG(MSG_BND_NEEDED) },
4571618Srie 		{ BND_REFER,		MSG_ORIG(MSG_BND_REFER) },
4581618Srie 		{ BND_FILTER,		MSG_ORIG(MSG_BND_FILTER) },
4591618Srie 		{ 0,			0 }
4601618Srie 	};
461*4734Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
462*4734Sab196087 	    NULL, sizeof (bnd_type_buf->buf), vda };
463280Srie 
4641618Srie 	if (flags == 0)
4651618Srie 		return (MSG_ORIG(MSG_STR_EMPTY));
466280Srie 
467*4734Sab196087 	conv_arg.buf = bnd_type_buf->buf;
4682352Sab196087 	conv_arg.oflags = conv_arg.rflags = flags;
4692352Sab196087 	(void) conv_expn_field(&conv_arg);
4701618Srie 
471*4734Sab196087 	return ((const char *)bnd_type_buf->buf);
472280Srie }
473280Srie 
4741824Srie /*
4751824Srie  * Note, conv_bnd_obj() is called with either:
4761824Srie  *	LML_FLG_OBJADDED (possibly with LML_FLG_OBJREEVAL added), or
4771824Srie  *	LML_FLG_OBJDELETED, or
4781824Srie  *	LML_FLG_ATEXIT.
4791824Srie  */
4802352Sab196087 #define	BINDOSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
4812352Sab196087 		MSG_BND_ADDED_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
4822352Sab196087 		MSG_BND_REEVAL_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
483*4734Sab196087 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
484*4734Sab196087 
485*4734Sab196087 /*
486*4734Sab196087  * Ensure that Conv_bnd_obj_buf_t is large enough:
487*4734Sab196087  *
488*4734Sab196087  * BINDOSZ is the real minimum size of the buffer required by conv_bnd_obj().
489*4734Sab196087  * However, Conv_bnd_obj_buf_t uses CONV_BND_OBJ_BUFSIZE to set the
490*4734Sab196087  * buffer size. We do things this way because the definition of BINDOSZ uses
491*4734Sab196087  * information that is not available in the environment of other programs
492*4734Sab196087  * that include the conv.h header file.
493*4734Sab196087  */
494*4734Sab196087 #if CONV_BND_OBJ_BUFSIZE < BINDOSZ
495*4734Sab196087 #error "CONV_BND_OBJ_BUFSIZE is not large enough"
496*4734Sab196087 #endif
497280Srie 
498280Srie const char *
499*4734Sab196087 conv_bnd_obj(uint_t flags, Conv_bnd_obj_buf_t *bnd_obj_buf)
500280Srie {
5011618Srie 	static Val_desc vda[] = {
5021618Srie 		{ LML_FLG_OBJADDED,	MSG_ORIG(MSG_BND_ADDED) },
5031618Srie 		{ LML_FLG_OBJREEVAL,	MSG_ORIG(MSG_BND_REEVAL) },
5041618Srie 		{ LML_FLG_OBJDELETED,	MSG_ORIG(MSG_BND_DELETED) },
5051618Srie 		{ LML_FLG_ATEXIT,	MSG_ORIG(MSG_BND_ATEXIT) },
5061618Srie 		{ 0,			0 }
5071618Srie 	};
508*4734Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
509*4734Sab196087 	    NULL, sizeof (bnd_obj_buf->buf), vda };
5101618Srie 
5111824Srie 	if ((flags & (LML_FLG_OBJADDED | LML_FLG_OBJREEVAL |
5121824Srie 	    LML_FLG_OBJDELETED | LML_FLG_ATEXIT)) == 0)
5131824Srie 		return (MSG_ORIG(MSG_BND_REVISIT));
514280Srie 
515280Srie 	/*
5161618Srie 	 * Note, we're not worried about unknown flags for this family, only
5172352Sab196087 	 * the selected flags are of interest, so we leave conv_arg.rflags
5182352Sab196087 	 * set to 0.
519280Srie 	 */
520*4734Sab196087 	conv_arg.buf = bnd_obj_buf->buf;
5212352Sab196087 	conv_arg.oflags = flags;
5222352Sab196087 	(void) conv_expn_field(&conv_arg);
523280Srie 
524*4734Sab196087 	return ((const char *)bnd_obj_buf->buf);
525280Srie }
526