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

@@ -433,11 +433,24 @@
          * is propagated in the corresponding R_AMD64_DTPOFF64 relocation.
          */
         if (orsp->rel_rtype == R_AMD64_DTPMOD64)
                 raddend = 0;
 
-        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;
         rea.r_addend = raddend;
         DBG_CALL(Dbg_reloc_out(ofl, ELF_DBG_LD, SHT_RELA, &rea, relosp->os_name,

@@ -446,10 +459,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);
 
         /*

@@ -1133,10 +1148,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) &&