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