xref: /titanic_50/usr/src/cmd/sgs/libconv/common/dynamic.c (revision 1d03c31e0733adea0edef54f0d5d2ea9639ecd2a)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  * String conversion routine for .dynamic tag entries.
30  */
31 #include	<stdio.h>
32 #include	<string.h>
33 #include	<sys/elf_SPARC.h>
34 #include	"rtld.h"
35 #include	"_conv.h"
36 #include	"dynamic_msg.h"
37 
38 
39 
40 /* Instantiate a local copy of conv_map2str() from _conv.h */
41 DEFINE_conv_map2str
42 
43 
44 
45 #define	POSSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
46 		MSG_DFP_LAZYLOAD_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
47 		MSG_DFP_GROUPPERM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
48 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
49 
50 /*
51  * Ensure that Conv_dyn_posflag1_buf_t is large enough:
52  *
53  * POSSZ is the real minimum size of the buffer required by conv_dyn_posflag1().
54  * However, Conv_dyn_posflag1_buf_t uses CONV_DYN_POSFLAG1_BUFSIZE to set the
55  * buffer size. We do things this way because the definition of POSSZ uses
56  * information that is not available in the environment of other programs
57  * that include the conv.h header file.
58  */
59 #if (CONV_DYN_POSFLAG1_BUFSIZE != POSSZ) && !defined(__lint)
60 #define	REPORT_BUFSIZE POSSZ
61 #include "report_bufsize.h"
62 #error "CONV_DYN_POSFLAG1_BUFSIZE does not match POSSZ"
63 #endif
64 
65 const char *
66 conv_dyn_posflag1(Xword flags, Conv_fmt_flags_t fmt_flags,
67     Conv_dyn_posflag1_buf_t *dyn_posflag1_buf)
68 {
69 	static Val_desc vda[] = {
70 		{ DF_P1_LAZYLOAD,	MSG_ORIG(MSG_DFP_LAZYLOAD) },
71 		{ DF_P1_GROUPPERM,	MSG_ORIG(MSG_DFP_GROUPPERM) },
72 		{ 0,			0 }
73 	};
74 	static CONV_EXPN_FIELD_ARG conv_arg = {
75 	    NULL, sizeof (dyn_posflag1_buf->buf), vda };
76 	static Val_desc vda_alt[] = {
77 		{ DF_P1_LAZYLOAD,	MSG_ORIG(MSG_DFP_LAZYLOAD_ALT) },
78 		{ DF_P1_GROUPPERM,	MSG_ORIG(MSG_DFP_GROUPPERM) },
79 		{ 0,			0 }
80 	};
81 	static CONV_EXPN_FIELD_ARG conv_arg_alt = {
82 	    NULL, sizeof (dyn_posflag1_buf->buf), vda_alt, NULL, 0, 0,
83 	    MSG_ORIG(MSG_STR_EMPTY), NULL, MSG_ORIG(MSG_STR_EMPTY) };
84 
85 	CONV_EXPN_FIELD_ARG *arg;
86 
87 	if (flags == 0)
88 		return (MSG_ORIG(MSG_GBL_ZERO));
89 
90 	arg = (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) ?
91 	    &conv_arg_alt : &conv_arg;
92 	arg->buf = dyn_posflag1_buf->buf;
93 	arg->oflags = arg->rflags = flags;
94 	(void) conv_expn_field(arg, fmt_flags);
95 
96 	return ((const char *)dyn_posflag1_buf);
97 }
98 
99 #define	FLAGSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
100 		MSG_DF_ORIGIN_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
101 		MSG_DF_SYMBOLIC_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
102 		MSG_DF_TEXTREL_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
103 		MSG_DF_BIND_NOW_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
104 		MSG_DF_STATIC_TLS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
105 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
106 
107 /*
108  * Ensure that Conv_dyn_flag_buf_t is large enough:
109  *
110  * FLAGSZ is the real minimum size of the buffer required by conv_dyn_flag().
111  * However, Conv_dyn_flag_buf_t uses CONV_DYN_FLAG_BUFSIZE to set the
112  * buffer size. We do things this way because the definition of FLAGSZ uses
113  * information that is not available in the environment of other programs
114  * that include the conv.h header file.
115  */
116 #if (CONV_DYN_FLAG_BUFSIZE != FLAGSZ) && !defined(__lint)
117 #define	REPORT_BUFSIZE FLAGSZ
118 #include "report_bufsize.h"
119 #error "CONV_DYN_FLAG_BUFSIZE does not match FLAGSZ"
120 #endif
121 const char *
122 conv_dyn_flag(Xword flags, Conv_fmt_flags_t fmt_flags,
123     Conv_dyn_flag_buf_t *dyn_flag_buf)
124 {
125 	static Val_desc vda[] = {
126 		{ DF_ORIGIN,		MSG_ORIG(MSG_DF_ORIGIN) },
127 		{ DF_SYMBOLIC,		MSG_ORIG(MSG_DF_SYMBOLIC) },
128 		{ DF_TEXTREL,		MSG_ORIG(MSG_DF_TEXTREL) },
129 		{ DF_BIND_NOW,		MSG_ORIG(MSG_DF_BIND_NOW) },
130 		{ DF_STATIC_TLS,	MSG_ORIG(MSG_DF_STATIC_TLS) },
131 		{ 0,			0 }
132 	};
133 	static CONV_EXPN_FIELD_ARG conv_arg = {
134 	    NULL, sizeof (dyn_flag_buf->buf), vda };
135 
136 	if (flags == 0)
137 		return (MSG_ORIG(MSG_GBL_ZERO));
138 
139 	conv_arg.buf = dyn_flag_buf->buf;
140 	conv_arg.oflags = conv_arg.rflags = flags;
141 	if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) {
142 		conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY);
143 	} else {
144 		conv_arg.prefix = conv_arg.suffix = NULL;
145 	}
146 	(void) conv_expn_field(&conv_arg, fmt_flags);
147 
148 	return ((const char *)dyn_flag_buf->buf);
149 }
150 
151 #define	FLAG1SZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
152 		MSG_DF1_NOW_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
153 		MSG_DF1_GLOBAL_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
154 		MSG_DF1_GROUP_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
155 		MSG_DF1_NODELETE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
156 		MSG_DF1_LOADFLTR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
157 		MSG_DF1_INITFIRST_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
158 		MSG_DF1_NOOPEN_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
159 		MSG_DF1_ORIGIN_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
160 		MSG_DF1_DIRECT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
161 		MSG_DF1_TRANS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
162 		MSG_DF1_INTERPOSE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
163 		MSG_DF1_NODEFLIB_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
164 		MSG_DF1_NODUMP_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
165 		MSG_DF1_CONFALT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
166 		MSG_DF1_ENDFILTEE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
167 		MSG_DF1_DISPRELPND_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
168 		MSG_DF1_DISPRELDNE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
169 		MSG_DF1_NODIRECT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
170 		MSG_DF1_IGNMULDEF_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
171 		MSG_DF1_NOKSYMS_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
172 		MSG_DF1_NOHDR_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
173 		MSG_DF1_NORELOC_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
174 		MSG_DF1_SYMINTPOSE_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
175 		MSG_DF1_GLOBAUDIT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
176 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
177 
178 /*
179  * Ensure that Conv_dyn_flag1_buf_t is large enough:
180  *
181  * FLAG1SZ is the real minimum size of the buffer required by conv_dyn_flag1().
182  * However, Conv_dyn_flag1_buf_t uses CONV_DYN_FLAG1_BUFSIZE to set the
183  * buffer size. We do things this way because the definition of FLAG1SZ uses
184  * information that is not available in the environment of other programs
185  * that include the conv.h header file.
186  */
187 #if (CONV_DYN_FLAG1_BUFSIZE != FLAG1SZ) && !defined(__lint)
188 #define	REPORT_BUFSIZE FLAG1SZ
189 #include "report_bufsize.h"
190 #error "CONV_DYN_FLAG1_BUFSIZE does not match FLAG1SZ"
191 #endif
192 
193 const char *
194 conv_dyn_flag1(Xword flags, Conv_fmt_flags_t fmt_flags,
195     Conv_dyn_flag1_buf_t *dyn_flag1_buf)
196 {
197 	static Val_desc vda[] = {
198 		{ DF_1_NOW,		MSG_ORIG(MSG_DF1_NOW) },
199 		{ DF_1_GLOBAL,		MSG_ORIG(MSG_DF1_GLOBAL) },
200 		{ DF_1_GROUP,		MSG_ORIG(MSG_DF1_GROUP) },
201 		{ DF_1_NODELETE,	MSG_ORIG(MSG_DF1_NODELETE) },
202 		{ DF_1_LOADFLTR,	MSG_ORIG(MSG_DF1_LOADFLTR) },
203 		{ DF_1_INITFIRST,	MSG_ORIG(MSG_DF1_INITFIRST) },
204 		{ DF_1_NOOPEN,		MSG_ORIG(MSG_DF1_NOOPEN) },
205 		{ DF_1_ORIGIN,		MSG_ORIG(MSG_DF1_ORIGIN) },
206 		{ DF_1_DIRECT,		MSG_ORIG(MSG_DF1_DIRECT) },
207 		{ DF_1_TRANS,		MSG_ORIG(MSG_DF1_TRANS) },
208 		{ DF_1_INTERPOSE,	MSG_ORIG(MSG_DF1_INTERPOSE) },
209 		{ DF_1_NODEFLIB,	MSG_ORIG(MSG_DF1_NODEFLIB) },
210 		{ DF_1_NODUMP,		MSG_ORIG(MSG_DF1_NODUMP) },
211 		{ DF_1_CONFALT,		MSG_ORIG(MSG_DF1_CONFALT) },
212 		{ DF_1_ENDFILTEE,	MSG_ORIG(MSG_DF1_ENDFILTEE) },
213 		{ DF_1_DISPRELDNE,	MSG_ORIG(MSG_DF1_DISPRELDNE) },
214 		{ DF_1_DISPRELPND,	MSG_ORIG(MSG_DF1_DISPRELPND) },
215 		{ DF_1_NODIRECT,	MSG_ORIG(MSG_DF1_NODIRECT) },
216 		{ DF_1_IGNMULDEF,	MSG_ORIG(MSG_DF1_IGNMULDEF) },
217 		{ DF_1_NOKSYMS,		MSG_ORIG(MSG_DF1_NOKSYMS) },
218 		{ DF_1_NOHDR,		MSG_ORIG(MSG_DF1_NOHDR) },
219 		{ DF_1_EDITED,		MSG_ORIG(MSG_DF1_EDITED) },
220 		{ DF_1_NORELOC,		MSG_ORIG(MSG_DF1_NORELOC) },
221 		{ DF_1_SYMINTPOSE,	MSG_ORIG(MSG_DF1_SYMINTPOSE) },
222 		{ DF_1_GLOBAUDIT,	MSG_ORIG(MSG_DF1_GLOBAUDIT) },
223 		{ 0,			0 }
224 	};
225 	static CONV_EXPN_FIELD_ARG conv_arg = {
226 	    NULL, sizeof (dyn_flag1_buf->buf), vda };
227 
228 	if (flags == 0)
229 		return (MSG_ORIG(MSG_GBL_ZERO));
230 
231 	conv_arg.oflags = conv_arg.rflags = flags;
232 	conv_arg.buf = dyn_flag1_buf->buf;
233 	(void) conv_expn_field(&conv_arg, fmt_flags);
234 
235 	return ((const char *)dyn_flag1_buf->buf);
236 }
237 
238 #define	FEATSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
239 		MSG_DTF_PARINIT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
240 		MSG_DTF_CONFEXP_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
241 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
242 
243 /*
244  * Ensure that Conv_dyn_feature1_buf_t is large enough:
245  *
246  * FEATSZ is the real min size of the buffer required by conv_dyn_feature1().
247  * However, Conv_dyn_feature1_buf_t uses CONV_DYN_FEATURE1_BUFSIZE to set the
248  * buffer size. We do things this way because the definition of FEATSZ uses
249  * information that is not available in the environment of other programs
250  * that include the conv.h header file.
251  */
252 #if (CONV_DYN_FEATURE1_BUFSIZE != FEATSZ) && !defined(__lint)
253 #define	REPORT_BUFSIZE FEATSZ
254 #include "report_bufsize.h"
255 #error "CONV_DYN_FEATURE1_BUFSIZE does not match FEATSZ"
256 #endif
257 
258 const char *
259 conv_dyn_feature1(Xword flags, Conv_fmt_flags_t fmt_flags,
260     Conv_dyn_feature1_buf_t *dyn_feature1_buf)
261 {
262 	static Val_desc vda[] = {
263 		{ DTF_1_PARINIT,	MSG_ORIG(MSG_DTF_PARINIT) },
264 		{ DTF_1_CONFEXP,	MSG_ORIG(MSG_DTF_CONFEXP) },
265 		{ 0,			0 }
266 	};
267 	static CONV_EXPN_FIELD_ARG conv_arg = {
268 	    NULL, sizeof (dyn_feature1_buf->buf), vda };
269 
270 	if (flags == 0)
271 		return (MSG_ORIG(MSG_GBL_ZERO));
272 
273 	conv_arg.buf = dyn_feature1_buf->buf;
274 	conv_arg.oflags = conv_arg.rflags = flags;
275 	if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) {
276 		conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY);
277 	} else {
278 		conv_arg.prefix = conv_arg.suffix = NULL;
279 	}
280 	(void) conv_expn_field(&conv_arg, fmt_flags);
281 
282 	return ((const char *)dyn_feature1_buf->buf);
283 }
284 
285 const char *
286 conv_dyn_tag(Xword tag, Half mach, Conv_fmt_flags_t fmt_flags,
287     Conv_inv_buf_t *inv_buf)
288 {
289 	/*
290 	 * Dynamic tag values are sparse, cover a wide range, and have
291 	 * holes. To handle this efficiently, we fall through a series
292 	 * of tests below, in increasing tag order, returning at the first
293 	 * match.
294 	 *
295 	 * If we fall all the way to the end, the tag is unknown,
296 	 * and its numeric value is printed.
297 	 */
298 
299 	/*
300 	 * Most of the tag values are clustered in contiguous ranges.
301 	 * Each contiguous range of defined values is handled with
302 	 * an array that contains the message index corresponding to
303 	 * each value in that range. The DYN_RANGE macro checks the
304 	 * tag value against range of values starting at _start_tag.
305 	 * If there is a match, the index of the appropriate name is
306 	 * pulled from _array and returned to the caller.
307 	 */
308 #define	DYN_RANGE(_start_tag, _array) \
309 	if ((tag >= _start_tag) && (tag < (_start_tag + ARRAY_NELTS(_array)))) \
310 		return (MSG_ORIG(_array[tag - _start_tag]));
311 
312 
313 	/*
314 	 * Generic dynamic tags:
315 	 *	- Note hole between DT_FLAGS and DT_PREINIT_ARRAY
316 	 *	- The first range has alternative names for dump,
317 	 *	  requiring a second array.
318 	 */
319 	static const Msg	tags_null[] = {
320 		MSG_DYN_NULL,		MSG_DYN_NEEDED,
321 		MSG_DYN_PLTRELSZ,	MSG_DYN_PLTGOT,
322 		MSG_DYN_HASH,		MSG_DYN_STRTAB,
323 		MSG_DYN_SYMTAB,		MSG_DYN_RELA,
324 		MSG_DYN_RELASZ,		MSG_DYN_RELAENT,
325 		MSG_DYN_STRSZ,		MSG_DYN_SYMENT,
326 		MSG_DYN_INIT,		MSG_DYN_FINI,
327 		MSG_DYN_SONAME,		MSG_DYN_RPATH,
328 		MSG_DYN_SYMBOLIC,	MSG_DYN_REL,
329 		MSG_DYN_RELSZ,		MSG_DYN_RELENT,
330 		MSG_DYN_PLTREL,		MSG_DYN_DEBUG,
331 		MSG_DYN_TEXTREL,	MSG_DYN_JMPREL,
332 		MSG_DYN_BIND_NOW,	MSG_DYN_INIT_ARRAY,
333 		MSG_DYN_FINI_ARRAY,	MSG_DYN_INIT_ARRAYSZ,
334 		MSG_DYN_FINI_ARRAYSZ,	MSG_DYN_RUNPATH,
335 		MSG_DYN_FLAGS
336 	};
337 	static const Msg	tags_null_alt[] = {
338 		MSG_DYN_NULL,		MSG_DYN_NEEDED,
339 		MSG_DYN_PLTRELSZ_ALT,	MSG_DYN_PLTGOT,
340 		MSG_DYN_HASH,		MSG_DYN_STRTAB,
341 		MSG_DYN_SYMTAB,		MSG_DYN_RELA,
342 		MSG_DYN_RELASZ,		MSG_DYN_RELAENT,
343 		MSG_DYN_STRSZ,		MSG_DYN_SYMENT,
344 		MSG_DYN_INIT,		MSG_DYN_FINI,
345 		MSG_DYN_SONAME,		MSG_DYN_RPATH,
346 		MSG_DYN_SYMBOLIC_ALT,	MSG_DYN_REL,
347 		MSG_DYN_RELSZ,		MSG_DYN_RELENT,
348 		MSG_DYN_PLTREL,		MSG_DYN_DEBUG,
349 		MSG_DYN_TEXTREL,	MSG_DYN_JMPREL,
350 		MSG_DYN_BIND_NOW,	MSG_DYN_INIT_ARRAY,
351 		MSG_DYN_FINI_ARRAY,	MSG_DYN_INIT_ARRAYSZ,
352 		MSG_DYN_FINI_ARRAYSZ,	MSG_DYN_RUNPATH,
353 		MSG_DYN_FLAGS
354 	};
355 	static const Msg	tags_preinit_array[] = {
356 		MSG_DYN_PREINIT_ARRAY,	MSG_DYN_PREINIT_ARRAYSZ
357 	};
358 
359 	/*
360 	 * SUNW: DT_LOOS -> DT_HIOS range. Note hole between DT_SUNW_TLSSORTSZ
361 	 * and DT_SUNW_STRPAD. We handle DT_SUNW_STRPAD as a single value below.
362 	 */
363 	static const Msg	tags_sunw_auxiliary[] = {
364 		MSG_DYN_SUNW_AUXILIARY,	MSG_DYN_SUNW_RTLDINF,
365 		MSG_DYN_SUNW_FILTER,	MSG_DYN_SUNW_CAP,
366 		MSG_DYN_SUNW_SYMTAB,	MSG_DYN_SUNW_SYMSZ,
367 		MSG_DYN_SUNW_SORTENT,	MSG_DYN_SUNW_SYMSORT,
368 		MSG_DYN_SUNW_SYMSORTSZ,	MSG_DYN_SUNW_TLSSORT,
369 		MSG_DYN_SUNW_TLSSORTSZ
370 	};
371 
372 	/*
373 	 * SUNW: DT_VALRNGLO - DT_VALRNGHI range.
374 	 */
375 	static const Msg	tags_checksum[] = {
376 		MSG_DYN_CHECKSUM,	MSG_DYN_PLTPADSZ,
377 		MSG_DYN_MOVEENT,	MSG_DYN_MOVESZ,
378 		MSG_DYN_FEATURE_1,	MSG_DYN_POSFLAG_1,
379 		MSG_DYN_SYMINSZ,	MSG_DYN_SYMINENT
380 	};
381 
382 	/*
383 	 * SUNW: DT_ADDRRNGLO - DT_ADDRRNGHI range.
384 	 */
385 	static const Msg	tags_config[] = {
386 		MSG_DYN_CONFIG,		MSG_DYN_DEPAUDIT,
387 		MSG_DYN_AUDIT,		MSG_DYN_PLTPAD,
388 		MSG_DYN_MOVETAB,	MSG_DYN_SYMINFO
389 	};
390 
391 	/*
392 	 * SUNW: generic range. Note hole between DT_VERSYM and DT_RELACOUNT.
393 	 * We handle DT_VERSYM as a single value below.
394 	 */
395 	static const Msg	tags_relacount[] = {
396 		MSG_DYN_RELACOUNT,	MSG_DYN_RELCOUNT,
397 		MSG_DYN_FLAGS_1,	MSG_DYN_VERDEF,
398 		MSG_DYN_VERDEFNUM,	MSG_DYN_VERNEED,
399 		MSG_DYN_VERNEEDNUM
400 	};
401 
402 	/*
403 	 * DT_LOPROC - DT_HIPROC range.
404 	 */
405 	static const Msg	tags_auxiliary[] = {
406 		MSG_DYN_AUXILIARY,	MSG_DYN_USED,
407 		MSG_DYN_FILTER
408 	};
409 
410 
411 
412 
413 	if (tag <= DT_FLAGS) {
414 		/* use 'dump' style? */
415 		if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP)
416 			return (conv_map2str(inv_buf, tag, fmt_flags,
417 			    ARRAY_NELTS(tags_null_alt), tags_null_alt));
418 		/* Standard style */
419 		return (conv_map2str(inv_buf, tag, fmt_flags,
420 		    ARRAY_NELTS(tags_null), tags_null));
421 	}
422 	DYN_RANGE(DT_PREINIT_ARRAY, tags_preinit_array);
423 	DYN_RANGE(DT_SUNW_AUXILIARY, tags_sunw_auxiliary);
424 	if (tag == DT_SUNW_STRPAD)
425 		return (MSG_ORIG(MSG_DYN_SUNW_STRPAD));
426 	DYN_RANGE(DT_CHECKSUM, tags_checksum);
427 	DYN_RANGE(DT_CONFIG, tags_config);
428 	if (tag == DT_VERSYM)
429 		return (MSG_ORIG(MSG_DYN_VERSYM));
430 	DYN_RANGE(DT_RELACOUNT, tags_relacount);
431 	DYN_RANGE(DT_AUXILIARY, tags_auxiliary);
432 
433 	/*
434 	 * SUNW: machine specific range.
435 	 */
436 	if (((mach == EM_SPARC) || (mach == EM_SPARCV9) ||
437 	    (mach == EM_SPARC32PLUS)) && (tag == DT_SPARC_REGISTER))
438 		/* this is so x86 can display a sparc binary */
439 		return (MSG_ORIG(MSG_DYN_REGISTER));
440 
441 	if (tag == DT_DEPRECATED_SPARC_REGISTER)
442 		return (MSG_ORIG(MSG_DYN_REGISTER));
443 
444 	/* Unknown item */
445 	return (conv_invalid_val(inv_buf, tag, fmt_flags));
446 
447 #undef DYN_RANGE
448 }
449 
450 #define	BINDTSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
451 		MSG_BND_NEEDED_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
452 		MSG_BND_REFER_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
453 		MSG_BND_FILTER_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
454 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
455 
456 /*
457  * Ensure that Conv_bnd_type_buf_t is large enough:
458  *
459  * BINDTSZ is the real minimum size of the buffer required by conv_bnd_type().
460  * However, Conv_bnd_type_buf_t uses CONV_BND_TYPE_BUFSIZE to set the
461  * buffer size. We do things this way because the definition of BINDTSZ uses
462  * information that is not available in the environment of other programs
463  * that include the conv.h header file.
464  */
465 #if (CONV_BND_TYPE_BUFSIZE != BINDTSZ) && !defined(__lint)
466 #define	REPORT_BUFSIZE BINDTSZ
467 #include "report_bufsize.h"
468 #error "CONV_BND_TYPE_BUFSIZE does not match BINDTSZ"
469 #endif
470 
471 const char *
472 conv_bnd_type(uint_t flags, Conv_bnd_type_buf_t *bnd_type_buf)
473 {
474 	static Val_desc vda[] = {
475 		{ BND_NEEDED,		MSG_ORIG(MSG_BND_NEEDED) },
476 		{ BND_REFER,		MSG_ORIG(MSG_BND_REFER) },
477 		{ BND_FILTER,		MSG_ORIG(MSG_BND_FILTER) },
478 		{ 0,			0 }
479 	};
480 	static CONV_EXPN_FIELD_ARG conv_arg = {
481 	    NULL, sizeof (bnd_type_buf->buf), vda };
482 
483 	if (flags == 0)
484 		return (MSG_ORIG(MSG_STR_EMPTY));
485 
486 	conv_arg.buf = bnd_type_buf->buf;
487 	conv_arg.oflags = conv_arg.rflags = flags;
488 	(void) conv_expn_field(&conv_arg, 0);
489 
490 	return ((const char *)bnd_type_buf->buf);
491 }
492 
493 /*
494  * Note, conv_bnd_obj() is called with either:
495  *	LML_FLG_OBJADDED (possibly with LML_FLG_OBJREEVAL added), or
496  *	LML_FLG_OBJDELETED, or
497  *	LML_FLG_ATEXIT.
498  */
499 #define	BINDOSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
500 		MSG_BND_ADDED_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
501 		MSG_BND_REEVAL_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
502 		CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
503 
504 /*
505  * Ensure that Conv_bnd_obj_buf_t is large enough:
506  *
507  * BINDOSZ is the real minimum size of the buffer required by conv_bnd_obj().
508  * However, Conv_bnd_obj_buf_t uses CONV_BND_OBJ_BUFSIZE to set the
509  * buffer size. We do things this way because the definition of BINDOSZ uses
510  * information that is not available in the environment of other programs
511  * that include the conv.h header file.
512  */
513 #if (CONV_BND_OBJ_BUFSIZE != BINDOSZ) && !defined(__lint)
514 #define	REPORT_BUFSIZE BINDOSZ
515 #include "report_bufsize.h"
516 #error "CONV_BND_OBJ_BUFSIZE does not match BINDOSZ"
517 #endif
518 
519 const char *
520 conv_bnd_obj(uint_t flags, Conv_bnd_obj_buf_t *bnd_obj_buf)
521 {
522 	static Val_desc vda[] = {
523 		{ LML_FLG_OBJADDED,	MSG_ORIG(MSG_BND_ADDED) },
524 		{ LML_FLG_OBJREEVAL,	MSG_ORIG(MSG_BND_REEVAL) },
525 		{ LML_FLG_OBJDELETED,	MSG_ORIG(MSG_BND_DELETED) },
526 		{ LML_FLG_ATEXIT,	MSG_ORIG(MSG_BND_ATEXIT) },
527 		{ 0,			0 }
528 	};
529 	static CONV_EXPN_FIELD_ARG conv_arg = {
530 	    NULL, sizeof (bnd_obj_buf->buf), vda };
531 
532 	if ((flags & (LML_FLG_OBJADDED | LML_FLG_OBJREEVAL |
533 	    LML_FLG_OBJDELETED | LML_FLG_ATEXIT)) == 0)
534 		return (MSG_ORIG(MSG_BND_REVISIT));
535 
536 	/*
537 	 * Note, we're not worried about unknown flags for this family, only
538 	 * the selected flags are of interest, so we leave conv_arg.rflags
539 	 * set to 0.
540 	 */
541 	conv_arg.buf = bnd_obj_buf->buf;
542 	conv_arg.oflags = flags;
543 	(void) conv_expn_field(&conv_arg, 0);
544 
545 	return ((const char *)bnd_obj_buf->buf);
546 }
547