Print this page
10908 Simplify SMAP relocations with krtld

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