Print this page
8616 ld has trouble parsing -z options specified with -Wl
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>


  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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  27  */
  28 /*
  29  * Copyright (c) 2012, Joyent, Inc.  All rights reserved.

  30  */
  31 
  32 /*
  33  * Publicly available flags are defined in ld(1).   The following flags are
  34  * private, and may be removed at any time.
  35  *
  36  *    OPTION                    MEANING
  37  *
  38  *    -z dtrace=symbol          assigns symbol to PT_SUNWDTRACE segment,
  39  *                              providing scratch area for dtrace processing.
  40  *
  41  *    -z noreloc                suppress relocation processing.  This provides
  42  *                              a mechanism for validating kernel module symbol
  43  *                              resolution that would normally incur fatal
  44  *                              relocation errors.
  45  *
  46  *    -z rtldinfo=symbol        assigns symbol to SUNW_RTLDINF dynamic tag,
  47  *                              providing pre-initialization specific routines
  48  *                              for TLS initialization.
  49  *


1220                         break;
1221 
1222                 case 's':
1223                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));
1224                         sflag = TRUE;
1225                         break;
1226 
1227                 case 't':
1228                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));
1229                         ofl->ofl_flags |= FLG_OF_NOWARN;
1230                         break;
1231 
1232                 case 'u':
1233                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1234                         break;
1235 
1236                 case 'z':
1237                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1238 
1239                         /*








1240                          * For specific help, print our usage message and exit
1241                          * immediately to ensure a 0 return code.
1242                          */
1243                         if (strncmp(optarg, MSG_ORIG(MSG_ARG_HELP),
1244                             MSG_ARG_HELP_SIZE) == 0) {
1245                                 usage_mesg(TRUE);
1246                                 exit(0);
1247                         }
1248 
1249                         /*
1250                          * For some options set a flag - further consistancy
1251                          * checks will be carried out in check_flags().
1252                          */
1253                         if ((strncmp(optarg, MSG_ORIG(MSG_ARG_LD32),
1254                             MSG_ARG_LD32_SIZE) == 0) ||
1255                             (strncmp(optarg, MSG_ORIG(MSG_ARG_LD64),
1256                             MSG_ARG_LD64_SIZE) == 0)) {
1257                                 if (createargv(ofl, usage) == S_ERROR)
1258                                         return (S_ERROR);
1259 




  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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  27  */
  28 /*
  29  * Copyright (c) 2012, Joyent, Inc.  All rights reserved.
  30  * Copyright 2017 RackTop Systems.
  31  */
  32 
  33 /*
  34  * Publicly available flags are defined in ld(1).   The following flags are
  35  * private, and may be removed at any time.
  36  *
  37  *    OPTION                    MEANING
  38  *
  39  *    -z dtrace=symbol          assigns symbol to PT_SUNWDTRACE segment,
  40  *                              providing scratch area for dtrace processing.
  41  *
  42  *    -z noreloc                suppress relocation processing.  This provides
  43  *                              a mechanism for validating kernel module symbol
  44  *                              resolution that would normally incur fatal
  45  *                              relocation errors.
  46  *
  47  *    -z rtldinfo=symbol        assigns symbol to SUNW_RTLDINF dynamic tag,
  48  *                              providing pre-initialization specific routines
  49  *                              for TLS initialization.
  50  *


1221                         break;
1222 
1223                 case 's':
1224                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));
1225                         sflag = TRUE;
1226                         break;
1227 
1228                 case 't':
1229                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, NULL));
1230                         ofl->ofl_flags |= FLG_OF_NOWARN;
1231                         break;
1232 
1233                 case 'u':
1234                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1235                         break;
1236 
1237                 case 'z':
1238                         DBG_CALL(Dbg_args_option(ofl->ofl_lml, ndx, c, optarg));
1239 
1240                         /*
1241                          * Skip comma that might be present between -z and its
1242                          * argument (e.g. if -Wl,-z,assert-deflib was passed).
1243                          */
1244                         if (strncmp(optarg, MSG_ORIG(MSG_STR_COMMA),
1245                              MSG_STR_COMMA_SIZE) == 0)
1246                                 optarg++;
1247 
1248                         /*
1249                          * For specific help, print our usage message and exit
1250                          * immediately to ensure a 0 return code.
1251                          */
1252                         if (strncmp(optarg, MSG_ORIG(MSG_ARG_HELP),
1253                             MSG_ARG_HELP_SIZE) == 0) {
1254                                 usage_mesg(TRUE);
1255                                 exit(0);
1256                         }
1257 
1258                         /*
1259                          * For some options set a flag - further consistancy
1260                          * checks will be carried out in check_flags().
1261                          */
1262                         if ((strncmp(optarg, MSG_ORIG(MSG_ARG_LD32),
1263                             MSG_ARG_LD32_SIZE) == 0) ||
1264                             (strncmp(optarg, MSG_ORIG(MSG_ARG_LD64),
1265                             MSG_ARG_LD64_SIZE) == 0)) {
1266                                 if (createargv(ofl, usage) == S_ERROR)
1267                                         return (S_ERROR);
1268