xref: /titanic_44/usr/src/cmd/sgs/libld/common/args.c (revision 9df12a23948bd40cbe37ce88d84e272c3894e675)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  *	Copyright (c) 1988 AT&T
24  *	  All Rights Reserved
25  *
26  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Publically available flags are defined in ld(1).   The following flags are
33  * private, and may be removed at any time.
34  *
35  *    OPTION			MEANING
36  *
37  *    -z dtrace=symbol		assigns symbol to PT_SUNWDTRACE segment,
38  *    				providing scratch ares for dtrace processing.
39  *
40  *    -z noreloc		suppress relocation processing.  This provides
41  *				a mechanism for validating kernel module symbol
42  *				resolution that would normally incur fatal
43  *				relocation errors.
44  *
45  *    -z rtldinfo=symbol	assigns symbol to SUNW_RTLDINF dynamic tag,
46  *				providing pre-initialization specific routines
47  *				for TLS initialization.
48  */
49 #include	<sys/link.h>
50 #include	<stdio.h>
51 #include	<fcntl.h>
52 #include	<string.h>
53 #include	<errno.h>
54 #include	<elf.h>
55 #include	<unistd.h>
56 #include	<debug.h>
57 #include	"msg.h"
58 #include	"_libld.h"
59 
60 /*
61  * Define a set of local argument flags, the settings of these will be
62  * verified in check_flags() and lead to the appropriate output file flags
63  * being initialized.
64  */
65 typedef	enum {
66 	SET_UNKNOWN = -1,
67 	SET_FALSE = 0,
68 	SET_TRUE = 1
69 } Setstate;
70 
71 static Setstate	dflag	= SET_UNKNOWN;
72 static Setstate	zdflag	= SET_UNKNOWN;
73 static Setstate	Qflag	= SET_UNKNOWN;
74 static Setstate	Bdflag	= SET_UNKNOWN;
75 
76 static Boolean	aflag	= FALSE;
77 static Boolean	bflag	= FALSE;
78 static Boolean	rflag	= FALSE;
79 static Boolean	sflag	= FALSE;
80 static Boolean	zinflag = FALSE;
81 static Boolean	zlflag	= FALSE;
82 static Boolean	Bgflag	= FALSE;
83 static Boolean	Blflag	= FALSE;
84 static Boolean	Beflag	= FALSE;
85 static Boolean	Bsflag	= FALSE;
86 static Boolean	Btflag	= FALSE;
87 static Boolean	Gflag	= FALSE;
88 static Boolean	Vflag	= FALSE;
89 
90 /*
91  * ztflag's state is set by pointing it to the matching string:
92  *	text | textoff | textwarn
93  */
94 static const char	*ztflag = 0;
95 
96 static uintptr_t process_files_com(Ofl_desc *, int, char **);
97 static uintptr_t process_flags_com(Ofl_desc *, int, char **, int *);
98 
99 /*
100  * Print usage message to stderr - 2 modes, summary message only,
101  * and full usage message.
102  */
103 static void
104 usage_mesg(Boolean detail)
105 {
106 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_USAGE),
107 	    MSG_ORIG(MSG_STR_OPTIONS));
108 
109 	if (detail == FALSE)
110 		return;
111 
112 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_6));
113 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_A));
114 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_B));
115 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CBDR));
116 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CBDY));
117 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CBE));
118 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CBG));
119 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CBL));
120 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CBR));
121 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CBS));
122 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_C));
123 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CC));
124 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_D));
125 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CD));
126 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_E));
127 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_F));
128 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CF));
129 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CG));
130 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_H));
131 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_I));
132 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CI));
133 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_L));
134 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CL));
135 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_M));
136 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CM));
137 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CN));
138 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_O));
139 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_P));
140 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CP));
141 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CQ));
142 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_R));
143 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CR));
144 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_S));
145 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CS));
146 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_T));
147 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_U));
148 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CV));
149 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CY));
150 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZA));
151 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZAE));
152 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZC));
153 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNC));
154 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZDFS));
155 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZDRS));
156 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZE));
157 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZFA));
158 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZGP));
159 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZH));
160 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZIG));
161 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZINA));
162 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZINI));
163 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZINT));
164 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZLAZY));
165 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZLD32));
166 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZLD64));
167 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZLO));
168 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZM));
169 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDFS));
170 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDEF));
171 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDEL));
172 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDLO));
173 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDU));
174 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNPA));
175 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNV));
176 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNOW));
177 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZO));
178 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZPIA));
179 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRL));
180 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRS));
181 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZT));
182 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTO));
183 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTW));
184 	(void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZV));
185 }
186 
187 /*
188  * Checks the command line option flags for consistency.
189  */
190 static uintptr_t
191 check_flags(Ofl_desc * ofl, int argc)
192 {
193 	if (Plibpath && (Llibdir || Ulibdir)) {
194 		eprintf(ofl->ofl_lml, ERR_FATAL, MSG_INTL(MSG_ARG_YP),
195 		    Llibdir ? 'L' : 'U');
196 		ofl->ofl_flags |= FLG_OF_FATAL;
197 	}
198 
199 	if (rflag) {
200 		if (dflag == SET_UNKNOWN)
201 			dflag = SET_FALSE;
202 		if (ofl->ofl_flags1 & FLG_OF1_RELCNT) {
203 			eprintf(ofl->ofl_lml, ERR_WARNING,
204 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_R),
205 			    MSG_ORIG(MSG_ARG_ZCOMBRELOC));
206 			ofl->ofl_flags1 &= ~FLG_OF1_RELCNT;
207 		}
208 		ofl->ofl_flags |= FLG_OF_RELOBJ;
209 	}
210 
211 	if (zdflag == SET_TRUE)
212 		ofl->ofl_flags |= FLG_OF_NOUNDEF;
213 
214 	if (zinflag)
215 		ofl->ofl_dtflags_1 |= DF_1_INTERPOSE;
216 
217 	if (sflag)
218 		ofl->ofl_flags |= FLG_OF_STRIP;
219 
220 	if (Qflag == SET_TRUE)
221 		ofl->ofl_flags |= FLG_OF_ADDVERS;
222 
223 	if (Blflag)
224 		ofl->ofl_flags |= FLG_OF_AUTOLCL;
225 
226 	if (Beflag)
227 		ofl->ofl_flags1 |= FLG_OF1_AUTOELM;
228 
229 	if (Blflag && Beflag) {
230 		eprintf(ofl->ofl_lml, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
231 		    MSG_ORIG(MSG_ARG_BELIMINATE), MSG_ORIG(MSG_ARG_BLOCAL));
232 		ofl->ofl_flags |= FLG_OF_FATAL;
233 	}
234 
235 	if (dflag != SET_FALSE) {
236 		/*
237 		 * Set -Bdynamic on by default, setting is rechecked as input
238 		 * files are processed.
239 		 */
240 		ofl->ofl_flags |=
241 		    (FLG_OF_DYNAMIC | FLG_OF_DYNLIBS | FLG_OF_PROCRED);
242 
243 		if (aflag) {
244 			eprintf(ofl->ofl_lml, ERR_FATAL,
245 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_DY),
246 			    MSG_ORIG(MSG_ARG_A));
247 			ofl->ofl_flags |= FLG_OF_FATAL;
248 		}
249 
250 		if (bflag)
251 			ofl->ofl_flags |= FLG_OF_BFLAG;
252 
253 		if (Bgflag == TRUE) {
254 			if (zdflag == SET_FALSE) {
255 				eprintf(ofl->ofl_lml, ERR_FATAL,
256 				    MSG_INTL(MSG_ARG_INCOMP),
257 				    MSG_ORIG(MSG_ARG_BGROUP),
258 				    MSG_ORIG(MSG_ARG_ZNODEF));
259 				ofl->ofl_flags |= FLG_OF_FATAL;
260 			}
261 			ofl->ofl_dtflags_1 |= DF_1_GROUP;
262 			ofl->ofl_flags |= FLG_OF_NOUNDEF;
263 		}
264 
265 		/*
266 		 * If the use of default library searching has been suppressed
267 		 * but no runpaths have been provided we're going to have a hard
268 		 * job running this object.
269 		 */
270 		if ((ofl->ofl_dtflags_1 & DF_1_NODEFLIB) && !ofl->ofl_rpath)
271 			eprintf(ofl->ofl_lml, ERR_WARNING,
272 			    MSG_INTL(MSG_ARG_NODEFLIB));
273 
274 		/*
275 		 * By default, text relocation warnings are given when building
276 		 * an executable unless the -b flag is specified.  This option
277 		 * implies that unclean text can be created, so no warnings are
278 		 * generated unless specifically asked for.
279 		 */
280 		if ((ztflag == MSG_ORIG(MSG_ARG_ZTEXTOFF)) ||
281 		    ((ztflag == 0) && bflag))
282 			ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
283 		else if (ztflag == MSG_ORIG(MSG_ARG_ZTEXT))
284 			ofl->ofl_flags |= FLG_OF_PURETXT;
285 
286 		if (Gflag || !rflag) {
287 			/*
288 			 * Create a dynamic object.  -Bdirect indicates that all
289 			 * references should be bound directly.  This also
290 			 * enables lazyloading.  Individual symbols can be
291 			 * bound directly (or not) using mapfiles and the
292 			 * DIRECT (NODIRECT) qualifier.  With this capability,
293 			 * each syminfo entry is tagged SYMINFO_FLG_DIRECTBIND.
294 			 * Prior to this per-symbol direct binding, runtime
295 			 * direct binding was controlled via the DF_1_DIRECT
296 			 * flag.  This flag affected all references from the
297 			 * object.  -Bdirect continues to set this flag, and
298 			 * thus provides a means of taking a newly built
299 			 * direct binding object back to older systems.
300 			 *
301 			 * NOTE, any use of per-symbol NODIRECT bindings, or
302 			 * -znodirect, will disable the creation of the
303 			 * DF_1_DIRECT flag.  Older runtime linkers do not
304 			 * have the capability to do per-symbol direct bindings.
305 			 */
306 			if (Bdflag == SET_TRUE) {
307 				ofl->ofl_dtflags_1 |= DF_1_DIRECT;
308 				ofl->ofl_flags1 |= FLG_OF1_LAZYLD;
309 				ofl->ofl_flags |= FLG_OF_SYMINFO;
310 			}
311 
312 			/*
313 			 * -Bnodirect disables directly binding to any symbols
314 			 * exported from the object being created.  Individual
315 			 * references to external objects can still be affected
316 			 * by -zdirect or mapfile DIRECT directives.
317 			 */
318 			if (Bdflag == SET_FALSE) {
319 				ofl->ofl_dtflags_1 |= DF_1_NODIRECT;
320 				ofl->ofl_flags1 |=
321 				    (FLG_OF1_NDIRECT | FLG_OF1_ALNODIR);
322 				ofl->ofl_flags |= FLG_OF_SYMINFO;
323 			}
324 		}
325 
326 		if (!Gflag && !rflag) {
327 			/*
328 			 * Dynamically linked executable.
329 			 */
330 			ofl->ofl_flags |= FLG_OF_EXEC;
331 
332 			if (zdflag != SET_FALSE)
333 				ofl->ofl_flags |= FLG_OF_NOUNDEF;
334 
335 			if (Bsflag) {
336 				eprintf(ofl->ofl_lml, ERR_FATAL,
337 				    MSG_INTL(MSG_ARG_DYNINCOMP),
338 				    MSG_ORIG(MSG_ARG_BSYMBOLIC));
339 				ofl->ofl_flags |= FLG_OF_FATAL;
340 			}
341 			if (ofl->ofl_soname) {
342 				eprintf(ofl->ofl_lml, ERR_FATAL,
343 				    MSG_INTL(MSG_ARG_DYNINCOMP),
344 				    MSG_ORIG(MSG_ARG_H));
345 				ofl->ofl_flags |= FLG_OF_FATAL;
346 			}
347 			if (Btflag) {
348 				eprintf(ofl->ofl_lml, ERR_FATAL,
349 				    MSG_INTL(MSG_ARG_DYNINCOMP),
350 				    MSG_ORIG(MSG_ARG_BTRANS));
351 				ofl->ofl_flags |= FLG_OF_FATAL;
352 			}
353 			if (ofl->ofl_filtees) {
354 				if (ofl->ofl_flags & FLG_OF_AUX) {
355 					eprintf(ofl->ofl_lml, ERR_FATAL,
356 					    MSG_INTL(MSG_ARG_DYNINCOMP),
357 					    MSG_ORIG(MSG_ARG_F));
358 				} else {
359 					eprintf(ofl->ofl_lml, ERR_FATAL,
360 					    MSG_INTL(MSG_ARG_DYNINCOMP),
361 					    MSG_ORIG(MSG_ARG_CF));
362 				}
363 				ofl->ofl_flags |= FLG_OF_FATAL;
364 			}
365 
366 		} else if (!rflag) {
367 			/*
368 			 * Shared library.
369 			 */
370 			ofl->ofl_flags |= FLG_OF_SHAROBJ;
371 
372 			/*
373 			 * By default we print relocation errors for
374 			 * executables but *not* for a shared object
375 			 */
376 			if (ztflag == 0)
377 				ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
378 
379 			if (Bsflag) {
380 				ofl->ofl_flags |= FLG_OF_SYMBOLIC;
381 				ofl->ofl_dtflags |= DF_SYMBOLIC;
382 			}
383 
384 			if (Btflag) {
385 				ofl->ofl_dtflags_1 |=
386 				    (DF_1_TRANS | DF_1_DIRECT);
387 				ofl->ofl_flags |= FLG_OF_SYMINFO;
388 			}
389 
390 		} else {
391 			/*
392 			 * Dynamic relocatable object
393 			 */
394 			/*
395 			 * By default we print relocation errors for
396 			 * executables but *not* for a shared object
397 			 */
398 			if (ztflag == 0)
399 				ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
400 		}
401 	} else {
402 		ofl->ofl_flags |= FLG_OF_STATIC;
403 
404 		if (bflag) {
405 			eprintf(ofl->ofl_lml, ERR_FATAL,
406 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_DN),
407 			    MSG_ORIG(MSG_ARG_B));
408 			ofl->ofl_flags |= FLG_OF_FATAL;
409 		}
410 		if (ofl->ofl_soname) {
411 			eprintf(ofl->ofl_lml, ERR_FATAL,
412 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_DN),
413 			    MSG_ORIG(MSG_ARG_H));
414 			ofl->ofl_flags |= FLG_OF_FATAL;
415 		}
416 		if (ofl->ofl_depaudit) {
417 			eprintf(ofl->ofl_lml, ERR_FATAL,
418 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_DN),
419 			    MSG_ORIG(MSG_ARG_P));
420 			ofl->ofl_flags |= FLG_OF_FATAL;
421 		}
422 		if (ofl->ofl_audit) {
423 			eprintf(ofl->ofl_lml, ERR_FATAL,
424 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_DN),
425 			    MSG_ORIG(MSG_ARG_CP));
426 			ofl->ofl_flags |= FLG_OF_FATAL;
427 		}
428 		if (ofl->ofl_config) {
429 			eprintf(ofl->ofl_lml, ERR_FATAL,
430 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_DN),
431 			    MSG_ORIG(MSG_ARG_C));
432 			ofl->ofl_flags |= FLG_OF_FATAL;
433 		}
434 		if (ofl->ofl_filtees) {
435 			if (ofl->ofl_flags & FLG_OF_AUX) {
436 				eprintf(ofl->ofl_lml, ERR_FATAL,
437 				    MSG_INTL(MSG_ARG_INCOMP),
438 				    MSG_ORIG(MSG_ARG_DN), MSG_ORIG(MSG_ARG_F));
439 			} else {
440 				eprintf(ofl->ofl_lml, ERR_FATAL,
441 				    MSG_INTL(MSG_ARG_INCOMP),
442 				    MSG_ORIG(MSG_ARG_DN), MSG_ORIG(MSG_ARG_CF));
443 			}
444 			ofl->ofl_flags |= FLG_OF_FATAL;
445 		}
446 		if (ztflag) {
447 			eprintf(ofl->ofl_lml, ERR_FATAL,
448 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_DN),
449 			    MSG_ORIG(MSG_ARG_ZTEXTALL));
450 			ofl->ofl_flags |= FLG_OF_FATAL;
451 		}
452 		if (Gflag) {
453 			eprintf(ofl->ofl_lml, ERR_FATAL,
454 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_DN),
455 			    MSG_ORIG(MSG_ARG_CG));
456 			ofl->ofl_flags |= FLG_OF_FATAL;
457 		}
458 		if (aflag && rflag) {
459 			eprintf(ofl->ofl_lml, ERR_FATAL,
460 			    MSG_INTL(MSG_ARG_INCOMP), MSG_ORIG(MSG_ARG_A),
461 			    MSG_ORIG(MSG_ARG_R));
462 			ofl->ofl_flags |= FLG_OF_FATAL;
463 		}
464 
465 		if (rflag) {
466 			/*
467 			 * We can only strip the symbol table and string table
468 			 * if no output relocations will refer to them
469 			 */
470 			if (sflag) {
471 				eprintf(ofl->ofl_lml, ERR_WARNING,
472 				    MSG_INTL(MSG_ARG_STRIP));
473 			}
474 
475 			if (ztflag == 0)
476 				ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
477 
478 			if (ofl->ofl_interp) {
479 				eprintf(ofl->ofl_lml, ERR_FATAL,
480 				    MSG_INTL(MSG_ARG_INCOMP),
481 				    MSG_ORIG(MSG_ARG_R), MSG_ORIG(MSG_ARG_CI));
482 				ofl->ofl_flags |= FLG_OF_FATAL;
483 			}
484 		} else {
485 			/*
486 			 * Static executable.
487 			 */
488 			ofl->ofl_flags |= FLG_OF_EXEC | FLG_OF_PROCRED;
489 
490 			if (zdflag != SET_FALSE)
491 				ofl->ofl_flags |= FLG_OF_NOUNDEF;
492 		}
493 	}
494 
495 	/*
496 	 * If the user didn't supply an output file name supply a default.
497 	 */
498 	if (ofl->ofl_name == NULL)
499 		ofl->ofl_name = MSG_ORIG(MSG_STR_AOUT);
500 
501 	/*
502 	 * We set the entrance criteria after all input argument processing as
503 	 * it is only at this point we're sure what the output image will be
504 	 * (static or dynamic).
505 	 */
506 	if (ld_ent_setup(ofl, M_SEGM_ALIGN) == S_ERROR)
507 		return (S_ERROR);
508 
509 	/*
510 	 * Process any mapfiles after establishing the entrance criteria as
511 	 * the user may be redefining or adding sections/segments.
512 	 */
513 	if (ofl->ofl_maps.head) {
514 		Listnode	*lnp;
515 		const char	*name;
516 
517 		for (LIST_TRAVERSE(&ofl->ofl_maps, lnp, name))
518 			if (ld_map_parse(name, ofl) == S_ERROR)
519 				return (S_ERROR);
520 
521 		if (ofl->ofl_flags & FLG_OF_SEGSORT)
522 			if (ld_sort_seg_list(ofl) == S_ERROR)
523 				return (S_ERROR);
524 	}
525 
526 	/*
527 	 * If -zloadfltr is set, verify that filtering is in effect.  Filters
528 	 * are either established from the command line, and affect the whole
529 	 * object, or are set on a per-symbol basis from a mapfile.
530 	 */
531 	if (zlflag) {
532 		if ((ofl->ofl_filtees == 0) && (ofl->ofl_dtsfltrs == 0)) {
533 			eprintf(ofl->ofl_lml, ERR_FATAL,
534 			    MSG_INTL(MSG_ARG_NOFLTR),
535 			    MSG_ORIG(MSG_ARG_ZLOADFLTR));
536 			ofl->ofl_flags |= FLG_OF_FATAL;
537 		}
538 		ofl->ofl_dtflags_1 |= DF_1_LOADFLTR;
539 	}
540 
541 	/*
542 	 * Check that we have something to work with.  This check is carried out
543 	 * after mapfile processing as its possible a mapfile is being used to
544 	 * define symbols, in which case it would be sufficient to build the
545 	 * output file purely from the mapfile.
546 	 */
547 	if ((ofl->ofl_objscnt == 0) && (ofl->ofl_soscnt == 0)) {
548 		if (Vflag && (argc == 2))
549 			ofl->ofl_flags1 |= FLG_OF1_DONE;
550 		else {
551 			eprintf(ofl->ofl_lml, ERR_FATAL,
552 			    MSG_INTL(MSG_ARG_NOFILES));
553 			return (S_ERROR);
554 		}
555 	}
556 	return (1);
557 }
558 
559 /*
560  * Decompose the string pointed by optarg into argv[][] so that argv[][] can be
561  * used as an argument to getopt().
562  *
563  * If the second argument 'error' is not 0, then this is called from the first
564  * pass. Else this is called from the second pass.
565  */
566 static uintptr_t
567 createargv(Ofl_desc *ofl, int *error)
568 {
569 	int		argc = 0, idx = 0, ooptind;
570 	uintptr_t	ret;
571 	char		**argv, *p0;
572 
573 	/*
574 	 * The argument being examined is either:
575 	 *	ld32= 	or
576 	 *	ld64=
577 	 */
578 #if	defined(_LP64)
579 	if (optarg[2] == '3')
580 		return (0);
581 #else
582 	if (optarg[2] == '6')
583 		return (0);
584 #endif
585 
586 	p0 = &optarg[5];
587 
588 	/*
589 	 * Count the number of arguments.
590 	 */
591 	while (*p0) {
592 		/*
593 		 * Pointing at non-separator character.
594 		 */
595 		if (*p0 != ',') {
596 			argc++;
597 			while (*p0 && (*p0 != ','))
598 				p0++;
599 			continue;
600 		}
601 
602 		/*
603 		 * Pointing at a separator character.
604 		 */
605 		if (*p0 == ',') {
606 			while (*p0 == ',')
607 				p0++;
608 			continue;
609 		}
610 	}
611 
612 	if (argc == 0)
613 		return (0);
614 
615 	/*
616 	 * Allocate argument vector.
617 	 */
618 	if ((p0 = (char *)strdup(&optarg[5])) == 0)
619 		return (S_ERROR);
620 	if ((argv = libld_malloc((sizeof (char *)) * (argc + 1))) == 0)
621 		return (S_ERROR);
622 
623 	while (*p0) {
624 		char *p;
625 
626 		/*
627 		 * Pointing at the beginning of non-separator character string.
628 		 */
629 		if (*p0 != ',') {
630 			p = p0;
631 			while (*p0 && (*p0 != ','))
632 				p0++;
633 			argv[idx++] = p;
634 			if (*p0) {
635 				*p0 = '\0';
636 				p0++;
637 			}
638 			continue;
639 		}
640 
641 		/*
642 		 * Pointing at the beginining of separator character string.
643 		 */
644 		if (*p0 == ',') {
645 			while (*p0 == ',')
646 				p0++;
647 			continue;
648 		}
649 	}
650 	argv[idx] = 0;
651 	ooptind = optind;
652 	optind = 0;
653 
654 	/*
655 	 * Dispatch to pass1 or pass2
656 	 */
657 	if (error)
658 		ret = process_flags_com(ofl, argc, argv, error);
659 	else
660 		ret = process_files_com(ofl, argc, argv);
661 
662 	optind = ooptind;
663 
664 	if (ret == S_ERROR)
665 		return (S_ERROR);
666 
667 	return (argc);
668 }
669 
670 /*
671  * Parsing options pass1 for process_flags().
672  */
673 static uintptr_t
674 parseopt_pass1(Ofl_desc *ofl, int argc, char **argv, int *error)
675 {
676 	int	c;
677 
678 	while ((c = getopt(argc, argv, MSG_ORIG(MSG_STR_OPTIONS))) != -1) {
679 		DBG_CALL(Dbg_args_flags(ofl->ofl_lml, (optind - 1), c));
680 
681 		switch (c) {
682 		case '6':			/* Processed by ld to */
683 			/*
684 			 * -64 is processed by ld to determine the output class.
685 			 * Here we sanity check the option incase some other
686 			 * -6* option is mistakenly passed to us.
687 			 */
688 			if (optarg[0] != '4') {
689 				eprintf(ofl->ofl_lml, ERR_FATAL,
690 				    MSG_INTL(MSG_ARG_ILLEGAL),
691 				    MSG_ORIG(MSG_ARG_6), optarg);
692 				ofl->ofl_flags |= FLG_OF_FATAL;
693 			}
694 			continue;
695 
696 		case 'a':
697 			aflag = TRUE;
698 			break;
699 
700 		case 'b':
701 			bflag = TRUE;
702 			break;
703 
704 		case 'c':
705 			if (ofl->ofl_config)
706 				eprintf(ofl->ofl_lml, ERR_WARNING,
707 				    MSG_INTL(MSG_ARG_MTONCE),
708 				    MSG_ORIG(MSG_ARG_C));
709 			else
710 				ofl->ofl_config = optarg;
711 			break;
712 
713 		case 'C':
714 			demangle_flag = 1;
715 			break;
716 
717 		case 'd':
718 			if ((optarg[0] == 'n') && (optarg[1] == '\0')) {
719 				if (dflag != SET_UNKNOWN)
720 					eprintf(ofl->ofl_lml, ERR_WARNING,
721 					    MSG_INTL(MSG_ARG_MTONCE),
722 					    MSG_ORIG(MSG_ARG_D));
723 				else
724 					dflag = SET_FALSE;
725 			} else if ((optarg[0] == 'y') && (optarg[1] == '\0')) {
726 				if (dflag != SET_UNKNOWN)
727 					eprintf(ofl->ofl_lml, ERR_WARNING,
728 					    MSG_INTL(MSG_ARG_MTONCE),
729 					    MSG_ORIG(MSG_ARG_D));
730 				else
731 					dflag = SET_TRUE;
732 			} else {
733 				eprintf(ofl->ofl_lml, ERR_FATAL,
734 				    MSG_INTL(MSG_ARG_ILLEGAL),
735 				    MSG_ORIG(MSG_ARG_D), optarg);
736 				ofl->ofl_flags |= FLG_OF_FATAL;
737 			}
738 			break;
739 
740 		case 'e':
741 			if (ofl->ofl_entry)
742 				eprintf(ofl->ofl_lml, ERR_WARNING,
743 				    MSG_INTL(MSG_ARG_MTONCE),
744 				    MSG_ORIG(MSG_ARG_E));
745 			else
746 				ofl->ofl_entry = (void *)optarg;
747 			break;
748 
749 		case 'f':
750 			if (ofl->ofl_filtees &&
751 			    (!(ofl->ofl_flags & FLG_OF_AUX))) {
752 				eprintf(ofl->ofl_lml, ERR_FATAL,
753 				    MSG_INTL(MSG_ARG_INCOMP),
754 				    MSG_ORIG(MSG_ARG_F), MSG_ORIG(MSG_ARG_CF));
755 				ofl->ofl_flags |= FLG_OF_FATAL;
756 			} else {
757 				if ((ofl->ofl_filtees =
758 				    add_string(ofl->ofl_filtees, optarg)) ==
759 				    (const char *)S_ERROR)
760 					return (S_ERROR);
761 				ofl->ofl_flags |= FLG_OF_AUX;
762 			}
763 			break;
764 
765 		case 'F':
766 			if (ofl->ofl_filtees &&
767 			    (ofl->ofl_flags & FLG_OF_AUX)) {
768 				eprintf(ofl->ofl_lml, ERR_FATAL,
769 				    MSG_INTL(MSG_ARG_INCOMP),
770 				    MSG_ORIG(MSG_ARG_CF), MSG_ORIG(MSG_ARG_F));
771 				ofl->ofl_flags |= FLG_OF_FATAL;
772 			} else {
773 				if ((ofl->ofl_filtees =
774 				    add_string(ofl->ofl_filtees, optarg)) ==
775 				    (const char *)S_ERROR)
776 					return (S_ERROR);
777 			}
778 			break;
779 
780 		case 'h':
781 			if (ofl->ofl_soname)
782 				eprintf(ofl->ofl_lml, ERR_WARNING,
783 				    MSG_INTL(MSG_ARG_MTONCE),
784 				    MSG_ORIG(MSG_ARG_H));
785 			else
786 				ofl->ofl_soname = (const char *)optarg;
787 			break;
788 
789 		case 'i':
790 			ofl->ofl_flags |= FLG_OF_IGNENV;
791 			break;
792 
793 		case 'I':
794 			if (ofl->ofl_interp)
795 				eprintf(ofl->ofl_lml, ERR_WARNING,
796 				    MSG_INTL(MSG_ARG_MTONCE),
797 				    MSG_ORIG(MSG_ARG_CI));
798 			else
799 				ofl->ofl_interp = (const char *)optarg;
800 			break;
801 
802 		case 'l':
803 			/*
804 			 * For now, count any library as a shared object.  This
805 			 * is used to size the internal symbol cache.  This
806 			 * value is recalculated later on actual file processing
807 			 * to get an accurate shared object count.
808 			 */
809 			ofl->ofl_soscnt++;
810 			break;
811 
812 		case 'm':
813 			ofl->ofl_flags |= FLG_OF_GENMAP;
814 			break;
815 
816 		case 'o':
817 			if (ofl->ofl_name)
818 				eprintf(ofl->ofl_lml, ERR_WARNING,
819 				    MSG_INTL(MSG_ARG_MTONCE),
820 				    MSG_ORIG(MSG_ARG_O));
821 			else
822 				ofl->ofl_name = (const char *)optarg;
823 			break;
824 
825 		case 'p':
826 			/*
827 			 * Multiple instances of this option may occur.  Each
828 			 * additional instance is effectively concatenated to
829 			 * the previous separated by a colon.
830 			 */
831 			if (*optarg != '\0') {
832 				if ((ofl->ofl_audit =
833 				    add_string(ofl->ofl_audit,
834 				    optarg)) == (const char *)S_ERROR)
835 					return (S_ERROR);
836 			}
837 			break;
838 
839 		case 'P':
840 			/*
841 			 * Multiple instances of this option may occur.  Each
842 			 * additional instance is effectively concatenated to
843 			 * the previous separated by a colon.
844 			 */
845 			if (*optarg != '\0') {
846 				if ((ofl->ofl_depaudit =
847 				    add_string(ofl->ofl_depaudit,
848 				    optarg)) == (const char *)S_ERROR)
849 					return (S_ERROR);
850 			}
851 			break;
852 
853 		case 'r':
854 			rflag = TRUE;
855 			break;
856 
857 		case 'R':
858 			/*
859 			 * Multiple instances of this option may occur.  Each
860 			 * additional instance is effectively concatenated to
861 			 * the previous separated by a colon.
862 			 */
863 			if (*optarg != '\0') {
864 				if ((ofl->ofl_rpath =
865 				    add_string(ofl->ofl_rpath,
866 				    optarg)) == (const char *)S_ERROR)
867 					return (S_ERROR);
868 			}
869 			break;
870 
871 		case 's':
872 			sflag = TRUE;
873 			break;
874 
875 		case 't':
876 			ofl->ofl_flags |= FLG_OF_NOWARN;
877 			break;
878 
879 		case 'u':
880 			break;
881 
882 		case 'z':
883 			/*
884 			 * For specific help, print our usage message and exit
885 			 * immediately to insure a 0 return code.
886 			 */
887 			if (strncmp(optarg, MSG_ORIG(MSG_ARG_HELP),
888 			    MSG_ARG_HELP_SIZE) == 0) {
889 				usage_mesg(1);
890 				exit(0);
891 			}
892 
893 			/*
894 			 * For some options set a flag - further consistancy
895 			 * checks will be carried out in check_flags().
896 			 */
897 			if ((strncmp(optarg, MSG_ORIG(MSG_ARG_LD32),
898 			    MSG_ARG_LD32_SIZE) == 0) ||
899 			    (strncmp(optarg, MSG_ORIG(MSG_ARG_LD64),
900 			    MSG_ARG_LD64_SIZE) == 0)) {
901 				if (createargv(ofl, error) == S_ERROR)
902 					return (S_ERROR);
903 
904 			} else if (
905 			    strcmp(optarg, MSG_ORIG(MSG_ARG_DEFS)) == 0) {
906 				if (zdflag != SET_UNKNOWN)
907 					eprintf(ofl->ofl_lml, ERR_WARNING,
908 					    MSG_INTL(MSG_ARG_MTONCE),
909 					    MSG_ORIG(MSG_ARG_ZDEFNODEF));
910 				else
911 					zdflag = SET_TRUE;
912 			} else if (strcmp(optarg,
913 			    MSG_ORIG(MSG_ARG_NODEFS)) == 0) {
914 				if (zdflag != SET_UNKNOWN)
915 					eprintf(ofl->ofl_lml, ERR_WARNING,
916 					    MSG_INTL(MSG_ARG_MTONCE),
917 					    MSG_ORIG(MSG_ARG_ZDEFNODEF));
918 				else
919 					zdflag = SET_FALSE;
920 			} else if (strcmp(optarg,
921 			    MSG_ORIG(MSG_ARG_TEXT)) == 0) {
922 				if (ztflag &&
923 				    (ztflag != MSG_ORIG(MSG_ARG_ZTEXT))) {
924 					eprintf(ofl->ofl_lml, ERR_FATAL,
925 					    MSG_INTL(MSG_ARG_INCOMP),
926 					    MSG_ORIG(MSG_ARG_ZTEXT),
927 					    ztflag);
928 					ofl->ofl_flags |= FLG_OF_FATAL;
929 				}
930 				ztflag = MSG_ORIG(MSG_ARG_ZTEXT);
931 			} else if (strcmp(optarg,
932 			    MSG_ORIG(MSG_ARG_TEXTOFF)) == 0) {
933 				if (ztflag &&
934 				    (ztflag != MSG_ORIG(MSG_ARG_ZTEXTOFF))) {
935 					eprintf(ofl->ofl_lml, ERR_FATAL,
936 					    MSG_INTL(MSG_ARG_INCOMP),
937 					    MSG_ORIG(MSG_ARG_ZTEXTOFF),
938 					    ztflag);
939 					ofl->ofl_flags |= FLG_OF_FATAL;
940 				}
941 				ztflag = MSG_ORIG(MSG_ARG_ZTEXTOFF);
942 			} else if (strcmp(optarg,
943 			    MSG_ORIG(MSG_ARG_TEXTWARN)) == 0) {
944 				if (ztflag &&
945 				    (ztflag != MSG_ORIG(MSG_ARG_ZTEXTWARN))) {
946 					eprintf(ofl->ofl_lml, ERR_FATAL,
947 					    MSG_INTL(MSG_ARG_INCOMP),
948 					    MSG_ORIG(MSG_ARG_ZTEXTWARN),
949 					    ztflag);
950 					ofl->ofl_flags |= FLG_OF_FATAL;
951 				}
952 				ztflag = MSG_ORIG(MSG_ARG_ZTEXTWARN);
953 
954 			/*
955 			 * For other options simply set the ofl flags directly.
956 			 */
957 			} else if (strcmp(optarg,
958 			    MSG_ORIG(MSG_ARG_RESCAN)) == 0) {
959 				ofl->ofl_flags1 |= FLG_OF1_RESCAN;
960 			} else if (strcmp(optarg,
961 			    MSG_ORIG(MSG_ARG_ABSEXEC)) == 0) {
962 				ofl->ofl_flags1 |= FLG_OF1_ABSEXEC;
963 			} else if (strcmp(optarg,
964 			    MSG_ORIG(MSG_ARG_LOADFLTR)) == 0) {
965 				zlflag = TRUE;
966 			} else if (strcmp(optarg,
967 			    MSG_ORIG(MSG_ARG_NORELOC)) == 0) {
968 				ofl->ofl_dtflags_1 |= DF_1_NORELOC;
969 			} else if (strcmp(optarg,
970 			    MSG_ORIG(MSG_ARG_NOVERSION)) == 0) {
971 				ofl->ofl_flags |= FLG_OF_NOVERSEC;
972 			} else if (strcmp(optarg,
973 			    MSG_ORIG(MSG_ARG_MULDEFS)) == 0) {
974 				ofl->ofl_flags |= FLG_OF_MULDEFS;
975 			} else if (strcmp(optarg,
976 			    MSG_ORIG(MSG_ARG_REDLOCSYM)) == 0) {
977 				ofl->ofl_flags1 |= FLG_OF1_REDLSYM;
978 			} else if (strcmp(optarg,
979 			    MSG_ORIG(MSG_ARG_INITFIRST)) == 0) {
980 				ofl->ofl_dtflags_1 |= DF_1_INITFIRST;
981 			} else if (strcmp(optarg,
982 			    MSG_ORIG(MSG_ARG_NODELETE)) == 0) {
983 				ofl->ofl_dtflags_1 |= DF_1_NODELETE;
984 			} else if (strcmp(optarg,
985 			    MSG_ORIG(MSG_ARG_NOPARTIAL)) == 0) {
986 				ofl->ofl_flags1 |= FLG_OF1_NOPARTI;
987 			} else if (strcmp(optarg,
988 			    MSG_ORIG(MSG_ARG_NOOPEN)) == 0) {
989 				ofl->ofl_dtflags_1 |= DF_1_NOOPEN;
990 			} else if (strcmp(optarg,
991 			    MSG_ORIG(MSG_ARG_NOW)) == 0) {
992 				ofl->ofl_dtflags_1 |= DF_1_NOW;
993 				ofl->ofl_dtflags |= DF_BIND_NOW;
994 			} else if (strcmp(optarg,
995 			    MSG_ORIG(MSG_ARG_ORIGIN)) == 0) {
996 				ofl->ofl_dtflags_1 |= DF_1_ORIGIN;
997 				ofl->ofl_dtflags |= DF_ORIGIN;
998 			} else if (strcmp(optarg,
999 			    MSG_ORIG(MSG_ARG_NODEFAULTLIB)) == 0) {
1000 				ofl->ofl_dtflags_1 |= DF_1_NODEFLIB;
1001 			} else if (strcmp(optarg,
1002 			    MSG_ORIG(MSG_ARG_NODUMP)) == 0) {
1003 				ofl->ofl_dtflags_1 |= DF_1_NODUMP;
1004 			} else if (strcmp(optarg,
1005 			    MSG_ORIG(MSG_ARG_ENDFILTEE)) == 0) {
1006 				ofl->ofl_dtflags_1 |= DF_1_ENDFILTEE;
1007 			} else if (strcmp(optarg,
1008 			    MSG_ORIG(MSG_ARG_VERBOSE)) == 0) {
1009 				ofl->ofl_flags |= FLG_OF_VERBOSE;
1010 			} else if (strcmp(optarg,
1011 			    MSG_ORIG(MSG_ARG_COMBRELOC)) == 0) {
1012 				ofl->ofl_flags1 |= FLG_OF1_RELCNT;
1013 			} else if (strcmp(optarg,
1014 			    MSG_ORIG(MSG_ARG_NOCOMPSTRTAB)) == 0) {
1015 				ofl->ofl_flags1 |= FLG_OF1_NCSTTAB;
1016 			} else if (strcmp(optarg,
1017 			    MSG_ORIG(MSG_ARG_INTERPOSE)) == 0) {
1018 				zinflag = TRUE;
1019 
1020 			/*
1021 			 * The following options just need vaildation as they
1022 			 * are interpreted on the second pass through the
1023 			 * command line arguments.
1024 			 */
1025 			} else if (
1026 			    strncmp(optarg, MSG_ORIG(MSG_ARG_INITARRAY),
1027 				MSG_ARG_INITARRAY_SIZE) &&
1028 			    strncmp(optarg, MSG_ORIG(MSG_ARG_FINIARRAY),
1029 				MSG_ARG_FINIARRAY_SIZE) &&
1030 			    strncmp(optarg, MSG_ORIG(MSG_ARG_PREINITARRAY),
1031 				MSG_ARG_PREINITARRAY_SIZE) &&
1032 			    strncmp(optarg, MSG_ORIG(MSG_ARG_RTLDINFO),
1033 				MSG_ARG_RTLDINFO_SIZE) &&
1034 			    strncmp(optarg, MSG_ORIG(MSG_ARG_DTRACE),
1035 				MSG_ARG_DTRACE_SIZE) &&
1036 			    strcmp(optarg, MSG_ORIG(MSG_ARG_ALLEXTRT)) &&
1037 			    strcmp(optarg, MSG_ORIG(MSG_ARG_DFLEXTRT)) &&
1038 			    strcmp(optarg, MSG_ORIG(MSG_ARG_DIRECT)) &&
1039 			    strcmp(optarg, MSG_ORIG(MSG_ARG_NODIRECT)) &&
1040 			    strcmp(optarg, MSG_ORIG(MSG_ARG_GROUPPERM)) &&
1041 			    strcmp(optarg, MSG_ORIG(MSG_ARG_IGNORE)) &&
1042 			    strcmp(optarg, MSG_ORIG(MSG_ARG_LAZYLOAD)) &&
1043 			    strcmp(optarg, MSG_ORIG(MSG_ARG_NOGROUPPERM)) &&
1044 			    strcmp(optarg, MSG_ORIG(MSG_ARG_NOLAZYLOAD)) &&
1045 			    strcmp(optarg, MSG_ORIG(MSG_ARG_RECORD)) &&
1046 			    strcmp(optarg, MSG_ORIG(MSG_ARG_WEAKEXT))) {
1047 				eprintf(ofl->ofl_lml, ERR_FATAL,
1048 				    MSG_INTL(MSG_ARG_ILLEGAL),
1049 				    MSG_ORIG(MSG_ARG_Z), optarg);
1050 				ofl->ofl_flags |= FLG_OF_FATAL;
1051 
1052 			}
1053 
1054 			break;
1055 
1056 		case 'D':
1057 			/*
1058 			 * If we have not yet read any input files go ahead
1059 			 * and process any debugging options (this allows any
1060 			 * argument processing, entrance criteria and library
1061 			 * initialization to be displayed).  Otherwise, if an
1062 			 * input file has been seen, skip interpretation until
1063 			 * process_files (this allows debugging to be turned
1064 			 * on and off around individual groups of files).
1065 			 */
1066 			if (ofl->ofl_objscnt == 0) {
1067 				if (dbg_setup(optarg, dbg_desc,
1068 				    &ofl->ofl_name, 1) == S_ERROR)
1069 					return (S_ERROR);
1070 			}
1071 			break;
1072 
1073 		case 'B':
1074 			if (strcmp(optarg, MSG_ORIG(MSG_ARG_DIRECT)) == 0) {
1075 				if (Bdflag == SET_FALSE) {
1076 					eprintf(ofl->ofl_lml, ERR_FATAL,
1077 					    MSG_INTL(MSG_ARG_INCOMP),
1078 					    MSG_ORIG(MSG_ARG_BNODIRECT),
1079 					    MSG_ORIG(MSG_ARG_BDIRECT));
1080 					ofl->ofl_flags |= FLG_OF_FATAL;
1081 				} else
1082 					Bdflag = SET_TRUE;
1083 			} else if (strcmp(optarg,
1084 			    MSG_ORIG(MSG_ARG_NODIRECT)) == 0) {
1085 				if (Bdflag == SET_TRUE) {
1086 					eprintf(ofl->ofl_lml, ERR_FATAL,
1087 					    MSG_INTL(MSG_ARG_INCOMP),
1088 					    MSG_ORIG(MSG_ARG_BDIRECT),
1089 					    MSG_ORIG(MSG_ARG_BNODIRECT));
1090 					ofl->ofl_flags |= FLG_OF_FATAL;
1091 				} else
1092 					Bdflag = SET_FALSE;
1093 			} else if (strcmp(optarg,
1094 			    MSG_ORIG(MSG_STR_SYMBOLIC)) == 0)
1095 				Bsflag = TRUE;
1096 			else if (strcmp(optarg, MSG_ORIG(MSG_ARG_REDUCE)) == 0)
1097 				ofl->ofl_flags |= FLG_OF_PROCRED;
1098 			else if (strcmp(optarg, MSG_ORIG(MSG_STR_LOCAL)) == 0)
1099 				Blflag = TRUE;
1100 			else if (strcmp(optarg,
1101 			    MSG_ORIG(MSG_ARG_TRANSLATOR)) == 0)
1102 				Btflag = TRUE;
1103 			else if (strcmp(optarg, MSG_ORIG(MSG_ARG_GROUP)) == 0)
1104 				Bgflag = TRUE;
1105 			else if (strcmp(optarg,
1106 			    MSG_ORIG(MSG_STR_ELIMINATE)) == 0)
1107 				Beflag = TRUE;
1108 			else if (strcmp(optarg, MSG_ORIG(MSG_STR_LD_DYNAMIC)) &&
1109 			    strcmp(optarg, MSG_ORIG(MSG_ARG_STATIC))) {
1110 				eprintf(ofl->ofl_lml, ERR_FATAL,
1111 				    MSG_INTL(MSG_ARG_ILLEGAL),
1112 				    MSG_ORIG(MSG_ARG_CB), optarg);
1113 				ofl->ofl_flags |= FLG_OF_FATAL;
1114 			}
1115 			break;
1116 
1117 		case 'G':
1118 			Gflag = TRUE;
1119 			break;
1120 
1121 		case 'L':
1122 			break;
1123 
1124 		case 'M':
1125 			if (list_appendc(&(ofl->ofl_maps), optarg) == 0)
1126 				return (S_ERROR);
1127 			break;
1128 
1129 		case 'N':
1130 			break;
1131 
1132 		case 'Q':
1133 			if ((optarg[0] == 'n') && (optarg[1] == '\0')) {
1134 				if (Qflag != SET_UNKNOWN)
1135 					eprintf(ofl->ofl_lml, ERR_WARNING,
1136 					    MSG_INTL(MSG_ARG_MTONCE),
1137 					    MSG_ORIG(MSG_ARG_CQ));
1138 				else
1139 					Qflag = SET_FALSE;
1140 			} else if ((optarg[0] == 'y') && (optarg[1] == '\0')) {
1141 				if (Qflag != SET_UNKNOWN)
1142 					eprintf(ofl->ofl_lml, ERR_WARNING,
1143 					    MSG_INTL(MSG_ARG_MTONCE),
1144 					    MSG_ORIG(MSG_ARG_CQ));
1145 				else
1146 					Qflag = SET_TRUE;
1147 			} else {
1148 				eprintf(ofl->ofl_lml, ERR_FATAL,
1149 				    MSG_INTL(MSG_ARG_ILLEGAL),
1150 				    MSG_ORIG(MSG_ARG_CQ), optarg);
1151 				ofl->ofl_flags |= FLG_OF_FATAL;
1152 			}
1153 			break;
1154 
1155 		case 'S':
1156 			if (list_appendc(&lib_support, optarg) == 0)
1157 				return (S_ERROR);
1158 			break;
1159 
1160 		case 'V':
1161 			if (!Vflag)
1162 				(void) fprintf(stderr, MSG_ORIG(MSG_STR_STRNL),
1163 				    ofl->ofl_sgsid);
1164 			Vflag = TRUE;
1165 			break;
1166 
1167 		case 'Y':
1168 			if (strncmp(optarg, MSG_ORIG(MSG_ARG_LCOM), 2) == 0) {
1169 				if (Llibdir)
1170 				    eprintf(ofl->ofl_lml, ERR_WARNING,
1171 					MSG_INTL(MSG_ARG_MTONCE),
1172 					MSG_ORIG(MSG_ARG_CYL));
1173 				else
1174 					Llibdir = optarg + 2;
1175 			} else if (strncmp(optarg,
1176 			    MSG_ORIG(MSG_ARG_UCOM), 2) == 0) {
1177 				if (Ulibdir)
1178 					eprintf(ofl->ofl_lml, ERR_WARNING,
1179 					    MSG_INTL(MSG_ARG_MTONCE),
1180 					    MSG_ORIG(MSG_ARG_CYU));
1181 				else
1182 					Ulibdir = optarg + 2;
1183 			} else if (strncmp(optarg,
1184 			    MSG_ORIG(MSG_ARG_PCOM), 2) == 0) {
1185 				if (Plibpath)
1186 					eprintf(ofl->ofl_lml, ERR_WARNING,
1187 					    MSG_INTL(MSG_ARG_MTONCE),
1188 					    MSG_ORIG(MSG_ARG_CYP));
1189 				else
1190 					Plibpath = optarg + 2;
1191 			} else {
1192 				eprintf(ofl->ofl_lml, ERR_FATAL,
1193 				    MSG_INTL(MSG_ARG_ILLEGAL),
1194 				    MSG_ORIG(MSG_ARG_CY), optarg);
1195 				ofl->ofl_flags |= FLG_OF_FATAL;
1196 			}
1197 			break;
1198 
1199 		case '?':
1200 			(*error)++;
1201 			break;
1202 
1203 		default:
1204 			break;
1205 		}
1206 	}
1207 	return (1);
1208 }
1209 
1210 /*
1211  * Parsing options pass2 for
1212  */
1213 static uintptr_t
1214 parseopt_pass2(Ofl_desc *ofl, int argc, char **argv)
1215 {
1216 	int	c;
1217 
1218 	while ((c = getopt(argc, argv, MSG_ORIG(MSG_STR_OPTIONS))) != -1) {
1219 		Ifl_desc	*ifl;
1220 		Sym_desc	*sdp;
1221 
1222 		DBG_CALL(Dbg_args_flags(ofl->ofl_lml, (optind - 1), c));
1223 		switch (c) {
1224 			case 'l':
1225 				if (ld_find_library(optarg, ofl) == S_ERROR)
1226 					return (S_ERROR);
1227 				break;
1228 			case 'B':
1229 				if (strcmp(optarg,
1230 				    MSG_ORIG(MSG_STR_LD_DYNAMIC)) == 0) {
1231 					if (ofl->ofl_flags & FLG_OF_DYNAMIC)
1232 						ofl->ofl_flags |=
1233 							FLG_OF_DYNLIBS;
1234 					else {
1235 						eprintf(ofl->ofl_lml, ERR_FATAL,
1236 						    MSG_INTL(MSG_ARG_INCOMP),
1237 						    MSG_ORIG(MSG_ARG_DN),
1238 						    MSG_ORIG(MSG_ARG_BDYNAMIC));
1239 						ofl->ofl_flags |= FLG_OF_FATAL;
1240 					}
1241 				} else if (strcmp(optarg,
1242 				    MSG_ORIG(MSG_ARG_STATIC)) == 0)
1243 					ofl->ofl_flags &= ~FLG_OF_DYNLIBS;
1244 				break;
1245 			case 'L':
1246 				if (ld_add_libdir(ofl, optarg) == S_ERROR)
1247 					return (S_ERROR);
1248 				break;
1249 			case 'N':
1250 				/*
1251 				 * Record DT_NEEDED string
1252 				 */
1253 				if (!(ofl->ofl_flags & FLG_OF_DYNAMIC)) {
1254 					eprintf(ofl->ofl_lml, ERR_FATAL,
1255 					    MSG_INTL(MSG_ARG_INCOMP),
1256 					    MSG_ORIG(MSG_ARG_DN),
1257 					    MSG_ORIG(MSG_ARG_CN));
1258 					ofl->ofl_flags |= FLG_OF_FATAL;
1259 				}
1260 				if (((ifl =
1261 				    libld_calloc(1, sizeof (Ifl_desc))) == 0) ||
1262 				    (list_appendc(&ofl->ofl_sos, ifl) == 0))
1263 					return (S_ERROR);
1264 
1265 				ifl->ifl_name = MSG_INTL(MSG_STR_COMMAND);
1266 				ifl->ifl_soname = optarg;
1267 				ifl->ifl_flags = (FLG_IF_NEEDSTR |
1268 				    FLG_IF_FILEREF | FLG_IF_DEPREQD);
1269 
1270 				break;
1271 			case 'D':
1272 				(void) dbg_setup(optarg, dbg_desc,
1273 				    &ofl->ofl_name, 2);
1274 				break;
1275 			case 'u':
1276 				if (ld_sym_add_u(optarg, ofl) ==
1277 				    (Sym_desc *)S_ERROR)
1278 					return (S_ERROR);
1279 				break;
1280 			case 'z':
1281 				if ((strncmp(optarg, MSG_ORIG(MSG_ARG_LD32),
1282 				    MSG_ARG_LD32_SIZE) == 0) ||
1283 				    (strncmp(optarg, MSG_ORIG(MSG_ARG_LD64),
1284 				    MSG_ARG_LD64_SIZE) == 0)) {
1285 					if (createargv(ofl, 0) == S_ERROR)
1286 						return (S_ERROR);
1287 				} else if (strcmp(optarg,
1288 				    MSG_ORIG(MSG_ARG_ALLEXTRT)) == 0) {
1289 					ofl->ofl_flags1 |= FLG_OF1_ALLEXRT;
1290 					ofl->ofl_flags1 &= ~FLG_OF1_WEAKEXT;
1291 				} else if (strcmp(optarg,
1292 				    MSG_ORIG(MSG_ARG_WEAKEXT)) == 0) {
1293 					ofl->ofl_flags1 |= FLG_OF1_WEAKEXT;
1294 					ofl->ofl_flags1 &= ~FLG_OF1_ALLEXRT;
1295 				} else if (strcmp(optarg,
1296 				    MSG_ORIG(MSG_ARG_DFLEXTRT)) == 0) {
1297 					ofl->ofl_flags1 &=
1298 					~(FLG_OF1_ALLEXRT | FLG_OF1_WEAKEXT);
1299 				} else if (strcmp(optarg,
1300 				    MSG_ORIG(MSG_ARG_DIRECT)) == 0) {
1301 					ofl->ofl_flags1 |= FLG_OF1_ZDIRECT;
1302 				} else if (strcmp(optarg,
1303 				    MSG_ORIG(MSG_ARG_NODIRECT)) == 0) {
1304 					ofl->ofl_flags1 &= ~FLG_OF1_ZDIRECT;
1305 					ofl->ofl_flags1 |= FLG_OF1_NDIRECT;
1306 				} else if (strcmp(optarg,
1307 				    MSG_ORIG(MSG_ARG_IGNORE)) == 0) {
1308 					ofl->ofl_flags1 |=
1309 					    (FLG_OF1_IGNORE | FLG_OF1_IGNPRC);
1310 				} else if (strcmp(optarg,
1311 				    MSG_ORIG(MSG_ARG_RECORD)) == 0) {
1312 					ofl->ofl_flags1 &= ~FLG_OF1_IGNORE;
1313 				} else if (strcmp(optarg,
1314 				    MSG_ORIG(MSG_ARG_LAZYLOAD)) == 0) {
1315 					ofl->ofl_flags1 |= FLG_OF1_LAZYLD;
1316 				} else if (strcmp(optarg,
1317 				    MSG_ORIG(MSG_ARG_NOLAZYLOAD)) == 0) {
1318 					ofl->ofl_flags1 &= ~ FLG_OF1_LAZYLD;
1319 				} else if (strcmp(optarg,
1320 				    MSG_ORIG(MSG_ARG_GROUPPERM)) == 0) {
1321 					ofl->ofl_flags1 |= FLG_OF1_GRPPRM;
1322 				} else if (strcmp(optarg,
1323 				    MSG_ORIG(MSG_ARG_NOGROUPPERM)) == 0) {
1324 					ofl->ofl_flags1 &= ~FLG_OF1_GRPPRM;
1325 				} else if (strncmp(optarg,
1326 				    MSG_ORIG(MSG_ARG_INITARRAY),
1327 				    MSG_ARG_INITARRAY_SIZE) == 0) {
1328 					if (((sdp = ld_sym_add_u(optarg +
1329 					    MSG_ARG_INITARRAY_SIZE, ofl)) ==
1330 					    (Sym_desc *)S_ERROR) ||
1331 					    (list_appendc(&ofl->ofl_initarray,
1332 					    sdp) == 0))
1333 						return (S_ERROR);
1334 				} else if (strncmp(optarg,
1335 				    MSG_ORIG(MSG_ARG_FINIARRAY),
1336 				    MSG_ARG_FINIARRAY_SIZE) == 0) {
1337 					if (((sdp = ld_sym_add_u(optarg +
1338 					    MSG_ARG_FINIARRAY_SIZE, ofl)) ==
1339 					    (Sym_desc *)S_ERROR) ||
1340 					    (list_appendc(&ofl->ofl_finiarray,
1341 					    sdp) == 0))
1342 						return (S_ERROR);
1343 				} else if (strncmp(optarg,
1344 				    MSG_ORIG(MSG_ARG_PREINITARRAY),
1345 				    MSG_ARG_PREINITARRAY_SIZE) == 0) {
1346 					if (((sdp = ld_sym_add_u(optarg +
1347 					    MSG_ARG_PREINITARRAY_SIZE, ofl)) ==
1348 					    (Sym_desc *)S_ERROR) ||
1349 					    (list_appendc(&ofl->ofl_preiarray,
1350 					    sdp) == 0))
1351 						return (S_ERROR);
1352 				} else if (strncmp(optarg,
1353 				    MSG_ORIG(MSG_ARG_RTLDINFO),
1354 				    MSG_ARG_RTLDINFO_SIZE) == 0) {
1355 					if (((sdp = ld_sym_add_u(optarg +
1356 					    MSG_ARG_RTLDINFO_SIZE, ofl)) ==
1357 					    (Sym_desc *)S_ERROR) ||
1358 					    (list_appendc(&ofl->ofl_rtldinfo,
1359 					    sdp) == 0))
1360 						return (S_ERROR);
1361 				} else if (strncmp(optarg,
1362 				    MSG_ORIG(MSG_ARG_DTRACE),
1363 				    MSG_ARG_DTRACE_SIZE) == 0) {
1364 					if ((sdp = ld_sym_add_u(optarg +
1365 					    MSG_ARG_DTRACE_SIZE, ofl)) ==
1366 					    (Sym_desc *)S_ERROR)
1367 						return (S_ERROR);
1368 					ofl->ofl_dtracesym = sdp;
1369 				}
1370 			default:
1371 				break;
1372 		}
1373 	}
1374 	return (1);
1375 }
1376 
1377 /*
1378  *
1379  * Pass 1 -- process_flags: collects all options and sets flags
1380  */
1381 static uintptr_t
1382 process_flags_com(Ofl_desc *ofl, int argc, char **argv, int *e)
1383 {
1384 	for (; optind < argc; optind++) {
1385 		/*
1386 		 * If we detect some more options return to getopt().
1387 		 * Checking argv[optind][1] against null prevents a forever
1388 		 * loop if an unadorned `-' argument is passed to us.
1389 		 */
1390 		while ((optind < argc) && (argv[optind][0] == '-')) {
1391 			if (argv[optind][1] != '\0') {
1392 				if (parseopt_pass1(ofl, argc, argv, e) ==
1393 				    S_ERROR)
1394 					return (S_ERROR);
1395 			} else if (++optind < argc)
1396 				continue;
1397 		}
1398 		if (optind >= argc)
1399 			break;
1400 		ofl->ofl_objscnt++;
1401 	}
1402 	return (1);
1403 }
1404 
1405 uintptr_t
1406 ld_process_flags(Ofl_desc *ofl, int argc, char **argv)
1407 {
1408 	int	error = 0;	/* Collect all argument errors before exit */
1409 
1410 	if (argc < 2) {
1411 		usage_mesg(FALSE);
1412 		return (S_ERROR);
1413 	}
1414 
1415 	/*
1416 	 * Option handling
1417 	 */
1418 	if (process_flags_com(ofl, argc, argv, &error) == S_ERROR)
1419 		return (S_ERROR);
1420 
1421 	/*
1422 	 * Having parsed everything, did we have any errors.
1423 	 */
1424 	if (error) {
1425 		usage_mesg(TRUE);
1426 		return (S_ERROR);
1427 	}
1428 
1429 	return (check_flags(ofl, argc));
1430 }
1431 
1432 /*
1433  * Pass 2 -- process_files: skips the flags collected in pass 1 and processes
1434  * files.
1435  */
1436 static uintptr_t
1437 process_files_com(Ofl_desc *ofl, int argc, char **argv)
1438 {
1439 	for (; optind < argc; optind++) {
1440 		int		fd;
1441 		Ifl_desc	*ifl;
1442 		Rej_desc	rej = { 0 };
1443 
1444 		/*
1445 		 * If we detect some more options return to getopt().
1446 		 * Checking argv[optind][1] against null prevents a forever
1447 		 * loop if an unadorned `-' argument is passed to us.
1448 		 */
1449 		while ((optind < argc) && (argv[optind][0] == '-')) {
1450 			if (argv[optind][1] != '\0') {
1451 				if (parseopt_pass2(ofl, argc, argv) == S_ERROR)
1452 					return (S_ERROR);
1453 			} else if (++optind < argc)
1454 				continue;
1455 		}
1456 		if (optind >= argc)
1457 			break;
1458 
1459 		if ((fd = open(argv[optind], O_RDONLY)) == -1) {
1460 			int err = errno;
1461 
1462 			eprintf(ofl->ofl_lml, ERR_FATAL,
1463 			    MSG_INTL(MSG_SYS_OPEN), argv[optind],
1464 			    strerror(err));
1465 			ofl->ofl_flags |= FLG_OF_FATAL;
1466 			continue;
1467 		}
1468 
1469 		DBG_CALL(Dbg_args_files(ofl->ofl_lml, optind, argv[optind]));
1470 
1471 		ifl = ld_process_open(argv[optind], 0, fd, ofl,
1472 		    (FLG_IF_CMDLINE | FLG_IF_NEEDED), &rej);
1473 		(void) close(fd);
1474 		if (ifl == (Ifl_desc *)S_ERROR)
1475 			return (S_ERROR);
1476 
1477 		/*
1478 		 * Check for mismatched input.
1479 		 */
1480 		if (rej.rej_type) {
1481 			eprintf(ofl->ofl_lml, ERR_FATAL,
1482 			    MSG_INTL(reject[rej.rej_type]),
1483 			    rej.rej_name ? rej.rej_name :
1484 			    MSG_INTL(MSG_STR_UNKNOWN), conv_reject_desc(&rej));
1485 			ofl->ofl_flags |= FLG_OF_FATAL;
1486 			return (1);
1487 		}
1488 	}
1489 	return (1);
1490 }
1491 
1492 uintptr_t
1493 ld_process_files(Ofl_desc *ofl, int argc, char **argv)
1494 {
1495 	optind = 1;		/* reinitialize optind */
1496 
1497 	/*
1498 	 * Process command line files (taking into account any applicable
1499 	 * preseeding flags).  Return if any fatal errors have occurred.
1500 	 */
1501 	if (process_files_com(ofl, argc, argv) == S_ERROR)
1502 		return (S_ERROR);
1503 	if (ofl->ofl_flags & FLG_OF_FATAL)
1504 		return (1);
1505 
1506 	/*
1507 	 * Now that all command line files have been processed see if there are
1508 	 * any additional `needed' shared object dependencies.
1509 	 */
1510 	if (ofl->ofl_soneed.head)
1511 		if (ld_finish_libs(ofl) == S_ERROR)
1512 			return (S_ERROR);
1513 
1514 	/*
1515 	 * If rescanning archives is enabled, do so now to determine whether
1516 	 * there might still be members extracted to satisfy references from any
1517 	 * explicit objects.  Continue until no new objects are extracted.  Note
1518 	 * that this pass is carried out *after* processing any implicit objects
1519 	 * (above) as they may already have resolved any undefined references
1520 	 * from any explicit dependencies.
1521 	 */
1522 	if (ofl->ofl_flags1 & FLG_OF1_RESCAN)
1523 		ofl->ofl_flags1 |= FLG_OF1_EXTRACT;
1524 	while ((ofl->ofl_flags1 & (FLG_OF1_RESCAN | FLG_OF1_EXTRACT)) ==
1525 	    (FLG_OF1_RESCAN | FLG_OF1_EXTRACT)) {
1526 		Listnode	*lnp;
1527 		Ar_desc		*adp;
1528 
1529 		ofl->ofl_flags1 &= ~FLG_OF1_EXTRACT;
1530 
1531 		DBG_CALL(Dbg_file_ar_rescan(ofl->ofl_lml));
1532 
1533 		for (LIST_TRAVERSE(&ofl->ofl_ars, lnp, adp)) {
1534 			const char	*name = adp->ad_name;
1535 			uintptr_t	error;
1536 			int		fd;
1537 
1538 			/*
1539 			 * If this archive was processed with -z allextract,
1540 			 * then all members have already been extracted.
1541 			 */
1542 			if (adp->ad_elf == (Elf *)NULL)
1543 				continue;
1544 
1545 			/*
1546 			 * Reopen the file.
1547 			 */
1548 			if ((fd = open(name, O_RDONLY)) == -1) {
1549 				int err = errno;
1550 
1551 				eprintf(ofl->ofl_lml, ERR_FATAL,
1552 				    MSG_INTL(MSG_SYS_OPEN), name,
1553 				    strerror(err));
1554 				ofl->ofl_flags |= FLG_OF_FATAL;
1555 				return (S_ERROR);
1556 			}
1557 
1558 			/*
1559 			 * Reestablish any archive specific command line flags.
1560 			 */
1561 			ofl->ofl_flags1 &= ~MSK_OF1_ARCHIVE;
1562 			ofl->ofl_flags1 |= (adp->ad_flags & MSK_OF1_ARCHIVE);
1563 
1564 			error = ld_process_archive(adp->ad_name, fd, adp, ofl);
1565 			(void) close(fd);
1566 
1567 			if (error == S_ERROR)
1568 				return (S_ERROR);
1569 			if (ofl->ofl_flags & FLG_OF_FATAL)
1570 				return (1);
1571 		}
1572 	}
1573 
1574 	/*
1575 	 * If debugging, provide statistics on each archives extraction, or flag
1576 	 * any archive that has provided no members.  Note that this could be a
1577 	 * nice place to free up much of the archive infrastructure, as we've
1578 	 * extracted any members we need.  However, as we presently don't free
1579 	 * anything under ld(1) there's not much point in proceeding further.
1580 	 */
1581 	DBG_CALL(Dbg_statistics_ar(ofl));
1582 
1583 	/*
1584 	 * If any version definitions have been established, either via input
1585 	 * from a mapfile or from the input relocatable objects, make sure any
1586 	 * version dependencies are satisfied, and version symbols created.
1587 	 */
1588 	if (ofl->ofl_verdesc.head)
1589 		if (ld_vers_check_defs(ofl) == S_ERROR)
1590 			return (S_ERROR);
1591 
1592 	/*
1593 	 * If segment ordering was specified (using mapfile) verify things
1594 	 * are ok.
1595 	 */
1596 	if (ofl->ofl_flags & FLG_OF_SEGORDER)
1597 		ld_ent_check(ofl);
1598 
1599 	return (1);
1600 }
1601