Print this page
10366 ld(1) should support GNU-style linker sets
10581 ld(1) should know kernel modules are a thing


  86 
  87 /*
  88  * Define a set of local argument flags, the settings of these will be
  89  * verified in check_flags() and lead to the appropriate output file flags
  90  * being initialized.
  91  */
  92 typedef enum {
  93         SET_UNKNOWN = -1,
  94         SET_FALSE = 0,
  95         SET_TRUE = 1
  96 } Setstate;
  97 
  98 static Setstate dflag   = SET_UNKNOWN;
  99 static Setstate zdflag  = SET_UNKNOWN;
 100 static Setstate Qflag   = SET_UNKNOWN;
 101 static Setstate Bdflag  = SET_UNKNOWN;
 102 static Setstate zfwflag = SET_UNKNOWN;
 103 
 104 static Boolean  aflag   = FALSE;
 105 static Boolean  bflag   = FALSE;
 106 static Boolean  rflag   = FALSE;
 107 static Boolean  sflag   = FALSE;
 108 static Boolean  zinflag = FALSE;
 109 static Boolean  zlflag  = FALSE;
 110 static Boolean  Bgflag  = FALSE;
 111 static Boolean  Blflag  = FALSE;
 112 static Boolean  Beflag  = FALSE;
 113 static Boolean  Bsflag  = FALSE;
 114 static Boolean  Dflag   = FALSE;
 115 static Boolean  Gflag   = FALSE;
 116 static Boolean  Vflag   = FALSE;
 117 









 118 /*
 119  * ztflag's state is set by pointing it to the matching string:
 120  *      text | textoff | textwarn
 121  */
 122 static const char       *ztflag = NULL;
 123 
 124 /*
 125  * Remember the guidance flags that result from the initial -z guidance
 126  * option, so that they can be compared to any that follow. We only want
 127  * to issue a warning when they differ.
 128  */
 129 static ofl_guideflag_t  initial_guidance_flags  = 0;
 130 
 131 static uintptr_t process_files_com(Ofl_desc *, int, char **);
 132 static uintptr_t process_flags_com(Ofl_desc *, int, char **, int *);
 133 
 134 /*
 135  * Print usage message to stderr - 2 modes, summary message only,
 136  * and full usage message.
 137  */


 211         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDEF));
 212         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDEL));
 213         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDLO));
 214         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDU));
 215         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNLD));
 216         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNOW));
 217         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNPA));
 218         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNV));
 219         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZO));
 220         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZPIA));
 221         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRL));
 222         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRREL));
 223         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRS));
 224         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRSN));
 225         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRSGRP));
 226         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZSCAP));
 227         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTARG));
 228         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZT));
 229         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTO));
 230         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTW));

 231         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZWRAP));
 232         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZVER));
 233 }
 234 
 235 /*
 236  * Rescan the archives seen on the command line in order
 237  * to handle circularly dependent archives, stopping when
 238  * no further member extraction occurs.
 239  *
 240  * entry:
 241  *      ofl - Output file descriptor
 242  *      isgrp - True if this is a an archive group search, False
 243  *              to search starting with argv[1] through end_arg_ndx
 244  *      end_arg_ndx - Index of final argv element to consider.
 245  */
 246 static uintptr_t
 247 ld_rescan_archives(Ofl_desc *ofl, int isgrp, int end_arg_ndx)
 248 {
 249         ofl->ofl_flags1 |= FLG_OF1_EXTRACT;
 250 


 296  * Checks the command line option flags for consistency.
 297  */
 298 static uintptr_t
 299 check_flags(Ofl_desc * ofl, int argc)
 300 {
 301         /*
 302          * If the user specified -zguidance=noall, then we can safely disable
 303          * the entire feature. The purpose of -zguidance=noall is to allow
 304          * the user to override guidance specified from a makefile via
 305          * the LD_OPTIONS environment variable, and so, we want to behave
 306          * in exactly the same manner we would have if no option were present.
 307          */
 308         if ((ofl->ofl_guideflags & (FLG_OFG_ENABLE | FLG_OFG_NO_ALL)) ==
 309             (FLG_OFG_ENABLE | FLG_OFG_NO_ALL))
 310                 ofl->ofl_guideflags &= ~FLG_OFG_ENABLE;
 311 
 312         if (Plibpath && (Llibdir || Ulibdir))
 313                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_YP),
 314                     Llibdir ? 'L' : 'U');
 315 
 316         if (rflag) {

 317                 if (dflag == SET_UNKNOWN)
 318                         dflag = SET_FALSE;
















 319                 /*
 320                  * Combining relocations when building a relocatable
 321                  * object isn't allowed.  Warn the user, but proceed.
 322                  */
 323                 if (ofl->ofl_flags & FLG_OF_COMREL)







 324                         ld_eprintf(ofl, ERR_WARNING, MSG_INTL(MSG_MARG_INCOMP),
 325                             MSG_INTL(MSG_MARG_REL),
 326                             MSG_ORIG(MSG_ARG_ZCOMBRELOC));

 327                 ofl->ofl_flags |= FLG_OF_RELOBJ;



 328         } else {
 329                 /*
 330                  * Translating object capabilities to symbol capabilities is
 331                  * only meaningful when creating a relocatable object.
 332                  */
 333                 if (ofl->ofl_flags & FLG_OF_OTOSCAP)
 334                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_ONLY),
 335                             MSG_ORIG(MSG_ARG_ZSYMBOLCAP),
 336                             MSG_INTL(MSG_MARG_REL));
 337 
 338                 /*
 339                  * If the user hasn't explicitly requested that relocations
 340                  * not be combined, combine them by default.
 341                  */
 342                 if ((ofl->ofl_flags & FLG_OF_NOCOMREL) == 0)
 343                         ofl->ofl_flags |= FLG_OF_COMREL;
 344         }
 345 
 346         if (zdflag == SET_TRUE)
 347                 ofl->ofl_flags |= FLG_OF_NOUNDEF;


 358         if (Blflag)
 359                 ofl->ofl_flags |= FLG_OF_AUTOLCL;
 360 
 361         if (Beflag)
 362                 ofl->ofl_flags |= FLG_OF_AUTOELM;
 363 
 364         if (Blflag && Beflag)
 365                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
 366                     MSG_ORIG(MSG_ARG_BELIMINATE), MSG_ORIG(MSG_ARG_BLOCAL));
 367 
 368         if (ofl->ofl_interp && (ofl->ofl_flags1 & FLG_OF1_NOINTRP))
 369                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
 370                     MSG_ORIG(MSG_ARG_CI), MSG_ORIG(MSG_ARG_ZNOINTERP));
 371 
 372         if ((ofl->ofl_flags1 & (FLG_OF1_NRLXREL | FLG_OF1_RLXREL)) ==
 373             (FLG_OF1_NRLXREL | FLG_OF1_RLXREL))
 374                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
 375                     MSG_ORIG(MSG_ARG_ZRELAXRELOC),
 376                     MSG_ORIG(MSG_ARG_ZNORELAXRELOC));
 377 
 378         if (ofl->ofl_filtees && !Gflag)
 379                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_ST_ONLYAVL),
 380                     ((ofl->ofl_flags & FLG_OF_AUX) ?
 381                     MSG_INTL(MSG_MARG_FILTER_AUX) : MSG_INTL(MSG_MARG_FILTER)));
 382 
 383         if (dflag != SET_FALSE) {
 384                 /*
 385                  * Set -Bdynamic on by default, setting is rechecked as input
 386                  * files are processed.
 387                  */
 388                 ofl->ofl_flags |=
 389                     (FLG_OF_DYNAMIC | FLG_OF_DYNLIBS | FLG_OF_PROCRED);
 390 
 391                 if (aflag)
 392                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
 393                             MSG_ORIG(MSG_ARG_DY), MSG_ORIG(MSG_ARG_A));
 394 
 395                 if (bflag)
 396                         ofl->ofl_flags |= FLG_OF_BFLAG;
 397 
 398                 if (Bgflag == TRUE) {


 412                  */
 413                 if ((ofl->ofl_dtflags_1 & DF_1_NODEFLIB) && !ofl->ofl_rpath)
 414                         ld_eprintf(ofl, ERR_WARNING, MSG_INTL(MSG_ARG_NODEFLIB),
 415                             MSG_INTL(MSG_MARG_RPATH));
 416 
 417                 /*
 418                  * By default, text relocation warnings are given when building
 419                  * an executable unless the -b flag is specified.  This option
 420                  * implies that unclean text can be created, so no warnings are
 421                  * generated unless specifically asked for.
 422                  */
 423                 if ((ztflag == MSG_ORIG(MSG_ARG_ZTEXTOFF)) ||
 424                     ((ztflag == NULL) && bflag)) {
 425                         ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
 426                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 427                 } else if (ztflag == MSG_ORIG(MSG_ARG_ZTEXT)) {
 428                         ofl->ofl_flags |= FLG_OF_PURETXT;
 429                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 430                 }
 431 
 432                 if (Gflag || !rflag) {
 433                         /*
 434                          * Create a dynamic object.  -Bdirect indicates that all
 435                          * references should be bound directly.  This also
 436                          * enables lazyloading.  Individual symbols can be
 437                          * bound directly (or not) using mapfiles and the
 438                          * DIRECT (NODIRECT) qualifier.  With this capability,
 439                          * each syminfo entry is tagged SYMINFO_FLG_DIRECTBIND.
 440                          * Prior to this per-symbol direct binding, runtime
 441                          * direct binding was controlled via the DF_1_DIRECT
 442                          * flag.  This flag affected all references from the
 443                          * object.  -Bdirect continues to set this flag, and
 444                          * thus provides a means of taking a newly built
 445                          * direct binding object back to older systems.
 446                          *
 447                          * NOTE, any use of per-symbol NODIRECT bindings, or
 448                          * -znodirect, will disable the creation of the
 449                          * DF_1_DIRECT flag.  Older runtime linkers do not
 450                          * have the capability to do per-symbol direct bindings.
 451                          */
 452                         if (Bdflag == SET_TRUE) {
 453                                 ofl->ofl_dtflags_1 |= DF_1_DIRECT;
 454                                 ofl->ofl_flags1 |= FLG_OF1_LAZYLD;
 455                                 ofl->ofl_guideflags |= FLG_OFG_NO_LAZY;
 456                                 ofl->ofl_flags |= FLG_OF_SYMINFO;
 457                         }
 458 
 459                         /*
 460                          * -Bnodirect disables directly binding to any symbols
 461                          * exported from the object being created.  Individual
 462                          * references to external objects can still be affected
 463                          * by -zdirect or mapfile DIRECT directives.
 464                          */
 465                         if (Bdflag == SET_FALSE) {
 466                                 ofl->ofl_flags1 |= (FLG_OF1_NDIRECT |
 467                                     FLG_OF1_NGLBDIR | FLG_OF1_ALNODIR);
 468                                 ofl->ofl_flags |= FLG_OF_SYMINFO;
 469                         }
 470                 }
 471 
 472                 if (!Gflag && !rflag) {
 473                         /*
 474                          * Dynamically linked executable.
 475                          */
 476                         ofl->ofl_flags |= FLG_OF_EXEC;
 477 
 478                         if (zdflag != SET_FALSE)
 479                                 ofl->ofl_flags |= FLG_OF_NOUNDEF;
 480 
 481                         /*
 482                          * -z textwarn is the default for executables, and
 483                          * only an explicit -z text* option can change that,
 484                          * so there's no need to provide additional guidance.
 485                          */
 486                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 487 
 488                         if (Bsflag)
 489                                 ld_eprintf(ofl, ERR_FATAL,
 490                                     MSG_INTL(MSG_ARG_DY_INCOMP),
 491                                     MSG_ORIG(MSG_ARG_BSYMBOLIC));
 492                         if (ofl->ofl_soname)
 493                                 ld_eprintf(ofl, ERR_FATAL,
 494                                     MSG_INTL(MSG_MARG_DY_INCOMP),
 495                                     MSG_INTL(MSG_MARG_SONAME));
 496                 } else if (!rflag) {
 497                         /*
 498                          * Shared library.
 499                          */
 500                         ofl->ofl_flags |= FLG_OF_SHAROBJ;
 501 
 502                         /*
 503                          * By default, print text relocation warnings for
 504                          * executables but *not* for shared objects. However,
 505                          * if -z guidance is on, issue warnings for shared
 506                          * objects as well.
 507                          *
 508                          * If -z textwarn is explicitly specified, also issue
 509                          * guidance messages if -z guidance is on, but not
 510                          * for -z text or -z textoff.
 511                          */
 512                         if (ztflag == NULL) {
 513                                 if (!OFL_GUIDANCE(ofl, FLG_OFG_NO_TEXT))
 514                                         ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
 515                         } else if ((ofl->ofl_flags & FLG_OF_PURETXT) ||
 516                             (ofl->ofl_flags1 & FLG_OF1_TEXTOFF)) {


 526                                             MSG_INTL(MSG_ARG_INCOMP),
 527                                             MSG_ORIG(MSG_ARG_BSYMBOLIC),
 528                                             MSG_ORIG(MSG_ARG_BNODIRECT));
 529                                 ofl->ofl_flags |= FLG_OF_SYMBOLIC;
 530                                 ofl->ofl_dtflags |= DF_SYMBOLIC;
 531                         }
 532                 } else {
 533                         /*
 534                          * Dynamic relocatable object.
 535                          */
 536                         if (ztflag == NULL)
 537                                 ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
 538                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 539 
 540                         if (ofl->ofl_interp)
 541                                 ld_eprintf(ofl, ERR_FATAL,
 542                                     MSG_INTL(MSG_MARG_INCOMP),
 543                                     MSG_INTL(MSG_MARG_REL),
 544                                     MSG_ORIG(MSG_ARG_CI));
 545                 }



 546         } else {
 547                 ofl->ofl_flags |= FLG_OF_STATIC;
 548 
 549                 if (bflag)
 550                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 551                             MSG_ORIG(MSG_ARG_B));
 552                 if (ofl->ofl_soname)
 553                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_ST_INCOMP),
 554                             MSG_INTL(MSG_MARG_SONAME));
 555                 if (ofl->ofl_depaudit)
 556                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 557                             MSG_ORIG(MSG_ARG_CP));
 558                 if (ofl->ofl_audit)
 559                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 560                             MSG_ORIG(MSG_ARG_P));
 561                 if (ofl->ofl_config)
 562                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 563                             MSG_ORIG(MSG_ARG_C));
 564                 if (ztflag)
 565                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 566                             MSG_ORIG(MSG_ARG_ZTEXTALL));
 567                 if (Gflag)
 568                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_ST_INCOMP),
 569                             MSG_INTL(MSG_MARG_SO));
 570                 if (aflag && rflag)
 571                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_INCOMP),
 572                             MSG_ORIG(MSG_ARG_A), MSG_INTL(MSG_MARG_REL));
 573 
 574                 if (rflag) {
 575                         /*
 576                          * We can only strip the symbol table and string table
 577                          * if no output relocations will refer to them.
 578                          */
 579                         if (sflag)
 580                                 ld_eprintf(ofl, ERR_WARNING,
 581                                     MSG_INTL(MSG_ARG_STRIP),
 582                                     MSG_INTL(MSG_MARG_REL),
 583                                     MSG_INTL(MSG_MARG_STRIP));
 584 
 585                         if (ztflag == NULL)
 586                                 ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
 587                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 588 
 589                         if (ofl->ofl_interp)
 590                                 ld_eprintf(ofl, ERR_FATAL,
 591                                     MSG_INTL(MSG_MARG_INCOMP),
 592                                     MSG_INTL(MSG_MARG_REL),
 593                                     MSG_ORIG(MSG_ARG_CI));
 594                 } else {


1184                         break;
1185 
1186                 case 'P':
1187                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1188 
1189                         /*
1190                          * Multiple instances of this option may occur.  Each
1191                          * additional instance is effectively concatenated to
1192                          * the previous separated by a colon.
1193                          */
1194                         if (*optarg != '\0') {
1195                                 if ((ofl->ofl_depaudit =
1196                                     add_string(ofl->ofl_depaudit,
1197                                     optarg)) == (const char *)S_ERROR)
1198                                         return (S_ERROR);
1199                         }
1200                         break;
1201 
1202                 case 'r':
1203                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));
1204                         rflag = TRUE;
1205                         break;
1206 
1207                 case 'R':
1208                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1209 
1210                         /*
1211                          * Multiple instances of this option may occur.  Each
1212                          * additional instance is effectively concatenated to
1213                          * the previous separated by a colon.
1214                          */
1215                         if (*optarg != '\0') {
1216                                 if ((ofl->ofl_rpath =
1217                                     add_string(ofl->ofl_rpath,
1218                                     optarg)) == (const char *)S_ERROR)
1219                                         return (S_ERROR);
1220                         }
1221                         break;
1222 
1223                 case 's':
1224                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));


1492                                         ofl->ofl_flags |= FLG_OF_FATWARN;
1493                                 }
1494                         } else if (strcmp(optarg,
1495                             MSG_ORIG(MSG_ARG_NOFATWARN)) == 0) {
1496                                 if (zfwflag  == SET_TRUE)
1497                                         ld_eprintf(ofl, ERR_WARNING_NF,
1498                                             MSG_INTL(MSG_ARG_MTONCE),
1499                                             MSG_ORIG(MSG_ARG_ZFATWNOFATW));
1500                                 else
1501                                         zfwflag = SET_FALSE;
1502 
1503                         /*
1504                          * Process everything related to -z assert-deflib. This
1505                          * must be done in pass 1 because it gets used in pass
1506                          * 2.
1507                          */
1508                         } else if (strncmp(optarg, MSG_ORIG(MSG_ARG_ASSDEFLIB),
1509                             MSG_ARG_ASSDEFLIB_SIZE) == 0) {
1510                                 if (assdeflib_parse(ofl, optarg) != TRUE)
1511                                         return (S_ERROR);


































1512                         /*
1513                          * The following options just need validation as they
1514                          * are interpreted on the second pass through the
1515                          * command line arguments.
1516                          */
1517                         } else if (
1518                             strncmp(optarg, MSG_ORIG(MSG_ARG_INITARRAY),
1519                             MSG_ARG_INITARRAY_SIZE) &&
1520                             strncmp(optarg, MSG_ORIG(MSG_ARG_FINIARRAY),
1521                             MSG_ARG_FINIARRAY_SIZE) &&
1522                             strncmp(optarg, MSG_ORIG(MSG_ARG_PREINITARRAY),
1523                             MSG_ARG_PREINITARRAY_SIZE) &&
1524                             strncmp(optarg, MSG_ORIG(MSG_ARG_RTLDINFO),
1525                             MSG_ARG_RTLDINFO_SIZE) &&
1526                             strncmp(optarg, MSG_ORIG(MSG_ARG_DTRACE),
1527                             MSG_ARG_DTRACE_SIZE) &&
1528                             strcmp(optarg, MSG_ORIG(MSG_ARG_ALLEXTRT)) &&
1529                             strcmp(optarg, MSG_ORIG(MSG_ARG_DFLEXTRT)) &&
1530                             strcmp(optarg, MSG_ORIG(MSG_ARG_DIRECT)) &&
1531                             strcmp(optarg, MSG_ORIG(MSG_ARG_NODIRECT)) &&


1610                                 Bgflag = TRUE;
1611                         else if (strcmp(optarg,
1612                             MSG_ORIG(MSG_STR_ELIMINATE)) == 0)
1613                                 Beflag = TRUE;
1614                         else if (strcmp(optarg,
1615                             MSG_ORIG(MSG_ARG_TRANSLATOR)) == 0) {
1616                                 ld_eprintf(ofl, ERR_WARNING,
1617                                     MSG_INTL(MSG_ARG_UNSUPPORTED),
1618                                     MSG_ORIG(MSG_ARG_BTRANSLATOR));
1619                         } else if (strcmp(optarg,
1620                             MSG_ORIG(MSG_STR_LD_DYNAMIC)) &&
1621                             strcmp(optarg, MSG_ORIG(MSG_ARG_STATIC))) {
1622                                 ld_eprintf(ofl, ERR_FATAL,
1623                                     MSG_INTL(MSG_ARG_ILLEGAL),
1624                                     MSG_ORIG(MSG_ARG_CB), optarg);
1625                         }
1626                         break;
1627 
1628                 case 'G':
1629                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));
1630                         Gflag = TRUE;
1631                         break;
1632 
1633                 case 'L':
1634                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1635                         break;
1636 
1637                 case 'M':
1638                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1639                         if (aplist_append(&(ofl->ofl_maps), optarg,
1640                             AL_CNT_OFL_MAPFILES) == NULL)
1641                                 return (S_ERROR);
1642                         break;
1643 
1644                 case 'N':
1645                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1646                         break;
1647 
1648                 case 'Q':
1649                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1650                         if ((optarg[0] == 'n') && (optarg[1] == '\0')) {




  86 
  87 /*
  88  * Define a set of local argument flags, the settings of these will be
  89  * verified in check_flags() and lead to the appropriate output file flags
  90  * being initialized.
  91  */
  92 typedef enum {
  93         SET_UNKNOWN = -1,
  94         SET_FALSE = 0,
  95         SET_TRUE = 1
  96 } Setstate;
  97 
  98 static Setstate dflag   = SET_UNKNOWN;
  99 static Setstate zdflag  = SET_UNKNOWN;
 100 static Setstate Qflag   = SET_UNKNOWN;
 101 static Setstate Bdflag  = SET_UNKNOWN;
 102 static Setstate zfwflag = SET_UNKNOWN;
 103 
 104 static Boolean  aflag   = FALSE;
 105 static Boolean  bflag   = FALSE;

 106 static Boolean  sflag   = FALSE;
 107 static Boolean  zinflag = FALSE;
 108 static Boolean  zlflag  = FALSE;
 109 static Boolean  Bgflag  = FALSE;
 110 static Boolean  Blflag  = FALSE;
 111 static Boolean  Beflag  = FALSE;
 112 static Boolean  Bsflag  = FALSE;
 113 static Boolean  Dflag   = FALSE;

 114 static Boolean  Vflag   = FALSE;
 115 
 116 enum output_type {
 117         OT_RELOC,               /* relocatable object */
 118         OT_SHARED,              /* shared object */
 119         OT_EXEC,                /* dynamic executable */
 120         OT_KMOD,                /* kernel module */
 121 };
 122 
 123 static enum output_type otype = OT_EXEC;
 124 
 125 /*
 126  * ztflag's state is set by pointing it to the matching string:
 127  *      text | textoff | textwarn
 128  */
 129 static const char       *ztflag = NULL;
 130 
 131 /*
 132  * Remember the guidance flags that result from the initial -z guidance
 133  * option, so that they can be compared to any that follow. We only want
 134  * to issue a warning when they differ.
 135  */
 136 static ofl_guideflag_t  initial_guidance_flags  = 0;
 137 
 138 static uintptr_t process_files_com(Ofl_desc *, int, char **);
 139 static uintptr_t process_flags_com(Ofl_desc *, int, char **, int *);
 140 
 141 /*
 142  * Print usage message to stderr - 2 modes, summary message only,
 143  * and full usage message.
 144  */


 218         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDEF));
 219         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDEL));
 220         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDLO));
 221         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNDU));
 222         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNLD));
 223         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNOW));
 224         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNPA));
 225         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZNV));
 226         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZO));
 227         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZPIA));
 228         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRL));
 229         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRREL));
 230         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRS));
 231         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRSN));
 232         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZRSGRP));
 233         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZSCAP));
 234         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTARG));
 235         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZT));
 236         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTO));
 237         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTW));
 238         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZTY));
 239         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZWRAP));
 240         (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZVER));
 241 }
 242 
 243 /*
 244  * Rescan the archives seen on the command line in order
 245  * to handle circularly dependent archives, stopping when
 246  * no further member extraction occurs.
 247  *
 248  * entry:
 249  *      ofl - Output file descriptor
 250  *      isgrp - True if this is a an archive group search, False
 251  *              to search starting with argv[1] through end_arg_ndx
 252  *      end_arg_ndx - Index of final argv element to consider.
 253  */
 254 static uintptr_t
 255 ld_rescan_archives(Ofl_desc *ofl, int isgrp, int end_arg_ndx)
 256 {
 257         ofl->ofl_flags1 |= FLG_OF1_EXTRACT;
 258 


 304  * Checks the command line option flags for consistency.
 305  */
 306 static uintptr_t
 307 check_flags(Ofl_desc * ofl, int argc)
 308 {
 309         /*
 310          * If the user specified -zguidance=noall, then we can safely disable
 311          * the entire feature. The purpose of -zguidance=noall is to allow
 312          * the user to override guidance specified from a makefile via
 313          * the LD_OPTIONS environment variable, and so, we want to behave
 314          * in exactly the same manner we would have if no option were present.
 315          */
 316         if ((ofl->ofl_guideflags & (FLG_OFG_ENABLE | FLG_OFG_NO_ALL)) ==
 317             (FLG_OFG_ENABLE | FLG_OFG_NO_ALL))
 318                 ofl->ofl_guideflags &= ~FLG_OFG_ENABLE;
 319 
 320         if (Plibpath && (Llibdir || Ulibdir))
 321                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_YP),
 322                     Llibdir ? 'L' : 'U');
 323 
 324         if ((otype == OT_RELOC) || (otype == OT_KMOD)) {
 325                 if (otype == OT_RELOC) {
 326                         if (dflag == SET_UNKNOWN)
 327                                 dflag = SET_FALSE;
 328                         if ((dflag == SET_TRUE) &&
 329                             OFL_GUIDANCE(ofl, FLG_OFG_NO_KMOD)) {
 330                                 ld_eprintf(ofl, ERR_GUIDANCE,
 331                                     MSG_INTL(MSG_GUIDE_KMOD));
 332                         }
 333                 } else if (otype == OT_KMOD) {
 334                         if (dflag != SET_UNKNOWN) {
 335                                 ld_eprintf(ofl, ERR_FATAL,
 336                                     MSG_INTL(MSG_MARG_INCOMP),
 337                                     MSG_INTL(MSG_MARG_TYPE_KMOD),
 338                                     MSG_ORIG(MSG_ARG_D));
 339                         }
 340 
 341                         dflag = SET_TRUE;
 342                 }
 343 
 344                 /*
 345                  * Combining relocations when building a relocatable
 346                  * object isn't allowed.  Warn the user, but proceed.
 347                  */
 348                 if (ofl->ofl_flags & FLG_OF_COMREL) {
 349                         const char *msg;
 350 
 351                         if (otype == OT_RELOC) {
 352                                 msg = MSG_INTL(MSG_MARG_REL);
 353                         } else {
 354                                 msg = MSG_INTL(MSG_MARG_TYPE_KMOD);
 355                         }
 356                         ld_eprintf(ofl, ERR_WARNING, MSG_INTL(MSG_MARG_INCOMP),
 357                             msg,
 358                             MSG_ORIG(MSG_ARG_ZCOMBRELOC));
 359                 }
 360                 ofl->ofl_flags |= FLG_OF_RELOBJ;
 361 
 362                 if (otype == OT_KMOD)
 363                         ofl->ofl_flags |= FLG_OF_KMOD;
 364         } else {
 365                 /*
 366                  * Translating object capabilities to symbol capabilities is
 367                  * only meaningful when creating a relocatable object.
 368                  */
 369                 if (ofl->ofl_flags & FLG_OF_OTOSCAP)
 370                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_ONLY),
 371                             MSG_ORIG(MSG_ARG_ZSYMBOLCAP),
 372                             MSG_INTL(MSG_MARG_REL));
 373 
 374                 /*
 375                  * If the user hasn't explicitly requested that relocations
 376                  * not be combined, combine them by default.
 377                  */
 378                 if ((ofl->ofl_flags & FLG_OF_NOCOMREL) == 0)
 379                         ofl->ofl_flags |= FLG_OF_COMREL;
 380         }
 381 
 382         if (zdflag == SET_TRUE)
 383                 ofl->ofl_flags |= FLG_OF_NOUNDEF;


 394         if (Blflag)
 395                 ofl->ofl_flags |= FLG_OF_AUTOLCL;
 396 
 397         if (Beflag)
 398                 ofl->ofl_flags |= FLG_OF_AUTOELM;
 399 
 400         if (Blflag && Beflag)
 401                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
 402                     MSG_ORIG(MSG_ARG_BELIMINATE), MSG_ORIG(MSG_ARG_BLOCAL));
 403 
 404         if (ofl->ofl_interp && (ofl->ofl_flags1 & FLG_OF1_NOINTRP))
 405                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
 406                     MSG_ORIG(MSG_ARG_CI), MSG_ORIG(MSG_ARG_ZNOINTERP));
 407 
 408         if ((ofl->ofl_flags1 & (FLG_OF1_NRLXREL | FLG_OF1_RLXREL)) ==
 409             (FLG_OF1_NRLXREL | FLG_OF1_RLXREL))
 410                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
 411                     MSG_ORIG(MSG_ARG_ZRELAXRELOC),
 412                     MSG_ORIG(MSG_ARG_ZNORELAXRELOC));
 413 
 414         if (ofl->ofl_filtees && (otype != OT_SHARED))
 415                 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_ST_ONLYAVL),
 416                     ((ofl->ofl_flags & FLG_OF_AUX) ?
 417                     MSG_INTL(MSG_MARG_FILTER_AUX) : MSG_INTL(MSG_MARG_FILTER)));
 418 
 419         if (dflag != SET_FALSE) {
 420                 /*
 421                  * Set -Bdynamic on by default, setting is rechecked as input
 422                  * files are processed.
 423                  */
 424                 ofl->ofl_flags |=
 425                     (FLG_OF_DYNAMIC | FLG_OF_DYNLIBS | FLG_OF_PROCRED);
 426 
 427                 if (aflag)
 428                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_INCOMP),
 429                             MSG_ORIG(MSG_ARG_DY), MSG_ORIG(MSG_ARG_A));
 430 
 431                 if (bflag)
 432                         ofl->ofl_flags |= FLG_OF_BFLAG;
 433 
 434                 if (Bgflag == TRUE) {


 448                  */
 449                 if ((ofl->ofl_dtflags_1 & DF_1_NODEFLIB) && !ofl->ofl_rpath)
 450                         ld_eprintf(ofl, ERR_WARNING, MSG_INTL(MSG_ARG_NODEFLIB),
 451                             MSG_INTL(MSG_MARG_RPATH));
 452 
 453                 /*
 454                  * By default, text relocation warnings are given when building
 455                  * an executable unless the -b flag is specified.  This option
 456                  * implies that unclean text can be created, so no warnings are
 457                  * generated unless specifically asked for.
 458                  */
 459                 if ((ztflag == MSG_ORIG(MSG_ARG_ZTEXTOFF)) ||
 460                     ((ztflag == NULL) && bflag)) {
 461                         ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
 462                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 463                 } else if (ztflag == MSG_ORIG(MSG_ARG_ZTEXT)) {
 464                         ofl->ofl_flags |= FLG_OF_PURETXT;
 465                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 466                 }
 467 
 468                 if ((otype == OT_SHARED) || (otype == OT_EXEC)) {
 469                         /*
 470                          * Create a dynamic object.  -Bdirect indicates that all
 471                          * references should be bound directly.  This also
 472                          * enables lazyloading.  Individual symbols can be
 473                          * bound directly (or not) using mapfiles and the
 474                          * DIRECT (NODIRECT) qualifier.  With this capability,
 475                          * each syminfo entry is tagged SYMINFO_FLG_DIRECTBIND.
 476                          * Prior to this per-symbol direct binding, runtime
 477                          * direct binding was controlled via the DF_1_DIRECT
 478                          * flag.  This flag affected all references from the
 479                          * object.  -Bdirect continues to set this flag, and
 480                          * thus provides a means of taking a newly built
 481                          * direct binding object back to older systems.
 482                          *
 483                          * NOTE, any use of per-symbol NODIRECT bindings, or
 484                          * -znodirect, will disable the creation of the
 485                          * DF_1_DIRECT flag.  Older runtime linkers do not
 486                          * have the capability to do per-symbol direct bindings.
 487                          */
 488                         if (Bdflag == SET_TRUE) {
 489                                 ofl->ofl_dtflags_1 |= DF_1_DIRECT;
 490                                 ofl->ofl_flags1 |= FLG_OF1_LAZYLD;
 491                                 ofl->ofl_guideflags |= FLG_OFG_NO_LAZY;
 492                                 ofl->ofl_flags |= FLG_OF_SYMINFO;
 493                         }
 494 
 495                         /*
 496                          * -Bnodirect disables directly binding to any symbols
 497                          * exported from the object being created.  Individual
 498                          * references to external objects can still be affected
 499                          * by -zdirect or mapfile DIRECT directives.
 500                          */
 501                         if (Bdflag == SET_FALSE) {
 502                                 ofl->ofl_flags1 |= (FLG_OF1_NDIRECT |
 503                                     FLG_OF1_NGLBDIR | FLG_OF1_ALNODIR);
 504                                 ofl->ofl_flags |= FLG_OF_SYMINFO;
 505                         }
 506                 }
 507 
 508                 if (otype == OT_EXEC) {
 509                         /*
 510                          * Dynamically linked executable.
 511                          */
 512                         ofl->ofl_flags |= FLG_OF_EXEC;
 513 
 514                         if (zdflag != SET_FALSE)
 515                                 ofl->ofl_flags |= FLG_OF_NOUNDEF;
 516 
 517                         /*
 518                          * -z textwarn is the default for executables, and
 519                          * only an explicit -z text* option can change that,
 520                          * so there's no need to provide additional guidance.
 521                          */
 522                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 523 
 524                         if (Bsflag)
 525                                 ld_eprintf(ofl, ERR_FATAL,
 526                                     MSG_INTL(MSG_ARG_DY_INCOMP),
 527                                     MSG_ORIG(MSG_ARG_BSYMBOLIC));
 528                         if (ofl->ofl_soname)
 529                                 ld_eprintf(ofl, ERR_FATAL,
 530                                     MSG_INTL(MSG_MARG_DY_INCOMP),
 531                                     MSG_INTL(MSG_MARG_SONAME));
 532                 } else if (otype == OT_SHARED) {
 533                         /*
 534                          * Shared library.
 535                          */
 536                         ofl->ofl_flags |= FLG_OF_SHAROBJ;
 537 
 538                         /*
 539                          * By default, print text relocation warnings for
 540                          * executables but *not* for shared objects. However,
 541                          * if -z guidance is on, issue warnings for shared
 542                          * objects as well.
 543                          *
 544                          * If -z textwarn is explicitly specified, also issue
 545                          * guidance messages if -z guidance is on, but not
 546                          * for -z text or -z textoff.
 547                          */
 548                         if (ztflag == NULL) {
 549                                 if (!OFL_GUIDANCE(ofl, FLG_OFG_NO_TEXT))
 550                                         ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
 551                         } else if ((ofl->ofl_flags & FLG_OF_PURETXT) ||
 552                             (ofl->ofl_flags1 & FLG_OF1_TEXTOFF)) {


 562                                             MSG_INTL(MSG_ARG_INCOMP),
 563                                             MSG_ORIG(MSG_ARG_BSYMBOLIC),
 564                                             MSG_ORIG(MSG_ARG_BNODIRECT));
 565                                 ofl->ofl_flags |= FLG_OF_SYMBOLIC;
 566                                 ofl->ofl_dtflags |= DF_SYMBOLIC;
 567                         }
 568                 } else {
 569                         /*
 570                          * Dynamic relocatable object.
 571                          */
 572                         if (ztflag == NULL)
 573                                 ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
 574                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 575 
 576                         if (ofl->ofl_interp)
 577                                 ld_eprintf(ofl, ERR_FATAL,
 578                                     MSG_INTL(MSG_MARG_INCOMP),
 579                                     MSG_INTL(MSG_MARG_REL),
 580                                     MSG_ORIG(MSG_ARG_CI));
 581                 }
 582 
 583                 assert((ofl->ofl_flags & (FLG_OF_SHAROBJ|FLG_OF_EXEC)) !=
 584                     (FLG_OF_SHAROBJ|FLG_OF_EXEC));
 585         } else {
 586                 ofl->ofl_flags |= FLG_OF_STATIC;
 587 
 588                 if (bflag)
 589                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 590                             MSG_ORIG(MSG_ARG_B));
 591                 if (ofl->ofl_soname)
 592                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_ST_INCOMP),
 593                             MSG_INTL(MSG_MARG_SONAME));
 594                 if (ofl->ofl_depaudit)
 595                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 596                             MSG_ORIG(MSG_ARG_CP));
 597                 if (ofl->ofl_audit)
 598                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 599                             MSG_ORIG(MSG_ARG_P));
 600                 if (ofl->ofl_config)
 601                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 602                             MSG_ORIG(MSG_ARG_C));
 603                 if (ztflag)
 604                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_ARG_ST_INCOMP),
 605                             MSG_ORIG(MSG_ARG_ZTEXTALL));
 606                 if (otype == OT_SHARED)
 607                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_ST_INCOMP),
 608                             MSG_INTL(MSG_MARG_SO));
 609                 if (aflag && (otype == OT_RELOC))
 610                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_MARG_INCOMP),
 611                             MSG_ORIG(MSG_ARG_A), MSG_INTL(MSG_MARG_REL));
 612 
 613                 if (otype == OT_RELOC) {
 614                         /*
 615                          * We can only strip the symbol table and string table
 616                          * if no output relocations will refer to them.
 617                          */
 618                         if (sflag)
 619                                 ld_eprintf(ofl, ERR_WARNING,
 620                                     MSG_INTL(MSG_ARG_STRIP),
 621                                     MSG_INTL(MSG_MARG_REL),
 622                                     MSG_INTL(MSG_MARG_STRIP));
 623 
 624                         if (ztflag == NULL)
 625                                 ofl->ofl_flags1 |= FLG_OF1_TEXTOFF;
 626                         ofl->ofl_guideflags |= FLG_OFG_NO_TEXT;
 627 
 628                         if (ofl->ofl_interp)
 629                                 ld_eprintf(ofl, ERR_FATAL,
 630                                     MSG_INTL(MSG_MARG_INCOMP),
 631                                     MSG_INTL(MSG_MARG_REL),
 632                                     MSG_ORIG(MSG_ARG_CI));
 633                 } else {


1223                         break;
1224 
1225                 case 'P':
1226                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1227 
1228                         /*
1229                          * Multiple instances of this option may occur.  Each
1230                          * additional instance is effectively concatenated to
1231                          * the previous separated by a colon.
1232                          */
1233                         if (*optarg != '\0') {
1234                                 if ((ofl->ofl_depaudit =
1235                                     add_string(ofl->ofl_depaudit,
1236                                     optarg)) == (const char *)S_ERROR)
1237                                         return (S_ERROR);
1238                         }
1239                         break;
1240 
1241                 case 'r':
1242                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));
1243                         otype = OT_RELOC;
1244                         break;
1245 
1246                 case 'R':
1247                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1248 
1249                         /*
1250                          * Multiple instances of this option may occur.  Each
1251                          * additional instance is effectively concatenated to
1252                          * the previous separated by a colon.
1253                          */
1254                         if (*optarg != '\0') {
1255                                 if ((ofl->ofl_rpath =
1256                                     add_string(ofl->ofl_rpath,
1257                                     optarg)) == (const char *)S_ERROR)
1258                                         return (S_ERROR);
1259                         }
1260                         break;
1261 
1262                 case 's':
1263                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));


1531                                         ofl->ofl_flags |= FLG_OF_FATWARN;
1532                                 }
1533                         } else if (strcmp(optarg,
1534                             MSG_ORIG(MSG_ARG_NOFATWARN)) == 0) {
1535                                 if (zfwflag  == SET_TRUE)
1536                                         ld_eprintf(ofl, ERR_WARNING_NF,
1537                                             MSG_INTL(MSG_ARG_MTONCE),
1538                                             MSG_ORIG(MSG_ARG_ZFATWNOFATW));
1539                                 else
1540                                         zfwflag = SET_FALSE;
1541 
1542                         /*
1543                          * Process everything related to -z assert-deflib. This
1544                          * must be done in pass 1 because it gets used in pass
1545                          * 2.
1546                          */
1547                         } else if (strncmp(optarg, MSG_ORIG(MSG_ARG_ASSDEFLIB),
1548                             MSG_ARG_ASSDEFLIB_SIZE) == 0) {
1549                                 if (assdeflib_parse(ofl, optarg) != TRUE)
1550                                         return (S_ERROR);
1551 
1552                         /*
1553                          * Process new-style output type specification, which
1554                          * we'll use in pass 2 and throughout.
1555                          */
1556                         } else if (strncmp(optarg, MSG_ORIG(MSG_ARG_TYPE),
1557                             MSG_ARG_TYPE_SIZE) == 0) {
1558                                 char *p = optarg + MSG_ARG_TYPE_SIZE;
1559                                 if (*p != '=') {
1560                                         ld_eprintf(ofl, ERR_FATAL,
1561                                             MSG_INTL(MSG_ARG_ILLEGAL),
1562                                             MSG_ORIG(MSG_ARG_Z), optarg);
1563                                         return (S_ERROR);
1564                                 }
1565 
1566                                 p++;
1567                                 if (strcmp(p,
1568                                     MSG_ORIG(MSG_ARG_TYPE_RELOC)) == 0) {
1569                                         otype = OT_RELOC;
1570                                 } else if (strcmp(p,
1571                                     MSG_ORIG(MSG_ARG_TYPE_EXEC)) == 0) {
1572                                         otype = OT_EXEC;
1573                                 } else if (strcmp(p,
1574                                     MSG_ORIG(MSG_ARG_TYPE_SHARED)) == 0) {
1575                                         otype = OT_SHARED;
1576                                 } else if (strcmp(p,
1577                                     MSG_ORIG(MSG_ARG_TYPE_KMOD)) == 0) {
1578                                         otype = OT_KMOD;
1579                                 } else {
1580                                         ld_eprintf(ofl, ERR_FATAL,
1581                                             MSG_INTL(MSG_ARG_ILLEGAL),
1582                                             MSG_ORIG(MSG_ARG_Z), optarg);
1583                                         return (S_ERROR);
1584                                 }
1585                         /*
1586                          * The following options just need validation as they
1587                          * are interpreted on the second pass through the
1588                          * command line arguments.
1589                          */
1590                         } else if (
1591                             strncmp(optarg, MSG_ORIG(MSG_ARG_INITARRAY),
1592                             MSG_ARG_INITARRAY_SIZE) &&
1593                             strncmp(optarg, MSG_ORIG(MSG_ARG_FINIARRAY),
1594                             MSG_ARG_FINIARRAY_SIZE) &&
1595                             strncmp(optarg, MSG_ORIG(MSG_ARG_PREINITARRAY),
1596                             MSG_ARG_PREINITARRAY_SIZE) &&
1597                             strncmp(optarg, MSG_ORIG(MSG_ARG_RTLDINFO),
1598                             MSG_ARG_RTLDINFO_SIZE) &&
1599                             strncmp(optarg, MSG_ORIG(MSG_ARG_DTRACE),
1600                             MSG_ARG_DTRACE_SIZE) &&
1601                             strcmp(optarg, MSG_ORIG(MSG_ARG_ALLEXTRT)) &&
1602                             strcmp(optarg, MSG_ORIG(MSG_ARG_DFLEXTRT)) &&
1603                             strcmp(optarg, MSG_ORIG(MSG_ARG_DIRECT)) &&
1604                             strcmp(optarg, MSG_ORIG(MSG_ARG_NODIRECT)) &&


1683                                 Bgflag = TRUE;
1684                         else if (strcmp(optarg,
1685                             MSG_ORIG(MSG_STR_ELIMINATE)) == 0)
1686                                 Beflag = TRUE;
1687                         else if (strcmp(optarg,
1688                             MSG_ORIG(MSG_ARG_TRANSLATOR)) == 0) {
1689                                 ld_eprintf(ofl, ERR_WARNING,
1690                                     MSG_INTL(MSG_ARG_UNSUPPORTED),
1691                                     MSG_ORIG(MSG_ARG_BTRANSLATOR));
1692                         } else if (strcmp(optarg,
1693                             MSG_ORIG(MSG_STR_LD_DYNAMIC)) &&
1694                             strcmp(optarg, MSG_ORIG(MSG_ARG_STATIC))) {
1695                                 ld_eprintf(ofl, ERR_FATAL,
1696                                     MSG_INTL(MSG_ARG_ILLEGAL),
1697                                     MSG_ORIG(MSG_ARG_CB), optarg);
1698                         }
1699                         break;
1700 
1701                 case 'G':
1702                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));
1703                         otype = OT_SHARED;
1704                         break;
1705 
1706                 case 'L':
1707                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1708                         break;
1709 
1710                 case 'M':
1711                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1712                         if (aplist_append(&(ofl->ofl_maps), optarg,
1713                             AL_CNT_OFL_MAPFILES) == NULL)
1714                                 return (S_ERROR);
1715                         break;
1716 
1717                 case 'N':
1718                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1719                         break;
1720 
1721                 case 'Q':
1722                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1723                         if ((optarg[0] == 'n') && (optarg[1] == '\0')) {