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

@@ -777,11 +777,29 @@
          * R_SPARC_TLS_DTPOFF* relocations.
          */
         if (orsp->rel_rtype == M_R_DTPMOD)
                 raddend = 0;
 
-        relbits = (char *)relosp->os_outdata->d_buf;
+        /*
+         * Note that the other case which writes out the relocation, above, is
+         * M_R_REGISTER specific and so does not need this check.
+         */
+        if ((orsp->rel_rtype != M_R_NONE) &&
+            (orsp->rel_rtype != M_R_REGISTER) &&
+            (orsp->rel_rtype != M_R_RELATIVE)) {
+                if (ndx == 0) {
+                        Conv_inv_buf_t  inv_buf;
+                        Is_desc *isp = orsp->rel_isdesc;
+
+                        ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_REL_NOSYMBOL),
+                            conv_reloc_type(ofl->ofl_nehdr->e_machine,
+                            orsp->rel_rtype, 0, &inv_buf),
+                            isp->is_file->ifl_name, EC_WORD(isp->is_scnndx),
+                            isp->is_name, EC_XWORD(roffset));
+                        return (S_ERROR);
+                }
+        }
 
         rea.r_info = ELF_R_INFO(ndx,
             ELF_R_TYPE_INFO(RELAUX_GET_TYPEDATA(orsp), orsp->rel_rtype));
         rea.r_offset = roffset;
         rea.r_addend = raddend;

@@ -791,10 +809,12 @@
         /*
          * Assert we haven't walked off the end of our relocation table.
          */
         assert(relosp->os_szoutrels <= relosp->os_shdr->sh_size);
 
+        relbits = (char *)relosp->os_outdata->d_buf;
+
         (void) memcpy((relbits + relosp->os_szoutrels),
             (char *)&rea, sizeof (Rela));
         relosp->os_szoutrels += (Xword)sizeof (Rela);
 
         /*

@@ -1409,10 +1429,24 @@
          */
         if (OFL_IS_STATIC_EXEC(ofl))
                 return (1);
 
         /*
+         * If the symbol will be reduced, we can't leave outstanding
+         * relocations against it, as nothing will ever be able to satisfy them
+         * (and the symbol won't be in .dynsym
+         */
+        if ((sdp != NULL) &&
+            (sdp->sd_sym->st_shndx == SHN_UNDEF) &&
+            (rsp->rel_rtype != M_R_NONE) &&
+            (rsp->rel_rtype != M_R_REGISTER) &&
+            (rsp->rel_rtype != M_R_RELATIVE)) {
+                if (ld_sym_reducable(ofl, sdp))
+                        return (1);
+        }
+
+        /*
          * Certain relocations do not make sense in a 64bit shared object,
          * if building a shared object do a sanity check on the output
          * relocations being created.
          */
         if (ofl->ofl_flags & FLG_OF_SHAROBJ) {