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 routines for syminfo attributes. 30 */ 31 #include <stdio.h> 32 #include <sys/machelf.h> 33 #include "_conv.h" 34 #include "syminfo_msg.h" 35 36 37 38 #define FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 39 MSG_SYMINFO_FLG_DIRECT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 40 MSG_SYMINFO_FLG_COPY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 41 MSG_SYMINFO_FLG_LAZYLOAD_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 42 MSG_SYMINFO_FLG_DIRECTBIND_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 43 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 44 45 /* 46 * Ensure that Conv_syminfo_flags_buf_t is large enough: 47 * 48 * FLAGSZ is the real minimum size of the buffer required by 49 * conv_syminfo_flags(). However, Conv_syminfo_flags_buf_t uses 50 * CONV_SYMINFO_FLAGS_BUFSIZE to set the buffer size. We do things 51 * this way because the definition of FLAGSZ uses information that 52 * is not available in the environment of other programs that include 53 * the conv.h header file. 54 */ 55 #if CONV_SYMINFO_FLAGS_BUFSIZE < FLAGSZ 56 #error "CONV_SYMINFO_FLAGS_BUFSIZE is not large enough" 57 #endif 58 59 const char * 60 conv_syminfo_flags(Xword flags, Conv_fmt_flags_t fmt_flags, 61 Conv_syminfo_flags_buf_t *syminfo_flags_buf) 62 { 63 static Val_desc vda[] = { 64 { SYMINFO_FLG_DIRECT, MSG_ORIG(MSG_SYMINFO_FLG_DIRECT) }, 65 { SYMINFO_FLG_COPY, MSG_ORIG(MSG_SYMINFO_FLG_COPY) }, 66 { SYMINFO_FLG_LAZYLOAD, MSG_ORIG(MSG_SYMINFO_FLG_LAZYLOAD) }, 67 { SYMINFO_FLG_DIRECTBIND, 68 MSG_ORIG(MSG_SYMINFO_FLG_DIRECTBIND) }, 69 { SYMINFO_FLG_NOEXTDIRECT, 70 MSG_ORIG(MSG_SYMINFO_FLG_NOEXTDIRECT) }, 71 { 0, 0 } 72 }; 73 static CONV_EXPN_FIELD_ARG conv_arg = { 74 NULL, sizeof (syminfo_flags_buf->buf), vda }; 75 76 if (flags == 0) 77 return (MSG_ORIG(MSG_GBL_ZERO)); 78 79 conv_arg.buf = syminfo_flags_buf->buf; 80 conv_arg.oflags = conv_arg.rflags = flags; 81 conv_arg.prefix = conv_arg.suffix = NULL; 82 (void) conv_expn_field(&conv_arg, fmt_flags); 83 84 return ((const char *)syminfo_flags_buf->buf); 85 } 86