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

@@ -353,11 +353,24 @@
                 addr += (uintptr_t)RELAUX_GET_OSDESC(orsp)->os_outdata->d_buf;
                 if (ld_reloc_targval_set(ofl, orsp, addr, addend) == 0)
                         return (S_ERROR);
         }
 
-        relbits = (char *)relosp->os_outdata->d_buf;
+        if ((orsp->rel_rtype != M_R_NONE) &&
+            (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, orsp->rel_rtype);
         rea.r_offset = roffset;
         DBG_CALL(Dbg_reloc_out(ofl, ELF_DBG_LD, SHT_REL, &rea, relosp->os_name,
             ld_reloc_sym_name(orsp)));

@@ -365,10 +378,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 (Rel));
         relosp->os_szoutrels += sizeof (Rel);
 
         /*

@@ -1134,10 +1149,23 @@
          */
         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_RELATIVE)) {
+                if (ld_sym_reducable(ofl, sdp))
+                        return (1);
+        }
+
+        /*
          * If we are adding a output relocation against a section
          * symbol (non-RELATIVE) then mark that section.  These sections
          * will be added to the .dynsym symbol table.
          */
         if (sdp && (rsp->rel_rtype != M_R_RELATIVE) &&