Print this page
9059 Simplify SMAP relocations with krtld
Portions contributed by: John Levon <john.levon@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/krtld/kobj.c
          +++ new/usr/src/uts/common/krtld/kobj.c
↓ open down ↓ 2171 lines elided ↑ open up ↑
2172 2172          mutex_exit(&mod_lock);
2173 2173  
2174 2174          kobj_notify(KOBJ_NOTIFY_MODUNLOADED, modp);
2175 2175          free_module_data(mp);
2176 2176  }
2177 2177  
2178 2178  static void
2179 2179  free_module_data(struct module *mp)
2180 2180  {
2181 2181          struct module_list *lp, *tmp;
     2182 +        hotinline_desc_t *hid, *next;
2182 2183          int ksyms_exported = 0;
2183 2184  
2184 2185          lp = mp->head;
2185 2186          while (lp) {
2186 2187                  tmp = lp;
2187 2188                  lp = lp->next;
2188 2189                  kobj_free((char *)tmp, sizeof (*tmp));
2189 2190          }
2190 2191  
     2192 +        /* release hotinlines */
     2193 +        hid = mp->hi_calls;
     2194 +        while (hid != NULL) {
     2195 +                next = hid->hid_next;
     2196 +                kobj_free(hid->hid_symname, strlen(hid->hid_symname) + 1);
     2197 +                kobj_free(hid, sizeof (hotinline_desc_t));
     2198 +                hid = next;
     2199 +        }
     2200 +
2191 2201          rw_enter(&ksyms_lock, RW_WRITER);
2192 2202          if (mp->symspace) {
2193 2203                  if (vmem_contains(ksyms_arena, mp->symspace, mp->symsize)) {
2194 2204                          vmem_free(ksyms_arena, mp->symspace, mp->symsize);
2195 2205                          ksyms_exported = 1;
2196 2206                  } else {
2197 2207                          if (mp->flags & KOBJ_NOKSYMS)
2198 2208                                  ksyms_exported = 1;
2199 2209                          kobj_free(mp->symspace, mp->symsize);
2200 2210                  }
↓ open down ↓ 825 lines elided ↑ open up ↑
3026 3036                          if ((sp1 = kobj_lookup_all(mp, name, 0)) != NULL) {
3027 3037                                  sp->st_shndx = SHN_ABS;
3028 3038                                  sp->st_value = sp1->st_value;
3029 3039                                  continue;
3030 3040                          }
3031 3041                  }
3032 3042  
3033 3043                  if (sp->st_shndx == SHN_UNDEF) {
3034 3044                          resolved = 0;
3035 3045  
     3046 +                        /*
     3047 +                         * Skip over sdt probes and smap calls,
     3048 +                         * they're relocated later.
     3049 +                         */
3036 3050                          if (strncmp(name, sdt_prefix, strlen(sdt_prefix)) == 0)
3037 3051                                  continue;
     3052 +#if defined(__x86)
     3053 +                        if (strcmp(name, "smap_enable") == 0 ||
     3054 +                            strcmp(name, "smap_disable") == 0)
     3055 +                                continue;
     3056 +#endif /* defined(__x86) */
3038 3057  
     3058 +
3039 3059                          /*
3040 3060                           * If it's not a weak reference and it's
3041 3061                           * not a primary object, it's an error.
3042 3062                           * (Primary objects may take more than
3043 3063                           * one pass to resolve)
3044 3064                           */
3045 3065                          if (!(mp->flags & KOBJ_PRIM) &&
3046 3066                              ELF_ST_BIND(sp->st_info) != STB_WEAK) {
3047 3067                                  _kobj_printf(ops, "%s: undefined symbol",
3048 3068                                      mp->filename);
↓ open down ↓ 1621 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX