group.c revision 8af2c5b9bdbf69a55f079d7ad9483d38fae9f023
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin/*
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * CDDL HEADER START
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * The contents of this file are subject to the terms of the
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * Common Development and Distribution License (the "License").
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * You may not use this file except in compliance with the License.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * or http://www.opensolaris.org/os/licensing.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * See the License for the specific language governing permissions
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * and limitations under the License.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * When distributing Covered Code, include this CDDL HEADER in each
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * If applicable, add the following below this CDDL HEADER, with the
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * fields enclosed by brackets "[]" replaced with your own identifying
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * information: Portions Copyright [yyyy] [name of copyright owner]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * CDDL HEADER END
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin/*
a4aeef46cda1835da2b19f8f62b4526de6521e6cDonghai Qiao * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * Use is subject to license terms.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#pragma ident "%Z%%M% %I% %E% SMI"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#include <string.h>
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#include "rtld.h"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#include "_conv.h"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#include "group_msg.h"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HDLSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPH_ZERO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPH_LDSO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPH_FIRST_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPH_FILTEE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPH_INITIAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPH_NOPENDLAZY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin/*
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * Ensure that Conv_grphdl_flags_buf_t is large enough:
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * HDLSZ is the real minimum size of the buffer required by conv_grphdl_flags().
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * However, Conv_grphdl_flags_buf_t uses CONV_GRPHDL_FLAGS_BUFSIZE to set the
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * buffer size. We do things this way because the definition of HDLSZ uses
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * information that is not available in the environment of other programs
ce67301fa82625f5594913e8ab6abf9e0aa461d0Roland Mainz * that include the conv.h header file.
ce67301fa82625f5594913e8ab6abf9e0aa461d0Roland Mainz */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#if (CONV_GRPHDL_FLAGS_BUFSIZE < HDLSZ) && !defined(__lint)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#error "CONV_GRPHDL_FLAGS_BUFSIZE is not large enough"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#endif
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin/*
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * String conversion routine for Grp_hdl flags.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinconst char *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinconv_grphdl_flags(uint_t flags, Conv_grphdl_flags_buf_t *grphdl_flags_buf)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin{
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin static Val_desc vda[] = {
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPH_ZERO, MSG_ORIG(MSG_GPH_ZERO) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPH_LDSO, MSG_ORIG(MSG_GPH_LDSO) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPH_FIRST, MSG_ORIG(MSG_GPH_FIRST) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPH_FILTEE, MSG_ORIG(MSG_GPH_FILTEE) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPH_INITIAL, MSG_ORIG(MSG_GPH_INITIAL) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPH_NOPENDLAZY, MSG_ORIG(MSG_GPH_NOPENDLAZY) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { 0, 0 }
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin };
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin static CONV_EXPN_FIELD_ARG conv_arg = {
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin NULL, sizeof (grphdl_flags_buf->buf), vda };
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (flags == 0)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin return (MSG_ORIG(MSG_GBL_NULL));
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin conv_arg.buf = grphdl_flags_buf->buf;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin conv_arg.oflags = conv_arg.rflags = flags;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin (void) conv_expn_field(&conv_arg);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin return ((const char *)grphdl_flags_buf->buf);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin}
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define DESCSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPD_DLSYM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPD_RELOC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPD_ADDEPS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPD_PARENT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPD_FILTER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPD_PROMOTE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin MSG_GPD_REMOVE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin/*
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * Ensure that Conv_grpdesc_flags_buf_t is large enough:
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * DESCSZ is the real min size of the buffer required by conv_grpdesc_flags().
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * However, Conv_grpdesc_flags_buf_t uses CONV_GRPDESC_FLAGS_BUFSIZE to set the
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * buffer size. We do things this way because the definition of DESCSZ uses
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * information that is not available in the environment of other programs
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * that include the conv.h header file.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#if (CONV_GRPDESC_FLAGS_BUFSIZE < DESCSZ) && !defined(__lint)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#error "CONV_GRPDESC_FLAGS_BUFSIZE is not large enough"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#endif
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin/*
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * String conversion routine for Grp_desc flags.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinconst char *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinconv_grpdesc_flags(uint_t flags, Conv_grpdesc_flags_buf_t *grpdesc_flags_buf)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin{
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin static Val_desc vda[] = {
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPD_DLSYM, MSG_ORIG(MSG_GPD_DLSYM) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPD_RELOC, MSG_ORIG(MSG_GPD_RELOC) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPD_ADDEPS, MSG_ORIG(MSG_GPD_ADDEPS) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPD_PARENT, MSG_ORIG(MSG_GPD_PARENT) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPD_FILTER, MSG_ORIG(MSG_GPD_FILTER) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPD_PROMOTE, MSG_ORIG(MSG_GPD_PROMOTE) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { GPD_REMOVE, MSG_ORIG(MSG_GPD_REMOVE) },
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { 0, 0 }
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin };
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin static CONV_EXPN_FIELD_ARG conv_arg = {
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin NULL, sizeof (grpdesc_flags_buf->buf), vda };
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (flags == 0)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin return (MSG_ORIG(MSG_GBL_NULL));
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin conv_arg.buf = grpdesc_flags_buf->buf;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin conv_arg.oflags = conv_arg.rflags = flags;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin (void) conv_expn_field(&conv_arg);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin return ((const char *)grpdesc_flags_buf->buf);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin}
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin