Print this page
10366 ld(1) should support GNU-style linker sets
10581 ld(1) should know kernel modules are a thing


3173                 if ((ehdr = elf_getehdr(elf)) == NULL) {
3174                         int     _class = gelf_getclass(elf);
3175 
3176                         /*
3177                          * This can fail for a number of reasons. Typically
3178                          * the object class is incorrect (ie. user is building
3179                          * 64-bit but managed to point at 32-bit libraries).
3180                          * Other ELF errors can include a truncated or corrupt
3181                          * file. Try to get the best error message possible.
3182                          */
3183                         if (ld_targ.t_m.m_class != _class) {
3184                                 _rej.rej_type = SGS_REJ_CLASS;
3185                                 _rej.rej_info = (uint_t)_class;
3186                         } else {
3187                                 _rej.rej_type = SGS_REJ_STR;
3188                                 _rej.rej_str = elf_errmsg(-1);
3189                         }
3190                         _rej.rej_name = name;
3191                         DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej,
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                 /*
3201                  * Determine if we've already come across this file.
3202                  */
3203                 if (!(flags & FLG_IF_EXTRACT)) {
3204                         APlist  *apl;
3205                         Aliste  idx;
3206 
3207                         if (ehdr->e_type == ET_REL)
3208                                 apl = ofl->ofl_objs;
3209                         else
3210                                 apl = ofl->ofl_sos;
3211 
3212                         /*




3173                 if ((ehdr = elf_getehdr(elf)) == NULL) {
3174                         int     _class = gelf_getclass(elf);
3175 
3176                         /*
3177                          * This can fail for a number of reasons. Typically
3178                          * the object class is incorrect (ie. user is building
3179                          * 64-bit but managed to point at 32-bit libraries).
3180                          * Other ELF errors can include a truncated or corrupt
3181                          * file. Try to get the best error message possible.
3182                          */
3183                         if (ld_targ.t_m.m_class != _class) {
3184                                 _rej.rej_type = SGS_REJ_CLASS;
3185                                 _rej.rej_info = (uint_t)_class;
3186                         } else {
3187                                 _rej.rej_type = SGS_REJ_STR;
3188                                 _rej.rej_str = elf_errmsg(-1);
3189                         }
3190                         _rej.rej_name = name;
3191                         DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej,
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) > 0) {
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                         _rej.rej_name = name;
3207 
3208                         if (rej->rej_type == 0) {
3209                                 *rej = _rej;
3210                                 rej->rej_name = strdup(_rej.rej_name);
3211                         }
3212                         return (0);
3213                 }
3214 
3215                 /*
3216                  * Determine if we've already come across this file.
3217                  */
3218                 if (!(flags & FLG_IF_EXTRACT)) {
3219                         APlist  *apl;
3220                         Aliste  idx;
3221 
3222                         if (ehdr->e_type == ET_REL)
3223                                 apl = ofl->ofl_objs;
3224                         else
3225                                 apl = ofl->ofl_sos;
3226 
3227                         /*