Print this page
OS-3477 lx brand: mdb(1) doesn't find branded symbols
OS-3426 lx brand: dtrace(1M) doesn't find branded symbols

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/librtld_db/common/rd_elf.c
          +++ new/usr/src/cmd/sgs/librtld_db/common/rd_elf.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
       26 +/*
       27 + * Copyright (c) 2014 Joyent, Inc.  All rights reserved.
       28 + */
       29 +
  26   30  #include        <stdlib.h>
  27   31  #include        <stdio.h>
  28   32  #include        <proc_service.h>
  29   33  #include        <link.h>
  30   34  #include        <rtld_db.h>
  31   35  #include        <rtld.h>
  32   36  #include        <alist.h>
  33   37  #include        <list.h>
  34   38  #include        <_rtld_db.h>
  35   39  #include        <msg.h>
  36   40  #include        <limits.h>
  37   41  #include        <string.h>
  38   42  #include        <sys/param.h>
  39   43  
  40   44  /*
       45 + * We want to include zone.h to pull in the prototype for zone_get_nroot(),
       46 + * but we need to avoid pulling in <sys/stream.h>, which has a definition
       47 + * of M_DATA that conflicts with the ELF-related definition in machdep_*.h.
       48 + */
       49 +#define         _SYS_STREAM_H
       50 +#include        <zone.h>
       51 +
       52 +/*
  41   53   * 64-bit builds are going to compile this module twice, the
  42   54   * second time with _ELF64 defined.  These defines should make
  43   55   * all the necessary adjustments to the code.
  44   56   */
  45   57  #ifdef _LP64
  46   58  #ifdef _ELF64
  47   59  #define _rd_event_enable32      _rd_event_enable64
  48   60  #define _rd_event_getmsg32      _rd_event_getmsg64
  49   61  #define _rd_get_dyns32          _rd_get_dyns64
  50   62  #define _rd_get_ehdr32          _rd_get_ehdr64
↓ open down ↓ 225 lines elided ↑ open up ↑
 276  288                  if (rc != RD_OK) {
 277  289                          LOG(ps_plog(MSG_ORIG(MSG_DB_INITFAILED)));
 278  290                          return (rc);
 279  291                  }
 280  292          }
 281  293  
 282  294          /*
 283  295           * If we are debugging a branded executable, load the appropriate
 284  296           * helper library, and call its initialization routine.  Being unable
 285  297           * to load the helper library is not a critical error.  (Hopefully
 286      -         * we'll still be able to access some objects in the target.)
      298 +         * we'll still be able to access some objects in the target.)  Note
      299 +         * that we pull in the native root here to allow for helper libraries
      300 +         * to be properly found from within the branded zone.
 287  301           */
 288  302          ps_pbrandname = (ps_pbrandname_fp_t)dlsym(RTLD_PROBE, "ps_pbrandname");
 289  303          while ((ps_pbrandname != NULL) &&
 290  304              (ps_pbrandname(php, brandname, MAXPATHLEN) == PS_OK)) {
 291  305                  const char *isa = "";
 292  306  
 293  307  #ifdef _LP64
 294  308                  isa = MSG_ORIG(MSG_DB_64BIT_PREFIX);
 295  309  #endif /* _LP64 */
 296  310  
 297      -                if (rtld_db_helper_path[0] != '\0')
      311 +                if (rtld_db_helper_path[0] != '\0') {
 298  312                          (void) snprintf(brandlib, MAXPATHLEN,
 299  313                              MSG_ORIG(MSG_DB_BRAND_HELPERPATH_PREFIX),
 300  314                              rtld_db_helper_path,
 301  315                              MSG_ORIG(MSG_DB_HELPER_PREFIX), brandname, isa,
 302  316                              brandname);
 303      -                else
      317 +                } else {
      318 +                        const char *nroot = zone_get_nroot();
      319 +
      320 +                        if (nroot == NULL)
      321 +                                nroot = "";
      322 +
 304  323                          (void) snprintf(brandlib, MAXPATHLEN,
 305      -                            MSG_ORIG(MSG_DB_BRAND_HELPERPATH),
      324 +                            MSG_ORIG(MSG_DB_BRAND_HELPERPATH), nroot,
 306  325                              MSG_ORIG(MSG_DB_HELPER_PREFIX), brandname, isa,
 307  326                              brandname);
      327 +                }
 308  328  
 309  329                  rap->rd_helper.rh_dlhandle = dlopen(brandlib,
 310  330                      RTLD_LAZY | RTLD_LOCAL);
 311  331                  if (rap->rd_helper.rh_dlhandle == NULL) {
 312  332                          LOG(ps_plog(MSG_ORIG(MSG_DB_HELPERLOADFAILED),
 313  333                              brandlib));
 314  334                          break;
 315  335                  }
 316  336  
 317  337                  rap->rd_helper.rh_ops = dlsym(rap->rd_helper.rh_dlhandle,
↓ open down ↓ 580 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX