Print this page
ld should reject kernel modules as input

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/libld/common/files.c
          +++ new/usr/src/cmd/sgs/libld/common/files.c
↓ open down ↓ 2348 lines elided ↑ open up ↑
2349 2349  }
2350 2350  
2351 2351  /*
2352 2352   * Process a relocation entry. At this point all input sections from this
2353 2353   * input file have been assigned an input section descriptor which is saved
2354 2354   * in the `ifl_isdesc' array.
2355 2355   */
2356 2356  static uintptr_t
2357 2357  rel_process(Is_desc *isc, Ifl_desc *ifl, Ofl_desc *ofl)
2358 2358  {
2359      -        Word    rndx;
     2359 +        Word    rndx;
2360 2360          Is_desc *risc;
2361 2361          Os_desc *osp;
2362 2362          Shdr    *shdr = isc->is_shdr;
2363 2363          Conv_inv_buf_t inv_buf;
2364 2364  
2365 2365          /*
2366 2366           * Make sure this is a valid relocation we can handle.
2367 2367           */
2368 2368          if (shdr->sh_type != ld_targ.t_m.m_rel_sht_type) {
2369 2369                  ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_FIL_INVALSEC),
↓ open down ↓ 813 lines elided ↑ open up ↑
3183 3183                          if (ld_targ.t_m.m_class != _class) {
3184 3184                                  _rej.rej_type = SGS_REJ_CLASS;
3185 3185                                  _rej.rej_info = (uint_t)_class;
3186 3186                          } else {
3187 3187                                  _rej.rej_type = SGS_REJ_STR;
3188 3188                                  _rej.rej_str = elf_errmsg(-1);
3189 3189                          }
3190 3190                          _rej.rej_name = name;
3191 3191                          DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej,
3192 3192                              ld_targ.t_m.m_mach));
     3193 +                        if (rej->rej_type == 0) {
     3194 +                                *rej = _rej;
     3195 +                                rej->rej_name = strdup(_rej.rej_name);
     3196 +                        }
     3197 +                        return (0);
     3198 +                }
     3199 +
     3200 +                if (_gelf_getdynval(elf, DT_SUNW_KMOD) == 1) {
     3201 +                        _rej.rej_name = name;
     3202 +                        DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej,
     3203 +                            ld_targ.t_m.m_mach));
     3204 +                        _rej.rej_type = SGS_REJ_KMOD;
     3205 +                        _rej.rej_str = elf_errmsg(-1);
     3206 +
3193 3207                          if (rej->rej_type == 0) {
3194 3208                                  *rej = _rej;
3195 3209                                  rej->rej_name = strdup(_rej.rej_name);
3196 3210                          }
3197 3211                          return (0);
3198 3212                  }
3199 3213  
3200 3214                  /*
3201 3215                   * Determine if we've already come across this file.
3202 3216                   */
↓ open down ↓ 522 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX