--- old/usr/src/cmd/sgs/libld/common/entry.c	2019-05-22 03:21:43.478121733 +0000
+++ new/usr/src/cmd/sgs/libld/common/entry.c	2019-05-22 03:21:43.531573846 +0000
@@ -472,7 +472,7 @@
 		    AL_CNT_SEGMENTS)) == NULL)
 			return (S_ERROR);
 
-#ifdef NDEBUG			/* assert() is enabled */
+#ifndef NDEBUG			/* assert() is enabled */
 		/*
 		 * Enforce the segment name rule: Any segment that can
 		 * be referenced by an entrance descriptor must have
--- old/usr/src/cmd/sgs/libld/common/machrel.amd.c	2019-05-22 03:21:44.035719758 +0000
+++ new/usr/src/cmd/sgs/libld/common/machrel.amd.c	2019-05-22 03:21:44.052673810 +0000
@@ -435,7 +435,20 @@
 	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;
@@ -448,6 +461,8 @@
 	 */
 	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);
@@ -1135,6 +1150,19 @@
 		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.
--- old/usr/src/cmd/sgs/libld/common/machrel.intel.c	2019-05-22 03:21:44.583464873 +0000
+++ new/usr/src/cmd/sgs/libld/common/machrel.intel.c	2019-05-22 03:21:44.612820774 +0000
@@ -355,7 +355,20 @@
 			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;
@@ -367,6 +380,8 @@
 	 */
 	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);
@@ -1136,6 +1151,19 @@
 		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.
--- old/usr/src/cmd/sgs/libld/common/machrel.sparc.c	2019-05-22 03:21:45.117532312 +0000
+++ new/usr/src/cmd/sgs/libld/common/machrel.sparc.c	2019-05-22 03:21:45.133682528 +0000
@@ -145,7 +145,7 @@
 	 * Determine which memory model to mark the binary with.  The options
 	 * are (most restrictive to least):
 	 *
-	 *	EF_SPARCV9_TSO		0x0 	Total Store Order
+	 *	EF_SPARCV9_TSO		0x0	Total Store Order
 	 *	EF_SPARCV9_PSO		0x1	Partial Store Order
 	 *	EF_SPARCV9_RMO		0x2	Relaxed Memory Order
 	 *
@@ -779,7 +779,25 @@
 	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));
@@ -793,6 +811,8 @@
 	 */
 	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);
@@ -927,7 +947,7 @@
 	case R_SPARC_TLS_IE_LDX:
 		/*
 		 * Current instruction:
-		 * 	ld{x}	[r1 + r2], r3
+		 *	ld{x}	[r1 + r2], r3
 		 *
 		 * Need to update this to:
 		 *
@@ -1009,7 +1029,7 @@
 	case R_SPARC_GOTDATA_OP:
 		/*
 		 * Current instruction:
-		 * 	ld{x}	[r1 + r2], r3
+		 *	ld{x}	[r1 + r2], r3
 		 *
 		 * Need to update this to:
 		 *
@@ -1411,6 +1431,20 @@
 		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.
--- old/usr/src/cmd/sgs/packages/common/SUNWonld-README	2019-05-22 03:21:45.684280762 +0000
+++ new/usr/src/cmd/sgs/packages/common/SUNWonld-README	2019-05-22 03:21:45.698278798 +0000
@@ -1667,3 +1667,4 @@
 	producing relocatable objects
 10366	ld(1) should support GNU-style linker sets
 10581	ld(1) should know kernel modules are a thing
+11057	hidden undefined weak symbols should not leave relocations
