Print this page
11057 hidden undefined weak symbols should not leave relocations
11058 libld entrance descriptor assertions get NDEBUG check backwards


 418                         else
 419                                 ndx = sdp->sd_shndx;
 420                 } else
 421                         ndx = ofl->ofl_parexpnndx;
 422         } else
 423                 ndx = sdp->sd_symndx;
 424 
 425         /*
 426          * Add the symbols 'value' to the addend field.
 427          */
 428         if (orsp->rel_flags & FLG_REL_ADVAL)
 429                 raddend += value;
 430 
 431         /*
 432          * The addend field for R_AMD64_DTPMOD64 means nothing.  The addend
 433          * is propagated in the corresponding R_AMD64_DTPOFF64 relocation.
 434          */
 435         if (orsp->rel_rtype == R_AMD64_DTPMOD64)
 436                 raddend = 0;
 437 
 438         relbits = (char *)relosp->os_outdata->d_buf;













 439 
 440         rea.r_info = ELF_R_INFO(ndx, orsp->rel_rtype);
 441         rea.r_offset = roffset;
 442         rea.r_addend = raddend;
 443         DBG_CALL(Dbg_reloc_out(ofl, ELF_DBG_LD, SHT_RELA, &rea, relosp->os_name,
 444             ld_reloc_sym_name(orsp)));
 445 
 446         /*
 447          * Assert we haven't walked off the end of our relocation table.
 448          */
 449         assert(relosp->os_szoutrels <= relosp->os_shdr->sh_size);
 450 


 451         (void) memcpy((relbits + relosp->os_szoutrels),
 452             (char *)&rea, sizeof (Rela));
 453         relosp->os_szoutrels += (Xword)sizeof (Rela);
 454 
 455         /*
 456          * Determine if this relocation is against a non-writable, allocatable
 457          * section.  If so we may need to provide a text relocation diagnostic.
 458          * Note that relocations against the .plt (R_AMD64_JUMP_SLOT) actually
 459          * result in modifications to the .got.
 460          */
 461         if (orsp->rel_rtype == R_AMD64_JUMP_SLOT)
 462                 osp = ofl->ofl_osgot;
 463 
 464         ld_reloc_remain_entry(orsp, osp, ofl, remain_seen);
 465         return (1);
 466 }
 467 
 468 /*
 469  * amd64 Instructions for TLS processing
 470  */


1116                         }
1117                 }
1118         }
1119         return (return_code);
1120 }
1121 
1122 static uintptr_t
1123 ld_add_outrel(Word flags, Rel_desc *rsp, Ofl_desc *ofl)
1124 {
1125         Rel_desc        *orsp;
1126         Sym_desc        *sdp = rsp->rel_sym;
1127 
1128         /*
1129          * Static executables *do not* want any relocations against them.
1130          * Since our engine still creates relocations against a WEAK UNDEFINED
1131          * symbol in a static executable, it's best to disable them here
1132          * instead of through out the relocation code.
1133          */
1134         if (OFL_IS_STATIC_EXEC(ofl))
1135                 return (1);













1136 
1137         /*
1138          * If we are adding a output relocation against a section
1139          * symbol (non-RELATIVE) then mark that section.  These sections
1140          * will be added to the .dynsym symbol table.
1141          */
1142         if (sdp && (rsp->rel_rtype != M_R_RELATIVE) &&
1143             ((flags & FLG_REL_SCNNDX) ||
1144             (ELF_ST_TYPE(sdp->sd_sym->st_info) == STT_SECTION))) {
1145 
1146                 /*
1147                  * If this is a COMMON symbol - no output section
1148                  * exists yet - (it's created as part of sym_validate()).
1149                  * So - we mark here that when it's created it should
1150                  * be tagged with the FLG_OS_OUTREL flag.
1151                  */
1152                 if ((sdp->sd_flags & FLG_SY_SPECSEC) &&
1153                     (sdp->sd_sym->st_shndx == SHN_COMMON)) {
1154                         if (ELF_ST_TYPE(sdp->sd_sym->st_info) != STT_TLS)
1155                                 ofl->ofl_flags1 |= FLG_OF1_BSSOREL;




 418                         else
 419                                 ndx = sdp->sd_shndx;
 420                 } else
 421                         ndx = ofl->ofl_parexpnndx;
 422         } else
 423                 ndx = sdp->sd_symndx;
 424 
 425         /*
 426          * Add the symbols 'value' to the addend field.
 427          */
 428         if (orsp->rel_flags & FLG_REL_ADVAL)
 429                 raddend += value;
 430 
 431         /*
 432          * The addend field for R_AMD64_DTPMOD64 means nothing.  The addend
 433          * is propagated in the corresponding R_AMD64_DTPOFF64 relocation.
 434          */
 435         if (orsp->rel_rtype == R_AMD64_DTPMOD64)
 436                 raddend = 0;
 437 
 438         if ((orsp->rel_rtype != M_R_NONE) &&
 439             (orsp->rel_rtype != M_R_RELATIVE)) {
 440                 if (ndx == 0) {
 441                         Conv_inv_buf_t  inv_buf;
 442                         Is_desc *isp = orsp->rel_isdesc;
 443 
 444                         ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_REL_NOSYMBOL),
 445                             conv_reloc_type(ofl->ofl_nehdr->e_machine,
 446                             orsp->rel_rtype, 0, &inv_buf),
 447                             isp->is_file->ifl_name, EC_WORD(isp->is_scnndx),
 448                             isp->is_name, EC_XWORD(roffset));
 449                         return (S_ERROR);
 450                 }
 451         }
 452 
 453         rea.r_info = ELF_R_INFO(ndx, orsp->rel_rtype);
 454         rea.r_offset = roffset;
 455         rea.r_addend = raddend;
 456         DBG_CALL(Dbg_reloc_out(ofl, ELF_DBG_LD, SHT_RELA, &rea, relosp->os_name,
 457             ld_reloc_sym_name(orsp)));
 458 
 459         /*
 460          * Assert we haven't walked off the end of our relocation table.
 461          */
 462         assert(relosp->os_szoutrels <= relosp->os_shdr->sh_size);
 463 
 464         relbits = (char *)relosp->os_outdata->d_buf;
 465 
 466         (void) memcpy((relbits + relosp->os_szoutrels),
 467             (char *)&rea, sizeof (Rela));
 468         relosp->os_szoutrels += (Xword)sizeof (Rela);
 469 
 470         /*
 471          * Determine if this relocation is against a non-writable, allocatable
 472          * section.  If so we may need to provide a text relocation diagnostic.
 473          * Note that relocations against the .plt (R_AMD64_JUMP_SLOT) actually
 474          * result in modifications to the .got.
 475          */
 476         if (orsp->rel_rtype == R_AMD64_JUMP_SLOT)
 477                 osp = ofl->ofl_osgot;
 478 
 479         ld_reloc_remain_entry(orsp, osp, ofl, remain_seen);
 480         return (1);
 481 }
 482 
 483 /*
 484  * amd64 Instructions for TLS processing
 485  */


1131                         }
1132                 }
1133         }
1134         return (return_code);
1135 }
1136 
1137 static uintptr_t
1138 ld_add_outrel(Word flags, Rel_desc *rsp, Ofl_desc *ofl)
1139 {
1140         Rel_desc        *orsp;
1141         Sym_desc        *sdp = rsp->rel_sym;
1142 
1143         /*
1144          * Static executables *do not* want any relocations against them.
1145          * Since our engine still creates relocations against a WEAK UNDEFINED
1146          * symbol in a static executable, it's best to disable them here
1147          * instead of through out the relocation code.
1148          */
1149         if (OFL_IS_STATIC_EXEC(ofl))
1150                 return (1);
1151 
1152         /*
1153          * If the symbol will be reduced, we can't leave outstanding
1154          * relocations against it, as nothing will ever be able to satisfy them
1155          * (and the symbol won't be in .dynsym
1156          */
1157         if ((sdp != NULL) &&
1158             (sdp->sd_sym->st_shndx == SHN_UNDEF) &&
1159             (rsp->rel_rtype != M_R_NONE) &&
1160             (rsp->rel_rtype != M_R_RELATIVE)) {
1161                 if (ld_sym_reducable(ofl, sdp))
1162                         return (1);
1163         }
1164 
1165         /*
1166          * If we are adding a output relocation against a section
1167          * symbol (non-RELATIVE) then mark that section.  These sections
1168          * will be added to the .dynsym symbol table.
1169          */
1170         if (sdp && (rsp->rel_rtype != M_R_RELATIVE) &&
1171             ((flags & FLG_REL_SCNNDX) ||
1172             (ELF_ST_TYPE(sdp->sd_sym->st_info) == STT_SECTION))) {
1173 
1174                 /*
1175                  * If this is a COMMON symbol - no output section
1176                  * exists yet - (it's created as part of sym_validate()).
1177                  * So - we mark here that when it's created it should
1178                  * be tagged with the FLG_OS_OUTREL flag.
1179                  */
1180                 if ((sdp->sd_flags & FLG_SY_SPECSEC) &&
1181                     (sdp->sd_sym->st_shndx == SHN_COMMON)) {
1182                         if (ELF_ST_TYPE(sdp->sd_sym->st_info) != STT_TLS)
1183                                 ofl->ofl_flags1 |= FLG_OF1_BSSOREL;