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.intel.c
          +++ new/usr/src/cmd/sgs/libld/common/machrel.intel.c
↓ open down ↓ 347 lines elided ↑ open up ↑
 348  348                  /*
 349  349                   * Get the address of the data item we need to modify.
 350  350                   */
 351  351                  addr = (uchar_t *)((uintptr_t)orsp->rel_roffset +
 352  352                      (uintptr_t)_elf_getxoff(orsp->rel_isdesc->is_indata));
 353  353                  addr += (uintptr_t)RELAUX_GET_OSDESC(orsp)->os_outdata->d_buf;
 354  354                  if (ld_reloc_targval_set(ofl, orsp, addr, addend) == 0)
 355  355                          return (S_ERROR);
 356  356          }
 357  357  
 358      -        relbits = (char *)relosp->os_outdata->d_buf;
      358 +        if ((orsp->rel_rtype != M_R_NONE) &&
      359 +            (orsp->rel_rtype != M_R_RELATIVE)) {
      360 +                if (ndx == 0) {
      361 +                        Conv_inv_buf_t  inv_buf;
      362 +                        Is_desc *isp = orsp->rel_isdesc;
      363 +
      364 +                        ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_REL_NOSYMBOL),
      365 +                            conv_reloc_type(ofl->ofl_nehdr->e_machine,
      366 +                            orsp->rel_rtype, 0, &inv_buf),
      367 +                            isp->is_file->ifl_name, EC_WORD(isp->is_scnndx),
      368 +                            isp->is_name, EC_XWORD(roffset));
      369 +                        return (S_ERROR);
      370 +                }
      371 +        }
 359  372  
 360  373          rea.r_info = ELF_R_INFO(ndx, orsp->rel_rtype);
 361  374          rea.r_offset = roffset;
 362  375          DBG_CALL(Dbg_reloc_out(ofl, ELF_DBG_LD, SHT_REL, &rea, relosp->os_name,
 363  376              ld_reloc_sym_name(orsp)));
 364  377  
 365  378          /*
 366  379           * Assert we haven't walked off the end of our relocation table.
 367  380           */
 368  381          assert(relosp->os_szoutrels <= relosp->os_shdr->sh_size);
 369  382  
      383 +        relbits = (char *)relosp->os_outdata->d_buf;
      384 +
 370  385          (void) memcpy((relbits + relosp->os_szoutrels),
 371  386              (char *)&rea, sizeof (Rel));
 372  387          relosp->os_szoutrels += sizeof (Rel);
 373  388  
 374  389          /*
 375  390           * Determine if this relocation is against a non-writable, allocatable
 376  391           * section.  If so we may need to provide a text relocation diagnostic.
 377  392           * Note that relocations against the .plt (R_386_JMP_SLOT) actually
 378  393           * result in modifications to the .got.
 379  394           */
↓ open down ↓ 747 lines elided ↑ open up ↑
1127 1142          Sym_desc        *sdp = rsp->rel_sym;
1128 1143  
1129 1144          /*
1130 1145           * Static executables *do not* want any relocations against them.
1131 1146           * Since our engine still creates relocations against a WEAK UNDEFINED
1132 1147           * symbol in a static executable, it's best to disable them here
1133 1148           * instead of through out the relocation code.
1134 1149           */
1135 1150          if (OFL_IS_STATIC_EXEC(ofl))
1136 1151                  return (1);
     1152 +
     1153 +        /*
     1154 +         * If the symbol will be reduced, we can't leave outstanding
     1155 +         * relocations against it, as nothing will ever be able to satisfy them
     1156 +         * (and the symbol won't be in .dynsym
     1157 +         */
     1158 +        if ((sdp != NULL) &&
     1159 +            (sdp->sd_sym->st_shndx == SHN_UNDEF) &&
     1160 +            (rsp->rel_rtype != M_R_NONE) &&
     1161 +            (rsp->rel_rtype != M_R_RELATIVE)) {
     1162 +                if (ld_sym_reducable(ofl, sdp))
     1163 +                        return (1);
     1164 +        }
1137 1165  
1138 1166          /*
1139 1167           * If we are adding a output relocation against a section
1140 1168           * symbol (non-RELATIVE) then mark that section.  These sections
1141 1169           * will be added to the .dynsym symbol table.
1142 1170           */
1143 1171          if (sdp && (rsp->rel_rtype != M_R_RELATIVE) &&
1144 1172              ((flags & FLG_REL_SCNNDX) ||
1145 1173              (ELF_ST_TYPE(sdp->sd_sym->st_info) == STT_SECTION))) {
1146 1174  
↓ open down ↓ 575 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX