changeset 10436:34c38a8abd7b

6516644 per-symbol filtering shouldn't be allowed in executables
author Rod Evans <Rod.Evans@Sun.COM>
date Tue, 01 Sep 2009 09:06:39 -0700
parents a8086b52d48a
children 157ade6698b1
files usr/src/cmd/sgs/libld/common/args.c usr/src/cmd/sgs/libld/common/libld.msg usr/src/cmd/sgs/libld/common/map.c usr/src/cmd/sgs/liblddbg/common/sections.c usr/src/cmd/sgs/packages/common/SUNWonld-README
diffstat 5 files changed, 78 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/sgs/libld/common/args.c	Tue Sep 01 16:25:33 2009 +0100
+++ b/usr/src/cmd/sgs/libld/common/args.c	Tue Sep 01 09:06:39 2009 -0700
@@ -335,6 +335,19 @@
 		ofl->ofl_flags |= FLG_OF_FATAL;
 	}
 
+	if (ofl->ofl_filtees && !Gflag) {
+		if (ofl->ofl_flags & FLG_OF_AUX) {
+			eprintf(ofl->ofl_lml, ERR_FATAL,
+			    MSG_INTL(MSG_MARG_ST_ONLYAVL),
+			    MSG_INTL(MSG_MARG_FILTER_AUX));
+		} else {
+			eprintf(ofl->ofl_lml, ERR_FATAL,
+			    MSG_INTL(MSG_MARG_ST_ONLYAVL),
+			    MSG_INTL(MSG_MARG_FILTER));
+		}
+		ofl->ofl_flags |= FLG_OF_FATAL;
+	}
+
 	if (dflag != SET_FALSE) {
 		/*
 		 * Set -Bdynamic on by default, setting is rechecked as input
@@ -453,19 +466,6 @@
 				    MSG_ORIG(MSG_ARG_BTRANS));
 				ofl->ofl_flags |= FLG_OF_FATAL;
 			}
-			if (ofl->ofl_filtees) {
-				if (ofl->ofl_flags & FLG_OF_AUX) {
-					eprintf(ofl->ofl_lml, ERR_FATAL,
-					    MSG_INTL(MSG_MARG_DY_INCOMP),
-					    MSG_INTL(MSG_MARG_FILTER_AUX));
-				} else {
-					eprintf(ofl->ofl_lml, ERR_FATAL,
-					    MSG_INTL(MSG_MARG_DY_INCOMP),
-					    MSG_INTL(MSG_MARG_FILTER));
-				}
-				ofl->ofl_flags |= FLG_OF_FATAL;
-			}
-
 		} else if (!rflag) {
 			/*
 			 * Shared library.
@@ -544,18 +544,6 @@
 			    MSG_INTL(MSG_ARG_ST_INCOMP), MSG_ORIG(MSG_ARG_C));
 			ofl->ofl_flags |= FLG_OF_FATAL;
 		}
-		if (ofl->ofl_filtees) {
-			if (ofl->ofl_flags & FLG_OF_AUX) {
-				eprintf(ofl->ofl_lml, ERR_FATAL,
-				    MSG_INTL(MSG_MARG_ST_INCOMP),
-				    MSG_INTL(MSG_MARG_FILTER_AUX));
-			} else {
-				eprintf(ofl->ofl_lml, ERR_FATAL,
-				    MSG_INTL(MSG_MARG_ST_INCOMP),
-				    MSG_INTL(MSG_MARG_FILTER));
-			}
-			ofl->ofl_flags |= FLG_OF_FATAL;
-		}
 		if (ztflag) {
 			eprintf(ofl->ofl_lml, ERR_FATAL,
 			    MSG_INTL(MSG_ARG_ST_INCOMP),
--- a/usr/src/cmd/sgs/libld/common/libld.msg	Tue Sep 01 16:25:33 2009 +0100
+++ b/usr/src/cmd/sgs/libld/common/libld.msg	Tue Sep 01 09:06:39 2009 -0700
@@ -820,6 +820,7 @@
 			 object (-dn, -r, --relocatable)"
 @ MSG_MARG_ST_INCOMP	"%s is incompatible with building a static \
 			 object (-dn, -r, --relocatable)"
+@ MSG_MARG_ST_ONLYAVL	"%s is only available when building a shared object"
 @ MSG_ARG_INCOMP	"option %s and %s are incompatible"
 @ MSG_MARG_INCOMP	"%s and %s are incompatible"
 @ MSG_ARG_MTONCE	"option %s appears more than once, first setting taken"
@@ -1011,6 +1012,8 @@
 			 when building a dynamic executable"
 @ MSG_MAP_NOEXVLSZ	"%s: %lld: value and size attributes are incompatible \
 			 with extern or parent symbols"
+@ MSG_MAP_FLTR_ONLYAVL	"%s: %lld: symbol filtering is only available when \
+			 building a shared object"
 
 @ MSG_MAP_SEGSAME	"segments `%s' and `%s' have the same assigned \
 			 virtual address"
--- a/usr/src/cmd/sgs/libld/common/map.c	Tue Sep 01 16:25:33 2009 +0100
+++ b/usr/src/cmd/sgs/libld/common/map.c	Tue Sep 01 09:06:39 2009 -0700
@@ -1466,6 +1466,7 @@
 				    MSG_INTL(MSG_MAP_UNKSYMSCO), mapfile,
 				    EC_XWORD(Line_num), _name);
 				errcnt++;
+				break;
 			}
 			continue;
 
@@ -1604,26 +1605,47 @@
 					    (FLG_OF1_NDIRECT | FLG_OF1_NGLBDIR);
 				} else if (strcmp(Start_tok,
 				    MSG_ORIG(MSG_MAP_FILTER)) == 0) {
+					/* BEGIN CSTYLED */
+					if (!(ofl->ofl_flags &
+					    FLG_OF_SHAROBJ)) {
+					    eprintf(ofl->ofl_lml, ERR_FATAL,
+						MSG_INTL(MSG_MAP_FLTR_ONLYAVL),
+						mapfile, EC_XWORD(Line_num));
+					    errcnt++;
+					    break;
+					}
+					/* END CSTYLED */
 					dftflag = filter = FLG_SY_STDFLTR;
 					sym_flags |= FLG_SY_STDFLTR;
 					ofl->ofl_flags |= FLG_OF_SYMINFO;
 					continue;
 				} else if (strcmp(Start_tok,
 				    MSG_ORIG(MSG_MAP_AUXILIARY)) == 0) {
+					/* BEGIN CSTYLED */
+					if (!(ofl->ofl_flags &
+					    FLG_OF_SHAROBJ)) {
+					    eprintf(ofl->ofl_lml, ERR_FATAL,
+						MSG_INTL(MSG_MAP_FLTR_ONLYAVL),
+						mapfile, EC_XWORD(Line_num));
+					    errcnt++;
+					    break;
+					}
+					/* END CSTYLED */
 					dftflag = filter = FLG_SY_AUXFLTR;
 					sym_flags |= FLG_SY_AUXFLTR;
 					ofl->ofl_flags |= FLG_OF_SYMINFO;
 					continue;
 				} else if (strcmp(Start_tok,
 				    MSG_ORIG(MSG_MAP_INTERPOSE)) == 0) {
+					/* BEGIN CSTYLED */
 					if (!(ofl->ofl_flags & FLG_OF_EXEC)) {
-						eprintf(ofl->ofl_lml, ERR_FATAL,
-						    MSG_INTL(MSG_MAP_NOINTPOSE),
-						    mapfile,
-						    EC_XWORD(Line_num));
-						errcnt++;
-						continue;
+					    eprintf(ofl->ofl_lml, ERR_FATAL,
+						MSG_INTL(MSG_MAP_NOINTPOSE),
+						mapfile, EC_XWORD(Line_num));
+					    errcnt++;
+					    break;
 					}
+					/* END CSTYLED */
 					sym_flags |= FLG_SY_INTPOSE;
 					ofl->ofl_flags |= FLG_OF_SYMINFO;
 					ofl->ofl_dtflags_1 |= DF_1_SYMINTPOSE;
--- a/usr/src/cmd/sgs/liblddbg/common/sections.c	Tue Sep 01 16:25:33 2009 +0100
+++ b/usr/src/cmd/sgs/liblddbg/common/sections.c	Tue Sep 01 09:06:39 2009 -0700
@@ -378,13 +378,15 @@
 			const char		*msg;
 
 			/*
-			 * An output section with sorted input sections
-			 * can also have a large number of unsorted sections.
-			 * Skip these without comment.
+			 * An output segment that requires ordering might have
+			 * as little as two sorted input sections.  For example,
+			 * the crt's can provide a SHN_BEGIN and SHN_AFTER, and
+			 * only these two sections must be processed.  Thus, if
+			 * a input section is unordered, move on.  Diagnosing
+			 * any unsorted section can produce way too much noise.
 			 */
-			if ((isp1->is_flags & FLG_IS_ORDERED) == 0) {
+			if ((isp1->is_flags & FLG_IS_ORDERED) == 0)
 				continue;
-			}
 
 			if (isp1->is_shdr->sh_flags & SHF_ORDERED) {
 				link = isp1->is_shdr->sh_info;
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README	Tue Sep 01 16:25:33 2009 +0100
+++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README	Tue Sep 01 09:06:39 2009 -0700
@@ -209,6 +209,7 @@
 4287364 ld.so.1 runtime configuration cleanup
 4289573 disable linking of ia64 binaries for Solaris8
 4293966 crle(1)'s default directories should be supplied
+--------------------------------------------------------------------------------
 
 ------------------------------------
 Solaris 8 600 (1st Q-update - s28u1)
@@ -407,7 +408,6 @@
 	Solaris/SunOS 5.8_x86		patch 109148-12
 --------------------------------------------------------------------------------
 
-
 ---------
 Solaris 9
 ---------
@@ -1279,9 +1279,9 @@
 	Solaris/SunOS 5.10_x86		patch TXXXXXX-XX
 --------------------------------------------------------------------------------
 
---------------
-Solaris Nevada
---------------
+--------------------------------------------
+Solaris Nevada (OpenSolaris 2008.05, snv_86)
+--------------------------------------------
 Bugid   Risk Synopsis
 ================================================================================
 6409350 BrandZ project integration into Solaris (link-editor components only)
@@ -1396,6 +1396,13 @@
 6357282 ldd should recognize PARENT and EXTERN symbols (D)
 	PSARC/2008/148 new ldd(1) -p option
 6672394 ldd(1) unused dependency processing is tricked by relocations errors
+--------------------------------------------------------------------------------
+
+---------------------------------------------
+Solaris Nevada (OpenSolaris 2008.11, snv_101)
+---------------------------------------------
+Bugid   Risk Synopsis
+================================================================================
 6671255 link-editor should support cross linking (D)
 	PSARC/2008/179 cross link-editor
 6674666 elfedit dyn:posflag1 needs option to locate element via NEEDED item
@@ -1440,6 +1447,14 @@
 	PSARC/2008/603 ELF objects to adopt GNU-style Versym indexes
 6752728 link-editor can enter UNDEF symbols in symbol sort sections
 6756472 AOUT search path pruning (D)
+--------------------------------------------------------------------------------
+
+---------------------------------------------
+Solaris Nevada (OpenSolaris 2009.06, snv_111)
+---------------------------------------------
+Bugid   Risk Synopsis
+================================================================================
+
 6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities (D)
 	(link-editor components only)
 	PSARC/2008/622 32-bit Address Restriction Software Capabilities Flag
@@ -1473,6 +1488,13 @@
 	pfinstall does it again.
 6807050 GNU linkonce sections can create duplicate and incompatible
 	eh_frame FDE entries
+--------------------------------------------------------------------------------
+
+--------------
+Solaris Nevada
+--------------
+Bugid   Risk Synopsis
+================================================================================
 6813909 generalize eh_frame support to non-amd64 platforms
 6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
 6802452 libelf shouldn't use MS_SYNC
@@ -1507,3 +1529,4 @@
 6856173 streams core dumps when compiled in 64bit with a very large static
 	array size
 6834197 ld pukes when given an empty plate
+6516644 per-symbol filtering shouldn't be allowed in executables