Print this page
3616 SHF_GROUP sections should not be discarded via other COMDAT mechanisms
3709 need sloppy relocation for GNU .debug_macro
Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Reviewed by: Robert Mustacchi <rm@joyent.com>


3446          */
3447         if ((data->d_buf = libld_calloc(size, 1)) == NULL)
3448                 return ((Is_desc *)S_ERROR);
3449         (void) memcpy(data->d_buf, ld_targ.t_nf.nf_template,
3450             ld_targ.t_nf.nf_size);
3451 
3452         /*
3453          * If size was larger than required, and the target supplies
3454          * a fill function, use it to fill the balance. If there is no
3455          * fill function, we accept the 0-fill supplied by libld_calloc().
3456          */
3457         if ((ld_targ.t_ff.ff_execfill != NULL) && (size > ld_targ.t_nf.nf_size))
3458                 ld_targ.t_ff.ff_execfill(data->d_buf, ld_targ.t_nf.nf_size,
3459                     size - ld_targ.t_nf.nf_size);
3460 
3461         if (aplist_append(&ofl->ofl_maptext, isec, AL_CNT_OFL_MAPSECS) == NULL)
3462                 return ((Is_desc *)S_ERROR);
3463 
3464         return (isec);
3465 }
















































3446          */
3447         if ((data->d_buf = libld_calloc(size, 1)) == NULL)
3448                 return ((Is_desc *)S_ERROR);
3449         (void) memcpy(data->d_buf, ld_targ.t_nf.nf_template,
3450             ld_targ.t_nf.nf_size);
3451 
3452         /*
3453          * If size was larger than required, and the target supplies
3454          * a fill function, use it to fill the balance. If there is no
3455          * fill function, we accept the 0-fill supplied by libld_calloc().
3456          */
3457         if ((ld_targ.t_ff.ff_execfill != NULL) && (size > ld_targ.t_nf.nf_size))
3458                 ld_targ.t_ff.ff_execfill(data->d_buf, ld_targ.t_nf.nf_size,
3459                     size - ld_targ.t_nf.nf_size);
3460 
3461         if (aplist_append(&ofl->ofl_maptext, isec, AL_CNT_OFL_MAPSECS) == NULL)
3462                 return ((Is_desc *)S_ERROR);
3463 
3464         return (isec);
3465 }
3466 
3467 void
3468 ld_comdat_validate(Ofl_desc *ofl, Ifl_desc *ifl)
3469 {
3470         int i;
3471 
3472         for (i = 0; i < ifl->ifl_shnum; i++) {
3473                 Is_desc *isp = ifl->ifl_isdesc[i];
3474                 int types = 0;
3475                 char buf[1024] = "";
3476                 Group_desc *gr = NULL;
3477 
3478                 if ((isp == NULL) || (isp->is_flags & FLG_IS_COMDAT) == 0)
3479                         continue;
3480 
3481                 if (isp->is_shdr->sh_type == SHT_SUNW_COMDAT) {
3482                         types++;
3483                         (void) strlcpy(buf, MSG_ORIG(MSG_STR_SUNW_COMDAT),
3484                             sizeof (buf));
3485                 }
3486 
3487                 if (strncmp(MSG_ORIG(MSG_SCN_GNU_LINKONCE), isp->is_name,
3488                     MSG_SCN_GNU_LINKONCE_SIZE) == 0) {
3489                         types++;
3490                         if (types > 1)
3491                                 (void) strlcat(buf, ", ", sizeof (buf));
3492                         (void) strlcat(buf, MSG_ORIG(MSG_SCN_GNU_LINKONCE),
3493                             sizeof (buf));
3494                 }
3495 
3496                 if ((isp->is_shdr->sh_flags & SHF_GROUP) &&
3497                     ((gr = ld_get_group(ofl, isp)) != NULL) &&
3498                     (gr->gd_data[0] & GRP_COMDAT)) {
3499                         types++;
3500                         if (types > 1)
3501                                 (void) strlcat(buf, ", ", sizeof (buf));
3502                         (void) strlcat(buf, MSG_ORIG(MSG_STR_GROUP),
3503                             sizeof (buf));
3504                 }
3505 
3506                 if (types > 1)
3507                         ld_eprintf(ofl, ERR_FATAL,
3508                             MSG_INTL(MSG_SCN_MULTICOMDAT), ifl->ifl_name,
3509                             EC_WORD(isp->is_scnndx), isp->is_name, buf);
3510         }
3511 }