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.
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.
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]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
40 static int localeinit
= 0;
43 * Defer localization overhead until a localized message, is required.
44 * For successful specific (32-bit or 64-bit) commands, none of this
45 * overhead should be incurred.
50 (void) setlocale(LC_MESSAGES
, MSG_ORIG(MSG_STR_EMPTY
));
51 (void) textdomain(MSG_ORIG(MSG_SUNW_OST_SGS
));
57 return (gettext(MSG_ORIG(mid
)));
61 * Error messages from ld.so.1 are formatted as:
63 * ld.so.1: app-name: fatal: ....
65 * Here, we skip over these three components. Thus the message a little less
66 * hostile when displayed by moe(). Really, it would be nice to have some
67 * flexibility over what ld.so.1 displays.
76 * Skip the first three components.
95 openlib(const char *prog
, const char *name
, int class, int silent
, int verbose
)
101 * If the class of object is required, localize the prefix message.
106 modestr
= MSG_INTL(MSG_PRE_64
);
108 modestr
= MSG_INTL(MSG_PRE_32
);
111 modestr
= MSG_ORIG(MSG_STR_EMPTY
);
115 * Open the optimal object, and determine its full name from the
116 * returned handle. Borrow the internal mode, RTLD_CONFGEN, from
117 * crle(1). This flag allows us to process incomplete objects, as
118 * would occur if the object couldn't find its dependencies or relocate
121 if ((handle
= dlmopen(LM_ID_NEWLM
, name
,
122 (RTLD_FIRST
| RTLD_CONFGEN
| RTLD_LAZY
))) == 0) {
124 (void) fprintf(stderr
, MSG_ORIG(MSG_FMT_VERBOSE
), prog
,
125 modestr
, trim_msg(dlerror()));
126 (void) fflush(stderr
);
133 if (dlinfo(handle
, RTLD_DI_LINKMAP
, &lmp
) == -1) {
135 (void) fprintf(stderr
,
136 MSG_ORIG(MSG_FMT_VERBOSE
), prog
, modestr
,
137 trim_msg(dlerror()));
138 (void) fflush(stderr
);
144 (void) printf(MSG_ORIG(MSG_FMT_VERBOSE
), prog
, modestr
,
147 (void) printf(MSG_ORIG(MSG_FMT_SIMPLE
), modestr
,
149 (void) fflush(stdout
);
152 (void) dlclose(handle
);
158 main(int argc
, char **argv
, char **envp
)
160 int var
, verbose
= 0, silent
= 0, error
= 0, mode
= 0, class = 0;
163 if ((prog
= strrchr(argv
[0], '/')) == 0)
169 while ((var
= getopt(argc
, argv
, MSG_ORIG(MSG_STR_OPTIONS
))) != EOF
) {
176 if ((optarg
[0] == '2') && (mode
== 0))
183 if ((optarg
[0] == '4') && (mode
== 0))
207 if (error
|| ((argc
- optind
) == 0)) {
209 (void) fprintf(stderr
, MSG_INTL(MSG_ARG_USAGE
), prog
);
216 * Process any 32-bit expansion.
219 if (mode
!= ONLY64
) {
221 if (openlib(prog
, argv
[optind
], class, silent
, verbose
) != 0) {
232 * Re-exec ourselves to process any 64-bit expansion.
234 #if !defined(__sparcv9) && !defined(__amd64)
235 (void) conv_check_native(argv
, envp
);