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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/libld/common/machrel.amd.c
          +++ new/usr/src/cmd/sgs/libld/common/machrel.amd.c
↓ open down ↓ 427 lines elided ↑ open up ↑
 428  428          if (orsp->rel_flags & FLG_REL_ADVAL)
 429  429                  raddend += value;
 430  430  
 431  431          /*
 432  432           * The addend field for R_AMD64_DTPMOD64 means nothing.  The addend
 433  433           * is propagated in the corresponding R_AMD64_DTPOFF64 relocation.
 434  434           */
 435  435          if (orsp->rel_rtype == R_AMD64_DTPMOD64)
 436  436                  raddend = 0;
 437  437  
 438      -        relbits = (char *)relosp->os_outdata->d_buf;
      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 +        }
 439  452  
 440  453          rea.r_info = ELF_R_INFO(ndx, orsp->rel_rtype);
 441  454          rea.r_offset = roffset;
 442  455          rea.r_addend = raddend;
 443  456          DBG_CALL(Dbg_reloc_out(ofl, ELF_DBG_LD, SHT_RELA, &rea, relosp->os_name,
 444  457              ld_reloc_sym_name(orsp)));
 445  458  
 446  459          /*
 447  460           * Assert we haven't walked off the end of our relocation table.
 448  461           */
 449  462          assert(relosp->os_szoutrels <= relosp->os_shdr->sh_size);
 450  463  
      464 +        relbits = (char *)relosp->os_outdata->d_buf;
      465 +
 451  466          (void) memcpy((relbits + relosp->os_szoutrels),
 452  467              (char *)&rea, sizeof (Rela));
 453  468          relosp->os_szoutrels += (Xword)sizeof (Rela);
 454  469  
 455  470          /*
 456  471           * Determine if this relocation is against a non-writable, allocatable
 457  472           * section.  If so we may need to provide a text relocation diagnostic.
 458  473           * Note that relocations against the .plt (R_AMD64_JUMP_SLOT) actually
 459  474           * result in modifications to the .got.
 460  475           */
↓ open down ↓ 665 lines elided ↑ open up ↑
1126 1141          Sym_desc        *sdp = rsp->rel_sym;
1127 1142  
1128 1143          /*
1129 1144           * Static executables *do not* want any relocations against them.
1130 1145           * Since our engine still creates relocations against a WEAK UNDEFINED
1131 1146           * symbol in a static executable, it's best to disable them here
1132 1147           * instead of through out the relocation code.
1133 1148           */
1134 1149          if (OFL_IS_STATIC_EXEC(ofl))
1135 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 +        }
1136 1164  
1137 1165          /*
1138 1166           * If we are adding a output relocation against a section
1139 1167           * symbol (non-RELATIVE) then mark that section.  These sections
1140 1168           * will be added to the .dynsym symbol table.
1141 1169           */
1142 1170          if (sdp && (rsp->rel_rtype != M_R_RELATIVE) &&
1143 1171              ((flags & FLG_REL_SCNNDX) ||
1144 1172              (ELF_ST_TYPE(sdp->sd_sym->st_info) == STT_SECTION))) {
1145 1173  
↓ open down ↓ 565 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX