xref: /onnv-gate/usr/src/cmd/sgs/libconv/common/syminfo.c (revision 5152:fa5ab16f3606)
15088Sab196087 /*
25088Sab196087  * CDDL HEADER START
35088Sab196087  *
45088Sab196087  * The contents of this file are subject to the terms of the
55088Sab196087  * Common Development and Distribution License (the "License").
65088Sab196087  * You may not use this file except in compliance with the License.
75088Sab196087  *
85088Sab196087  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95088Sab196087  * or http://www.opensolaris.org/os/licensing.
105088Sab196087  * See the License for the specific language governing permissions
115088Sab196087  * and limitations under the License.
125088Sab196087  *
135088Sab196087  * When distributing Covered Code, include this CDDL HEADER in each
145088Sab196087  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155088Sab196087  * If applicable, add the following below this CDDL HEADER, with the
165088Sab196087  * fields enclosed by brackets "[]" replaced with your own identifying
175088Sab196087  * information: Portions Copyright [yyyy] [name of copyright owner]
185088Sab196087  *
195088Sab196087  * CDDL HEADER END
205088Sab196087  */
215088Sab196087 
225088Sab196087 /*
235088Sab196087  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
245088Sab196087  * Use is subject to license terms.
255088Sab196087  */
265088Sab196087 #pragma ident	"%Z%%M%	%I%	%E% SMI"
275088Sab196087 
285088Sab196087 /*
295088Sab196087  * String conversion routines for syminfo attributes.
305088Sab196087  */
315088Sab196087 #include	<stdio.h>
325088Sab196087 #include	<sys/machelf.h>
335088Sab196087 #include	"_conv.h"
345088Sab196087 #include	"syminfo_msg.h"
355088Sab196087 
365088Sab196087 
375088Sab196087 
385088Sab196087 #define	FLAGSZ	CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
395088Sab196087 	MSG_SYMINFO_FLG_DIRECT_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
405088Sab196087 	MSG_SYMINFO_FLG_COPY_SIZE	+ CONV_EXPN_FIELD_DEF_SEP_SIZE + \
415088Sab196087 	MSG_SYMINFO_FLG_LAZYLOAD_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
425088Sab196087 	MSG_SYMINFO_FLG_DIRECTBIND_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
435088Sab196087 	CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
445088Sab196087 
455088Sab196087 /*
465088Sab196087  * Ensure that Conv_syminfo_flags_buf_t is large enough:
475088Sab196087  *
485088Sab196087  * FLAGSZ is the real minimum size of the buffer required by
495088Sab196087  * conv_syminfo_flags(). However, Conv_syminfo_flags_buf_t uses
505088Sab196087  * CONV_SYMINFO_FLAGS_BUFSIZE to set the buffer size. We do things
515088Sab196087  * this way because the definition of FLAGSZ uses information that
525088Sab196087  * is not available in the environment of other programs that include
535088Sab196087  * the conv.h header file.
545088Sab196087  */
55*5152Sab196087 #if (CONV_SYMINFO_FLAGS_BUFSIZE != FLAGSZ) && !defined(__lint)
56*5152Sab196087 #define	REPORT_BUFSIZE FLAGSZ
57*5152Sab196087 #include "report_bufsize.h"
58*5152Sab196087 #error "CONV_SYMINFO_FLAGS_BUFSIZE does not match FLAGSZ"
595088Sab196087 #endif
605088Sab196087 
615088Sab196087 const char *
625088Sab196087 conv_syminfo_flags(Xword flags, Conv_fmt_flags_t fmt_flags,
635088Sab196087     Conv_syminfo_flags_buf_t *syminfo_flags_buf)
645088Sab196087 {
655088Sab196087 	static Val_desc vda[] = {
665088Sab196087 		{ SYMINFO_FLG_DIRECT,	MSG_ORIG(MSG_SYMINFO_FLG_DIRECT) },
675088Sab196087 		{ SYMINFO_FLG_COPY,	MSG_ORIG(MSG_SYMINFO_FLG_COPY) },
685088Sab196087 		{ SYMINFO_FLG_LAZYLOAD,	MSG_ORIG(MSG_SYMINFO_FLG_LAZYLOAD) },
695088Sab196087 		{ SYMINFO_FLG_DIRECTBIND,
705088Sab196087 		    MSG_ORIG(MSG_SYMINFO_FLG_DIRECTBIND) },
715088Sab196087 		{ SYMINFO_FLG_NOEXTDIRECT,
725088Sab196087 		    MSG_ORIG(MSG_SYMINFO_FLG_NOEXTDIRECT) },
735088Sab196087 		{ 0,			0 }
745088Sab196087 	};
755088Sab196087 	static CONV_EXPN_FIELD_ARG conv_arg = {
765088Sab196087 	    NULL, sizeof (syminfo_flags_buf->buf), vda };
775088Sab196087 
785088Sab196087 	if (flags == 0)
795088Sab196087 		return (MSG_ORIG(MSG_GBL_ZERO));
805088Sab196087 
815088Sab196087 	conv_arg.buf = syminfo_flags_buf->buf;
825088Sab196087 	conv_arg.oflags = conv_arg.rflags = flags;
835088Sab196087 	conv_arg.prefix = conv_arg.suffix = NULL;
845088Sab196087 	(void) conv_expn_field(&conv_arg, fmt_flags);
855088Sab196087 
865088Sab196087 	return ((const char *)syminfo_flags_buf->buf);
875088Sab196087 }
88