1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <string.h>
#include "_conv.h"
#include "dl_msg.h"
#define MODESZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
MSG_RTLD_LAZY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
MSG_RTLD_GLOBAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
MSG_RTLD_NOLOAD_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
MSG_RTLD_PARENT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
MSG_RTLD_GROUP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
MSG_RTLD_WORLD_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
MSG_RTLD_NODELETE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
MSG_RTLD_FIRST_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
MSG_RTLD_CONFGEN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
/*
* Ensure that Conv_dl_mode_buf_t is large enough:
*
* MODESZ is the real minimum size of the buffer required by conv_dl_mode().
* However, Conv_dl_mode_buf_t uses CONV_DL_MODE_BUFSIZE to set the
* buffer size. We do things this way because the definition of MODESZ uses
* information that is not available in the environment of other programs
* that include the conv.h header file.
*/
#if (CONV_DL_MODE_BUFSIZE != MODESZ) && !defined(__lint)
#define REPORT_BUFSIZE MODESZ
#include "report_bufsize.h"
#error "CONV_DL_MODE_BUFSIZE does not match MODESZ"
#endif
/*
* String conversion routine for dlopen() attributes.
*/
const char *
conv_dl_mode(int mode, int fabricate, Conv_dl_mode_buf_t *dl_mode_buf)
{
static const Val_desc vda[] = {
{ RTLD_NOLOAD, MSG_RTLD_NOLOAD },
{ RTLD_PARENT, MSG_RTLD_PARENT },
{ RTLD_GROUP, MSG_RTLD_GROUP },
{ RTLD_WORLD, MSG_RTLD_WORLD },
{ RTLD_NODELETE, MSG_RTLD_NODELETE },
{ RTLD_FIRST, MSG_RTLD_FIRST },
{ RTLD_CONFGEN, MSG_RTLD_CONFGEN },
{ 0, 0 }
};
static const char *leading_str_arr[3];
static CONV_EXPN_FIELD_ARG conv_arg = {
NULL, sizeof (dl_mode_buf->buf), leading_str_arr };
const char **lstr = leading_str_arr;
conv_arg.buf = dl_mode_buf->buf;
conv_arg.oflags = conv_arg.rflags = mode;
if (mode & RTLD_NOW) {
*lstr++ = MSG_ORIG(MSG_RTLD_NOW);
} else if ((mode & RTLD_LAZY) || fabricate) {
*lstr++ = MSG_ORIG(MSG_RTLD_LAZY);
}
if (mode & RTLD_GLOBAL) {
*lstr++ = MSG_ORIG(MSG_RTLD_GLOBAL);
} else if (fabricate) {
*lstr++ = MSG_ORIG(MSG_RTLD_LOCAL);
}
*lstr = NULL;
conv_arg.oflags = mode;
conv_arg.rflags = mode & ~(RTLD_LAZY | RTLD_NOW | RTLD_GLOBAL);
(void) conv_expn_field(&conv_arg, vda, 0);
return ((const char *)dl_mode_buf->buf);
}
/*
* Note: We can use two different sets of prefix/separator/suffix
* strings in conv_dl_flag(), depending on the value of the separator
* argument. To size the buffer, I use the default prefix and suffix
* sizes, and the alternate separator size, because they are larger.
*/
#define FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
MSG_RTLD_REL_RELATIVE_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_REL_EXEC_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_REL_DEPENDS_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_REL_PRELOAD_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_REL_SELF_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_REL_WEAK_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_MEMORY_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_STRIP_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_NOHEAP_SIZE + MSG_GBL_SEP_SIZE + \
MSG_RTLD_CONFSET_SIZE + \
CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
/*
* Ensure that Conv_dl_flag_buf_t is large enough:
*
* FLAGSZ is the real minimum size of the buffer required by conv_dl_flag().
* However, Conv_dl_flag_buf_t uses CONV_DL_FLAG_BUFSIZE to set the
* buffer size. We do things this way because the definition of FLAGSZ uses
* information that is not available in the environment of other programs
* that include the conv.h header file.
*/
#if (CONV_DL_FLAG_BUFSIZE != FLAGSZ) && !defined(__lint)
#define REPORT_BUFSIZE FLAGSZ
#include "report_bufsize.h"
#error "CONV_DL_FLAG_BUFSIZE does not match FLAGSZ"
#endif
/*
* String conversion routine for dldump() flags.
* crle(1) uses this routine to generate update information, and in this case
* we build a "|" separated string.
*/
const char *
conv_dl_flag(int flags, Conv_fmt_flags_t fmt_flags,
Conv_dl_flag_buf_t *dl_flag_buf)
{
static const Val_desc vda[] = {
{ RTLD_REL_RELATIVE, MSG_RTLD_REL_RELATIVE },
{ RTLD_REL_EXEC, MSG_RTLD_REL_EXEC },
{ RTLD_REL_DEPENDS, MSG_RTLD_REL_DEPENDS },
{ RTLD_REL_PRELOAD, MSG_RTLD_REL_PRELOAD },
{ RTLD_REL_SELF, MSG_RTLD_REL_SELF },
{ RTLD_REL_WEAK, MSG_RTLD_REL_WEAK },
{ RTLD_MEMORY, MSG_RTLD_MEMORY },
{ RTLD_STRIP, MSG_RTLD_STRIP },
{ RTLD_NOHEAP, MSG_RTLD_NOHEAP },
{ RTLD_CONFSET, MSG_RTLD_CONFSET },
{ 0, 0 }
};
static const char *leading_str_arr[2];
static CONV_EXPN_FIELD_ARG conv_arg = {
NULL, sizeof (dl_flag_buf->buf), leading_str_arr };
const char **lstr = leading_str_arr;
if (flags == 0)
return (MSG_ORIG(MSG_GBL_ZERO));
conv_arg.buf = dl_flag_buf->buf;
if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_CRLE) {
conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_GBL_QUOTE);
conv_arg.sep = MSG_ORIG(MSG_GBL_SEP);
} else { /* Use default delimiters */
conv_arg.prefix = conv_arg.suffix = conv_arg.sep = NULL;
}
if ((flags & RTLD_REL_ALL) == RTLD_REL_ALL) {
*lstr++ = MSG_ORIG(MSG_RTLD_REL_ALL);
flags &= ~RTLD_REL_ALL;
}
*lstr = NULL;
conv_arg.oflags = conv_arg.rflags = flags;
(void) conv_expn_field(&conv_arg, vda, fmt_flags);
return ((const char *)dl_flag_buf->buf);
}
const char *
conv_dl_info(int request)
{
static const Msg requests[RTLD_DI_MAX] = {
MSG_RTLD_DI_LMID, /* MSG_ORIG(MSG_RTLD_DI_LMID) */
MSG_RTLD_DI_LINKMAP, /* MSG_ORIG(MSG_RTLD_DI_LINKMAP) */
MSG_RTLD_DI_CONFIGADDR, /* MSG_ORIG(MSG_RTLD_DI_CONFIGADDR) */
MSG_RTLD_DI_SERINFO, /* MSG_ORIG(MSG_RTLD_DI_SERINFO) */
MSG_RTLD_DI_SERINFOSIZE, /* MSG_ORIG(MSG_RTLD_DI_SERINFOSIZE) */
MSG_RTLD_DI_ORIGIN, /* MSG_ORIG(MSG_RTLD_DI_ORIGIN) */
MSG_RTLD_DI_PROFILENAME, /* MSG_ORIG(MSG_RTLD_DI_PROFILENAME) */
MSG_RTLD_DI_PROFILEOUT, /* MSG_ORIG(MSG_RTLD_DI_PROFILEOUT) */
MSG_RTLD_DI_GETSIGNAL, /* MSG_ORIG(MSG_RTLD_DI_GETSIGNAL) */
MSG_RTLD_DI_SETSIGNAL, /* MSG_ORIG(MSG_RTLD_DI_SETSIGNAL) */
MSG_RTLD_DI_ARGSINFO, /* MSG_ORIG(MSG_RTLD_DI_ARGSINFO) */
MSG_RTLD_DI_MMAPS, /* MSG_ORIG(MSG_RTLD_DI_MMAPS) */
MSG_RTLD_DI_MMAPCNT, /* MSG_ORIG(MSG_RTLD_DI_MMAPCNT) */
MSG_RTLD_DI_DEFERRED, /* MSG_ORIG(MSG_RTLD_DI_DEFERRED) */
MSG_RTLD_DI_DEFERRED_SYM
/* MSG_ORIG(MSG_RTLD_DI_DEFERRED_SYM) */
};
static Conv_inv_buf_t inv_buf;
#if (RTLD_DI_MAX != RTLD_DI_DEFERRED_SYM)
#error "RTLD_DI_MAX has grown"
#endif
if (request && (request <= RTLD_DI_MAX))
return (MSG_ORIG(requests[request - 1]));
(void) conv_invalid_val(&inv_buf, EC_NATPTR(request), 0);
return (inv_buf.buf);
}
|