1*2020b2b6SRod Evans /* 2*2020b2b6SRod Evans * CDDL HEADER START 3*2020b2b6SRod Evans * 4*2020b2b6SRod Evans * The contents of this file are subject to the terms of the 5*2020b2b6SRod Evans * Common Development and Distribution License (the "License"). 6*2020b2b6SRod Evans * You may not use this file except in compliance with the License. 7*2020b2b6SRod Evans * 8*2020b2b6SRod Evans * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*2020b2b6SRod Evans * or http://www.opensolaris.org/os/licensing. 10*2020b2b6SRod Evans * See the License for the specific language governing permissions 11*2020b2b6SRod Evans * and limitations under the License. 12*2020b2b6SRod Evans * 13*2020b2b6SRod Evans * When distributing Covered Code, include this CDDL HEADER in each 14*2020b2b6SRod Evans * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*2020b2b6SRod Evans * If applicable, add the following below this CDDL HEADER, with the 16*2020b2b6SRod Evans * fields enclosed by brackets "[]" replaced with your own identifying 17*2020b2b6SRod Evans * information: Portions Copyright [yyyy] [name of copyright owner] 18*2020b2b6SRod Evans * 19*2020b2b6SRod Evans * CDDL HEADER END 20*2020b2b6SRod Evans */ 21*2020b2b6SRod Evans 22*2020b2b6SRod Evans /* 23*2020b2b6SRod Evans * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24*2020b2b6SRod Evans */ 25*2020b2b6SRod Evans 26*2020b2b6SRod Evans #include <string.h> 27*2020b2b6SRod Evans #include <link.h> 28*2020b2b6SRod Evans #include "_conv.h" 29*2020b2b6SRod Evans #include "audit_msg.h" 30*2020b2b6SRod Evans 31*2020b2b6SRod Evans #define BINDSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 32*2020b2b6SRod Evans MSG_LA_FLG_BINDTO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 33*2020b2b6SRod Evans MSG_LA_FLG_BINDFROM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 34*2020b2b6SRod Evans CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 35*2020b2b6SRod Evans 36*2020b2b6SRod Evans /* 37*2020b2b6SRod Evans * Ensure that Conv_la_bind_buf_t is large enough: 38*2020b2b6SRod Evans * 39*2020b2b6SRod Evans * BINDSZ is the real minimum size of the buffer required by conv_la_bind(). 40*2020b2b6SRod Evans * However, Conv_la_bind_buf_t uses CONV_LA_BIND_BUFSIZE to set the 41*2020b2b6SRod Evans * buffer size. We do things this way because the definition of BINDSZ uses 42*2020b2b6SRod Evans * information that is not available in the environment of other programs 43*2020b2b6SRod Evans * that include the conv.h header file. 44*2020b2b6SRod Evans */ 45*2020b2b6SRod Evans #if (CONV_LA_BIND_BUFSIZE != BINDSZ) && !defined(__lint) 46*2020b2b6SRod Evans #define REPORT_BUFSIZE BINDSZ 47*2020b2b6SRod Evans #include "report_bufsize.h" 48*2020b2b6SRod Evans #error "CONV_LA_BIND_BUFSIZE does not match BINDSZ" 49*2020b2b6SRod Evans #endif 50*2020b2b6SRod Evans 51*2020b2b6SRod Evans /* 52*2020b2b6SRod Evans * String conversion routine for la_objopen() return flags. 53*2020b2b6SRod Evans */ 54*2020b2b6SRod Evans const char * 55*2020b2b6SRod Evans conv_la_bind(uint_t bind, Conv_la_bind_buf_t *la_bind_buf) 56*2020b2b6SRod Evans { 57*2020b2b6SRod Evans static const Val_desc vda[] = { 58*2020b2b6SRod Evans { LA_FLG_BINDTO, MSG_LA_FLG_BINDTO }, 59*2020b2b6SRod Evans { LA_FLG_BINDFROM, MSG_LA_FLG_BINDFROM }, 60*2020b2b6SRod Evans { 0, 0 } 61*2020b2b6SRod Evans }; 62*2020b2b6SRod Evans static CONV_EXPN_FIELD_ARG conv_arg = { 63*2020b2b6SRod Evans NULL, sizeof (la_bind_buf->buf), NULL }; 64*2020b2b6SRod Evans 65*2020b2b6SRod Evans if (bind == 0) 66*2020b2b6SRod Evans return (MSG_ORIG(MSG_GBL_ZERO)); 67*2020b2b6SRod Evans 68*2020b2b6SRod Evans conv_arg.buf = la_bind_buf->buf; 69*2020b2b6SRod Evans conv_arg.oflags = conv_arg.rflags = bind; 70*2020b2b6SRod Evans 71*2020b2b6SRod Evans (void) conv_expn_field(&conv_arg, vda, 0); 72*2020b2b6SRod Evans 73*2020b2b6SRod Evans return ((const char *)la_bind_buf->buf); 74*2020b2b6SRod Evans } 75*2020b2b6SRod Evans 76*2020b2b6SRod Evans #define SEARCHSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 77*2020b2b6SRod Evans MSG_LA_SER_ORIG_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 78*2020b2b6SRod Evans MSG_LA_SER_LIBPATH_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 79*2020b2b6SRod Evans MSG_LA_SER_RUNPATH_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 80*2020b2b6SRod Evans MSG_LA_SER_DEFAULT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 81*2020b2b6SRod Evans MSG_LA_SER_CONFIG_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 82*2020b2b6SRod Evans MSG_LA_SER_SECURE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 83*2020b2b6SRod Evans CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 84*2020b2b6SRod Evans 85*2020b2b6SRod Evans /* 86*2020b2b6SRod Evans * Ensure that Conv_la_search_buf_t is large enough: 87*2020b2b6SRod Evans * 88*2020b2b6SRod Evans * SEARCHSZ is the real minimum size of the buffer required by conv_la_search(). 89*2020b2b6SRod Evans * However, Conv_la_search_buf_t uses CONV_LA_SEARCH_BUFSIZE to set the 90*2020b2b6SRod Evans * buffer size. We do things this way because the definition of SEARCHSZ uses 91*2020b2b6SRod Evans * information that is not available in the environment of other programs 92*2020b2b6SRod Evans * that include the conv.h header file. 93*2020b2b6SRod Evans */ 94*2020b2b6SRod Evans #if (CONV_LA_SEARCH_BUFSIZE != SEARCHSZ) && !defined(__lint) 95*2020b2b6SRod Evans #define REPORT_BUFSIZE SEARCHSZ 96*2020b2b6SRod Evans #include "report_bufsize.h" 97*2020b2b6SRod Evans #error "CONV_LA_SEARCH_BUFSIZE does not match SEARCHSZ" 98*2020b2b6SRod Evans #endif 99*2020b2b6SRod Evans 100*2020b2b6SRod Evans /* 101*2020b2b6SRod Evans * String conversion routine for la_objsearch() flags. 102*2020b2b6SRod Evans */ 103*2020b2b6SRod Evans const char * 104*2020b2b6SRod Evans conv_la_search(uint_t search, Conv_la_search_buf_t *la_search_buf) 105*2020b2b6SRod Evans { 106*2020b2b6SRod Evans static const Val_desc vda[] = { 107*2020b2b6SRod Evans { LA_SER_ORIG, MSG_LA_SER_ORIG }, 108*2020b2b6SRod Evans { LA_SER_LIBPATH, MSG_LA_SER_LIBPATH }, 109*2020b2b6SRod Evans { LA_SER_RUNPATH, MSG_LA_SER_RUNPATH }, 110*2020b2b6SRod Evans { LA_SER_DEFAULT, MSG_LA_SER_DEFAULT }, 111*2020b2b6SRod Evans { LA_SER_CONFIG, MSG_LA_SER_CONFIG }, 112*2020b2b6SRod Evans { LA_SER_SECURE, MSG_LA_SER_SECURE }, 113*2020b2b6SRod Evans { 0, 0 } 114*2020b2b6SRod Evans }; 115*2020b2b6SRod Evans static CONV_EXPN_FIELD_ARG conv_arg = { 116*2020b2b6SRod Evans NULL, sizeof (la_search_buf->buf), NULL }; 117*2020b2b6SRod Evans 118*2020b2b6SRod Evans if (search == 0) 119*2020b2b6SRod Evans return (MSG_ORIG(MSG_GBL_NULL)); 120*2020b2b6SRod Evans 121*2020b2b6SRod Evans conv_arg.buf = la_search_buf->buf; 122*2020b2b6SRod Evans conv_arg.oflags = conv_arg.rflags = search; 123*2020b2b6SRod Evans 124*2020b2b6SRod Evans (void) conv_expn_field(&conv_arg, vda, 0); 125*2020b2b6SRod Evans 126*2020b2b6SRod Evans return ((const char *)la_search_buf->buf); 127*2020b2b6SRod Evans } 128*2020b2b6SRod Evans 129*2020b2b6SRod Evans /* 130*2020b2b6SRod Evans * String conversion routine for la_objopen() return flags. 131*2020b2b6SRod Evans */ 132*2020b2b6SRod Evans 133*2020b2b6SRod Evans /* 134*2020b2b6SRod Evans * String conversion routine for la_activity() flags. 135*2020b2b6SRod Evans */ 136*2020b2b6SRod Evans const char * 137*2020b2b6SRod Evans conv_la_activity(uint_t request, Conv_fmt_flags_t fmt_flags, 138*2020b2b6SRod Evans Conv_inv_buf_t *inv_buf) 139*2020b2b6SRod Evans { 140*2020b2b6SRod Evans static const Msg requests[LA_ACT_MAX] = { 141*2020b2b6SRod Evans MSG_LA_ACT_CONSISTENT, /* MSG_ORIG(MSG_LA_ACT_CONSISTENT) */ 142*2020b2b6SRod Evans MSG_LA_ACT_ADD, /* MSG_ORIG(MSG_LA_ACT_ADD) */ 143*2020b2b6SRod Evans MSG_LA_ACT_DELETE /* MSG_ORIG(MSG_LA_ACT_DELETE) */ 144*2020b2b6SRod Evans }; 145*2020b2b6SRod Evans static const conv_ds_msg_t ds_requests = { 146*2020b2b6SRod Evans CONV_DS_MSG_INIT(LA_ACT_CONSISTENT, requests) }; 147*2020b2b6SRod Evans 148*2020b2b6SRod Evans static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_requests), NULL }; 149*2020b2b6SRod Evans 150*2020b2b6SRod Evans return (conv_map_ds(ELFOSABI_NONE, EM_NONE, request, ds, fmt_flags, 151*2020b2b6SRod Evans inv_buf)); 152*2020b2b6SRod Evans } 153*2020b2b6SRod Evans 154*2020b2b6SRod Evans #define SYMBSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 155*2020b2b6SRod Evans MSG_LA_SYMB_NOPLTENTER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 156*2020b2b6SRod Evans MSG_LA_SYMB_NOPLTEXIT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 157*2020b2b6SRod Evans MSG_LA_SYMB_STRUCTCALL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 158*2020b2b6SRod Evans MSG_LA_SYMB_DLSYM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 159*2020b2b6SRod Evans MSG_LA_SYMB_ALTVALUE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 160*2020b2b6SRod Evans CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 161*2020b2b6SRod Evans 162*2020b2b6SRod Evans /* 163*2020b2b6SRod Evans * Ensure that Conv_la_symbind_buf_t is large enough: 164*2020b2b6SRod Evans * 165*2020b2b6SRod Evans * SYMBSZ is the real minimum size of the buffer required by conv_la_symbind(). 166*2020b2b6SRod Evans * However, Conv_la_symbind_buf_t uses CONV_LA_SYMB_BUFSIZE to set the 167*2020b2b6SRod Evans * buffer size. We do things this way because the definition of SYMBSZ uses 168*2020b2b6SRod Evans * information that is not available in the environment of other programs 169*2020b2b6SRod Evans * that include the conv.h header file. 170*2020b2b6SRod Evans */ 171*2020b2b6SRod Evans #if (CONV_LA_SYMBIND_BUFSIZE != SYMBSZ) && !defined(__lint) 172*2020b2b6SRod Evans #define REPORT_BUFSIZE SYMBSZ 173*2020b2b6SRod Evans #include "report_bufsize.h" 174*2020b2b6SRod Evans #error "CONV_LA_SYMBIND_BUFSIZE does not match SYMBSZ" 175*2020b2b6SRod Evans #endif 176*2020b2b6SRod Evans 177*2020b2b6SRod Evans /* 178*2020b2b6SRod Evans * String conversion routine for la_symbind() flags. 179*2020b2b6SRod Evans */ 180*2020b2b6SRod Evans const char * 181*2020b2b6SRod Evans conv_la_symbind(uint_t symbind, Conv_la_symbind_buf_t *la_symbind_buf) 182*2020b2b6SRod Evans { 183*2020b2b6SRod Evans static const Val_desc vda[] = { 184*2020b2b6SRod Evans { LA_SYMB_NOPLTENTER, MSG_LA_SYMB_NOPLTENTER }, 185*2020b2b6SRod Evans { LA_SYMB_NOPLTEXIT, MSG_LA_SYMB_NOPLTEXIT }, 186*2020b2b6SRod Evans { LA_SYMB_STRUCTCALL, MSG_LA_SYMB_STRUCTCALL }, 187*2020b2b6SRod Evans { LA_SYMB_DLSYM, MSG_LA_SYMB_DLSYM }, 188*2020b2b6SRod Evans { LA_SYMB_ALTVALUE, MSG_LA_SYMB_ALTVALUE }, 189*2020b2b6SRod Evans { 0, 0 } 190*2020b2b6SRod Evans }; 191*2020b2b6SRod Evans static CONV_EXPN_FIELD_ARG conv_arg = { 192*2020b2b6SRod Evans NULL, sizeof (la_symbind_buf->buf), NULL }; 193*2020b2b6SRod Evans 194*2020b2b6SRod Evans if (symbind == 0) 195*2020b2b6SRod Evans return (MSG_ORIG(MSG_GBL_NULL)); 196*2020b2b6SRod Evans 197*2020b2b6SRod Evans conv_arg.buf = la_symbind_buf->buf; 198*2020b2b6SRod Evans conv_arg.oflags = conv_arg.rflags = symbind; 199*2020b2b6SRod Evans 200*2020b2b6SRod Evans (void) conv_expn_field(&conv_arg, vda, 0); 201*2020b2b6SRod Evans 202*2020b2b6SRod Evans return ((const char *)la_symbind_buf->buf); 203*2020b2b6SRod Evans } 204