--- old/usr/src/cmd/sgs/include/libld.h	2019-02-11 00:23:18.513557689 +0000
+++ new/usr/src/cmd/sgs/include/libld.h	2019-02-11 00:23:18.532713518 +0000
@@ -105,7 +105,7 @@
  */
 struct rel_cache {
 	APlist		*rc_list;	/* list of Rel_cachebuf */
-	Word		rc_cnt;		/* 	and count */
+	Word		rc_cnt;		/*	and count */
 };
 
 /*
@@ -147,7 +147,7 @@
 	RLXREL_REJ_NONE = 0,	/* Replacement symbol was found */
 	RLXREL_REJ_TARGET,	/* Target sec disallows relaxed relocations */
 	RLXREL_REJ_SECTION,	/* Either there is no replacement section, */
-				/* 	or its attributes are incompatible */
+				/*	or its attributes are incompatible */
 	RLXREL_REJ_SYMBOL,	/* Replacement symbol not found */
 } Rlxrel_rej;
 
@@ -261,15 +261,15 @@
 	APlist		*ofl_ents;	/* list of entrance descriptors */
 	avl_tree_t	ofl_ents_avl;	/* O(log N) access to named ent. desc */
 	APlist		*ofl_objs;	/* relocatable object file list */
-	Word		ofl_objscnt;	/* 	and count */
+	Word		ofl_objscnt;	/*	and count */
 	APlist		*ofl_ars;	/* archive library list */
-	Word		ofl_arscnt;	/* 	and count */
+	Word		ofl_arscnt;	/*	and count */
 	int		ofl_ars_gsandx; /* archive group argv index. 0 means */
 					/*	no current group, < 0 means */
 					/*	error reported. >0 is cur ndx */
 	Word		ofl_ars_gsndx;	/* current -zrescan-start ofl_ars ndx */
 	APlist		*ofl_sos;	/* shared object list */
-	Word		ofl_soscnt;	/* 	and count */
+	Word		ofl_soscnt;	/*	and count */
 	APlist		*ofl_soneed;	/* list of implicitly required .so's */
 	APlist		*ofl_socntl;	/* list of .so control definitions */
 	Rel_cache	ofl_outrels;	/* list of output relocations */
@@ -283,7 +283,7 @@
 	APlist		*ofl_ismove;	/* list of .SUNW_move sections */
 	APlist		*ofl_ismoverel;	/* list of relocation input section */
 					/* targeting to expanded area */
-	APlist		*ofl_parsyms; 	/* list of partially initialized */
+	APlist		*ofl_parsyms;	/* list of partially initialized */
 					/*	symbols (ie. move symbols) */
 	APlist		*ofl_extrarels;	/* relocation sections which have */
 					/*    a NULL sh_info */
@@ -879,7 +879,7 @@
 #define	FLG_IF_DISPPEND 0x00000800	/* displacement relocation done */
 					/*	in the ld time. */
 #define	FLG_IF_DISPDONE 0x00001000	/* displacement relocation done */
-					/* 	at the run time */
+					/*	at the run time */
 #define	FLG_IF_MAPFILE	0x00002000	/* file is a mapfile */
 #define	FLG_IF_HSTRTAB	0x00004000	/* file has a string section */
 #define	FLG_IF_FILEREF	0x00008000	/* file contains a section which */
@@ -916,11 +916,11 @@
 	Elf_Data	*is_indata;	/* input sections raw data */
 	Is_desc		*is_symshndx;	/* related SHT_SYM_SHNDX section */
 	Is_desc		*is_comdatkeep;	/* If COMDAT section is discarded, */
-					/* 	this is section that was kept */
+					/*	this is section that was kept */
 	Word		is_scnndx;	/* original section index in file */
 	Word		is_ordndx;	/* index for section.  Used to decide */
 					/*	where to insert section when */
-					/* 	reordering sections */
+					/*	reordering sections */
 	Word		is_keyident;	/* key for SHF_{ORDERED|LINK_ORDER} */
 					/*	processing and ident used for */
 					/*	 placing/ordering sections */
@@ -990,7 +990,7 @@
 					/*	by section symbol index */
 	Word		os_ordndx;	/* index for section.  Used to decide */
 					/*	where to insert section when */
-					/* 	reordering sections */
+					/*	reordering sections */
 	Xword		os_szoutrels;	/* size of output relocation section */
 	uint_t		os_namehash;	/* hash on section name */
 	uchar_t		os_flags;	/* various flags */
@@ -1067,7 +1067,7 @@
 #define	FLG_SG_P_FLAGS		0x0020	/* p_flags segment attribute set */
 #define	FLG_SG_P_TYPE		0x0040	/* p_type segment attribute set */
 #define	FLG_SG_IS_ORDER		0x0080	/* input section ordering is required */
-					/* 	for this segment. */
+					/*	for this segment. */
 #define	FLG_SG_NOHDR		0x0100	/* don't map ELF or phdrs into */
 					/*	this segment */
 #define	FLG_SG_EMPTY		0x0200	/* an empty segment specification */
@@ -1141,7 +1141,7 @@
 	Move		*md_move;	/* original Move entry */
 	Xword		md_start;	/* start position */
 	Xword		md_len;		/* length of initialization */
-	Word 		md_oidx;	/* output Move entry index */
+	Word		md_oidx;	/* output Move entry index */
 } Mv_desc;
 
 /*
@@ -1172,7 +1172,7 @@
  * important for performance.
  */
 struct sym_aux {
-	APlist 		*sa_dfiles;	/* files where symbol is defined */
+	APlist		*sa_dfiles;	/* files where symbol is defined */
 	Sym		sa_sym;		/* copy of symtab entry */
 	const char	*sa_vfile;	/* first unavailable definition */
 	const char	*sa_rfile;	/* file with first symbol referenced */
@@ -1184,6 +1184,7 @@
 	Half		sa_symspec;	/* special symbol ids */
 	Half		sa_overndx;	/* output file versioning index */
 	Half		sa_dverndx;	/* dependency versioning index */
+	Os_desc		*sa_boundsec;	/* output section of SECBOUND_ syms */
 };
 
 /*
@@ -1200,13 +1201,15 @@
  * These are the ids for processing of `Special symbols'.  They are used
  * to set the sym->sd_aux->sa_symspec field.
  */
-#define	SDAUX_ID_ETEXT	1		/* etext && _etext symbol */
-#define	SDAUX_ID_EDATA	2		/* edata && _edata symbol */
-#define	SDAUX_ID_END	3		/* end, _end, && _END_ symbol */
-#define	SDAUX_ID_DYN	4		/* DYNAMIC && _DYNAMIC symbol */
-#define	SDAUX_ID_PLT	5		/* _PROCEDURE_LINKAGE_TABLE_ symbol */
-#define	SDAUX_ID_GOT	6		/* _GLOBAL_OFFSET_TABLE_ symbol */
-#define	SDAUX_ID_START	7		/* START_ && _START_ symbol */
+#define	SDAUX_ID_ETEXT		1	/* etext && _etext symbol */
+#define	SDAUX_ID_EDATA		2	/* edata && _edata symbol */
+#define	SDAUX_ID_END		3	/* end, _end, && _END_ symbol */
+#define	SDAUX_ID_DYN		4	/* DYNAMIC && _DYNAMIC symbol */
+#define	SDAUX_ID_PLT		5	/* _PROCEDURE_LINKAGE_TABLE_ symbol */
+#define	SDAUX_ID_GOT		6	/* _GLOBAL_OFFSET_TABLE_ symbol */
+#define	SDAUX_ID_START		7	/* START_ && _START_ symbol */
+#define	SDAUX_ID_SECBOUND_START	8	/* __start_<section> symbols */
+#define	SDAUX_ID_SECBOUND_STOP	9	/* __stop_<section> symbols */
 
 /*
  * Flags for sym_desc.sd_flags
@@ -1226,7 +1229,7 @@
 #define	FLG_SY_NOTAVAIL	0x00000020	/* symbol is not available to the */
 					/*	application either because it */
 					/*	originates from an implicitly */
-					/* 	referenced shared object, or */
+					/*	referenced shared object, or */
 					/*	because it is not part of a */
 					/*	specified version. */
 #define	FLG_SY_REDUCED	0x00000040	/* a global is reduced to local */
@@ -1236,7 +1239,7 @@
 #define	FLG_SY_MAPREF	0x00000200	/* symbol reference generated by user */
 					/*	from mapfile */
 #define	FLG_SY_REFRSD	0x00000400	/* symbols sd_ref has been raised */
-					/* 	due to a copy-relocs */
+					/*	due to a copy-relocs */
 					/*	weak-strong pairing */
 #define	FLG_SY_INTPOSE	0x00000800	/* symbol defines an interposer */
 #define	FLG_SY_INVALID	0x00001000	/* unwanted/erroneous symbol */
--- old/usr/src/cmd/sgs/libld/common/libld.msg	2019-02-11 00:23:19.090576593 +0000
+++ new/usr/src/cmd/sgs/libld/common/libld.msg	2019-02-11 00:23:19.108559277 +0000
@@ -36,7 +36,7 @@
 
 #
 # TRANSLATION_NOTE -- Beginning of USAGE message
-# 	The following messages are the usage messages for the ld command.
+#	The following messages are the usage messages for the ld command.
 #	Tab characters (\t) are used to align the messages.
 #
 #	Each usage message starts with \t, and if the message has more than one
@@ -54,9 +54,9 @@
 #	In C locale, the first 3 messages would look like the following:
 #
 #	usage: ld [-6:abc:.....] file(s)
-#        	[-a]            create an absolute file
-#        	[-b]            do not do special PIC relocations in a.out
-#        	[-c file]       record configuration 'file'
+#		[-a]		create an absolute file
+#		[-b]		do not do special PIC relocations in a.out
+#		[-c file]	record configuration 'file'
 #
 @ MSG_ARG_USAGE		"usage: ld [-%s] file(s)\n"
 @ MSG_ARG_DETAIL_3	"\t[-32]\t\tenforce a 32-bit link-edit\n"
@@ -353,13 +353,13 @@
 
 #
 # TRANSLATION_NOTE
-# 	The following 7 messages are the message to print the
+#	The following 7 messages are the message to print the
 #	following example messages.
 #
 #Text relocation remains		      referenced
 #    against symbol		    offset	in file
-#str                                 0x14      	main.o
-#printf                              0x1c      	main.o
+#str				     0x14	main.o
+#printf				     0x1c	main.o
 #
 #	The first two lines are the header, and the next msgid
 #	is the format string for the header.
@@ -476,7 +476,7 @@
 
 @ MSG_SCN_DWFOVRFLW	"%s: section %s: encoded DWARF data exceeds \
 			 section size"
-@ MSG_SCN_DWFBADENC	"%s: section %s: invalid DWARF encoding: %#x"                         
+@ MSG_SCN_DWFBADENC	"%s: section %s: invalid DWARF encoding: %#x"
 
 # Symbol processing errors
 
@@ -543,11 +543,11 @@
 
 #
 # TRANSLATION_NOTE
-# 	The following 7 messages are the message to print the
+#	The following 7 messages are the message to print the
 #	following example messages.
 #
 #Undefined			first referenced
-# symbol  			    in file
+# symbol			    in file
 #inquire                            halt_hold.o
 #
 @ MSG_SYM_FMT_UNDEF	"%s\t\t\t%s\
@@ -879,6 +879,9 @@
 @ MSG_SYM_L_START	"START_"
 @ MSG_SYM_L_START_U	"_START_"
 
+@ MSG_SYM_SECBOUND_START "__start_"
+@ MSG_SYM_SECBOUND_STOP "__stop_"
+
 # Support functions
 
 @ MSG_SUP_VERSION	"ld_version"
@@ -898,10 +901,10 @@
 @ MSG_SUP_INSEC		"ld_input_section"
 @ MSG_SUP_SEC		"ld_section"
 
-# 
+#
 # Message previously in 'ld'
 #
-# 
+#
 @ _START_
 
 # System error messages
@@ -979,7 +982,7 @@
 # The next message is a format string for a title. The title is composed of
 # two lines. In C locale, it would look like:
 #
-# 	output		input		new
+#	output		input		new
 #	section		section		displacement	size
 #
 # The \t characters are used for alignment.  (output section), (input section),
@@ -1307,7 +1310,7 @@
 @ MSG_STR_PATH		"%s/%s"
 @ MSG_STR_STRNL		"%s\n"
 @ MSG_STR_NL		"\n"
-@ MSG_STR_CAPGROUPID 	"CAP_GROUP_%d"
+@ MSG_STR_CAPGROUPID	"CAP_GROUP_%d"
 
 @ MSG_STR_LD_DYNAMIC	"dynamic"
 @ MSG_STR_SYMBOLIC	"symbolic"
--- old/usr/src/cmd/sgs/libld/common/syms.c	2019-02-11 00:23:19.633205553 +0000
+++ new/usr/src/cmd/sgs/libld/common/syms.c	2019-02-11 00:23:19.651958600 +0000
@@ -36,6 +36,7 @@
 #include	<stdio.h>
 #include	<string.h>
 #include	<debug.h>
+#include	<alloca.h>
 #include	"msg.h"
 #include	"_libld.h"
 
@@ -636,7 +637,7 @@
     sd_flag_t sdflags_u, sd_flag_t sdflags, Ofl_desc *ofl)
 {
 	Sym_desc	*sdp;
-	Sym_desc 	*usdp;
+	Sym_desc	*usdp;
 	Sym		*sym;
 	Word		hash;
 	avl_index_t	where;
@@ -692,9 +693,10 @@
 				usdp->sd_flags |= FLG_SY_MAPUSED;
 
 			DBG_CALL(Dbg_syms_updated(ofl, usdp, uname));
-		} else
+		} else {
 			ld_eprintf(ofl, ERR_WARNING, MSG_INTL(MSG_SYM_RESERVE),
 			    uname, usdp->sd_file->ifl_name);
+		}
 	} else {
 		/*
 		 * If the symbol does not exist create it.
@@ -795,7 +797,7 @@
  *
  *  -	the symbol has been defined by an implicitly supplied library, ie. one
  *	which was encounted because it was NEEDED by another library, rather
- * 	than from a command line supplied library which would become the only
+ *	than from a command line supplied library which would become the only
  *	dependency of the output file being produced.
  *
  *  -	the symbol has been defined by a version of a shared object that is
@@ -885,6 +887,59 @@
 }
 
 /*
+ * If an undef symbol exists naming a bound for the output section,
+ * turn it into a defined symbol with the correct value.
+ *
+ * We set an arbitrary 1KB limit on the resulting symbol names.
+ */
+static void
+sym_add_bounds(Ofl_desc *ofl, Os_desc *osp, Word bound)
+{
+	Sym_desc *bsdp;
+	char symn[1024];
+	size_t nsz;
+
+	switch (bound) {
+	case SDAUX_ID_SECBOUND_START:
+		nsz = snprintf(symn, sizeof (symn), "%s%s",
+		    MSG_ORIG(MSG_SYM_SECBOUND_START), osp->os_name + 1);
+		if (nsz > sizeof (symn))
+			return;
+		break;
+	case SDAUX_ID_SECBOUND_STOP:
+		nsz = snprintf(symn, sizeof (symn), "%s%s",
+		    MSG_ORIG(MSG_SYM_SECBOUND_STOP), osp->os_name + 1);
+		if (nsz > sizeof (symn))
+			return;
+		break;
+	default:
+		assert(0);
+	}
+
+	if ((bsdp = ld_sym_find(symn, SYM_NOHASH, NULL, ofl)) != NULL) {
+		if ((bsdp->sd_shndx != SHN_UNDEF) &&
+		    (bsdp->sd_ref == REF_REL_NEED)) {
+			ld_eprintf(ofl, ERR_WARNING, MSG_INTL(MSG_SYM_RESERVE),
+			    symn, bsdp->sd_file->ifl_name);
+			return;
+		}
+
+		DBG_CALL(Dbg_syms_updated(ofl, bsdp, symn));
+
+		bsdp->sd_aux->sa_symspec = bound;
+		bsdp->sd_aux->sa_boundsec = osp;
+		bsdp->sd_flags |= FLG_SY_SPECSEC;
+		bsdp->sd_ref = REF_REL_NEED;
+		bsdp->sd_sym->st_info = ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE);
+		bsdp->sd_sym->st_other = STV_PROTECTED;
+		bsdp->sd_isc = NULL;
+		bsdp->sd_sym->st_size = 0;
+		bsdp->sd_sym->st_value = 0;
+		bsdp->sd_shndx = bsdp->sd_sym->st_shndx = SHN_ABS;
+	}
+}
+
+/*
  * At this point all symbol input processing has been completed, therefore
  * complete the symbol table entries by generating any necessary internal
  * symbols.
@@ -893,12 +948,32 @@
 ld_sym_spec(Ofl_desc *ofl)
 {
 	Sym_desc	*sdp;
+	Sg_desc		*sgp;
+	Aliste		idx1;
 
 	if (ofl->ofl_flags & FLG_OF_RELOBJ)
 		return (1);
 
 	DBG_CALL(Dbg_syms_spec_title(ofl->ofl_lml));
 
+	/*
+	 * For each section in the output file, look for symbols named for the
+	 * __start/__stop patterns.  If references exist, flesh the symbols to
+	 * be defined.
+	 *
+	 * the symbols are given values at the same time as the other special
+	 * symbols.
+	 */
+	for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) {
+		Os_desc *osp;
+		Aliste idx2;
+
+		for (APLIST_TRAVERSE(sgp->sg_osdescs, idx2, osp)) {
+			sym_add_bounds(ofl, osp, SDAUX_ID_SECBOUND_START);
+			sym_add_bounds(ofl, osp, SDAUX_ID_SECBOUND_STOP);
+		}
+	}
+
 	if (sym_add_spec(MSG_ORIG(MSG_SYM_ETEXT), MSG_ORIG(MSG_SYM_ETEXT_U),
 	    SDAUX_ID_ETEXT, 0, (FLG_SY_DEFAULT | FLG_SY_EXPDEF),
 	    ofl) == S_ERROR)
@@ -1133,7 +1208,7 @@
  * or modified), validate and count the relevant entries:
  *
  *  -	check and print any undefined symbols remaining.  Note that if a symbol
- *	has been defined by virtue of the inclusion of 	an implicit shared
+ *	has been defined by virtue of the inclusion of	an implicit shared
  *	library, it is still classed as undefined.
  *
  *  -	count the number of global needed symbols together with the size of
@@ -1141,7 +1216,7 @@
  *	symbols may be reduced to locals).
  *
  *  -	establish the size and alignment requirements for the global .bss
- *	section (the alignment of this section is based on the 	first symbol
+ *	section (the alignment of this section is based on the first symbol
  *	that it will contain).
  */
 uintptr_t
@@ -1890,7 +1965,7 @@
  * input sections from this input file have been assigned an input section
  * descriptor which is saved in the `ifl_isdesc' array.
  *
- *  -	local symbols are saved (as is) if the input file is a 	relocatable
+ *  -	local symbols are saved (as is) if the input file is a	relocatable
  *	object
  *
  *  -	global symbols are added to the linkers internal symbol table if they
--- old/usr/src/cmd/sgs/libld/common/update.c	2019-02-11 00:23:20.264343814 +0000
+++ new/usr/src/cmd/sgs/libld/common/update.c	2019-02-11 00:23:20.280516954 +0000
@@ -184,7 +184,7 @@
 #endif
 	Addr		bssaddr, etext = 0, edata = 0, end = 0, start = 0;
 	Addr		tlsbssaddr = 0;
-	Addr 		parexpnbase, parexpnaddr;
+	Addr		parexpnbase, parexpnaddr;
 	int		start_set = 0;
 	Sym		_sym = {0}, *sym, *symtab = NULL;
 	Sym		*dynsym = NULL, *ldynsym = NULL;
@@ -1333,7 +1333,7 @@
 				 *	keyword in a mapfile.
 				 *
 				 *  -	Symbol reference has been bound to a
-				 * 	dependency which was specified as
+				 *	dependency which was specified as
 				 *	requiring direct bindings with -zdirect.
 				 *
 				 *  -	All symbol references are required to
@@ -1768,6 +1768,19 @@
 				    ofl_osgot->os_scn);
 				sdp->sd_flags &= ~FLG_SY_SPECSEC;
 				break;
+			case SDAUX_ID_SECBOUND_START:
+				sym->st_value = sap->sa_boundsec->
+				    os_shdr->sh_addr;
+				sectndx = elf_ndxscn(sap->sa_boundsec->os_scn);
+				sdp->sd_flags &= ~FLG_SY_SPECSEC;
+				break;
+			case SDAUX_ID_SECBOUND_STOP:
+				sym->st_value = sap->sa_boundsec->
+				    os_shdr->sh_addr +
+				    sap->sa_boundsec->os_shdr->sh_size;
+				sectndx = elf_ndxscn(sap->sa_boundsec->os_scn);
+				sdp->sd_flags &= ~FLG_SY_SPECSEC;
+				break;
 			default:
 				/* NOTHING */
 				;
@@ -3157,7 +3170,7 @@
 					    imvp->m_info);
 				}
 			} else {
-				Boolean 	isredloc = FALSE;
+				Boolean		isredloc = FALSE;
 
 				if ((ELF_ST_BIND(sym->st_info) == STB_LOCAL) &&
 				    (ofl->ofl_flags & FLG_OF_REDLSYM))
@@ -3652,7 +3665,7 @@
 	DBG_CALL(Dbg_seg_title(ofl->ofl_lml));
 	for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) {
 		Phdr		*phdr = &(sgp->sg_phdr);
-		Xword 		p_align;
+		Xword		p_align;
 		Aliste		idx2;
 		Sym_desc	*sdp;
 
@@ -3872,8 +3885,8 @@
 			 * Check overlaps
 			 */
 			for (i = 0; i < phdrndx - 1; i++) {
-				Addr 	p_s = (ofl->ofl_phdr[i]).p_vaddr;
-				Addr 	p_e;
+				Addr	p_s = (ofl->ofl_phdr[i]).p_vaddr;
+				Addr	p_e;
 
 				if ((ofl->ofl_phdr[i]).p_type != PT_LOAD)
 					continue;
--- old/usr/src/cmd/sgs/packages/common/SUNWonld-README	2019-02-11 00:23:20.918082071 +0000
+++ new/usr/src/cmd/sgs/packages/common/SUNWonld-README	2019-02-11 00:23:20.934418486 +0000
@@ -1662,3 +1662,4 @@
 7594	ld -zaslr should accept Solaris-compatible values
 8616	ld has trouble parsing -z options specified with -Wl
 10267	ld and GCC disagree about i386 local dynamic TLS
+10366	ld(1) should support GNU-style linker sets
--- /dev/null	2019-02-11 00:23:21.000000000 +0000
+++ new/usr/src/pkg/manifests/system-test-elftest.mf	2019-02-11 00:23:21.397272289 +0000
@@ -0,0 +1,57 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2018, Richard Lowe.
+#
+
+set name=pkg.fmri value=pkg:/system/test/elftest@$(PKGVERS)
+set name=pkg.description value="ELF Unit Tests"
+set name=pkg.summary value="ELF Test Suite"
+set name=info.classification \
+    value=org.opensolaris.category.2008:Development/System
+set name=variant.arch value=$(ARCH)
+dir path=opt/elf-tests
+dir path=opt/elf-tests/bin
+dir path=opt/elf-tests/runfiles
+dir path=opt/elf-tests/tests
+dir path=opt/elf-tests/tests/assert-deflib
+dir path=opt/elf-tests/tests/linker-sets
+dir path=opt/elf-tests/tests/tls
+dir path=opt/elf-tests/tests/tls/x64
+dir path=opt/elf-tests/tests/tls/x64/ie
+dir path=opt/elf-tests/tests/tls/x86
+dir path=opt/elf-tests/tests/tls/x86/ld
+file path=opt/elf-tests/bin/elftest mode=0555
+file path=opt/elf-tests/runfiles/default.run mode=0444
+file path=opt/elf-tests/tests/assert-deflib/link.c mode=0444
+file path=opt/elf-tests/tests/assert-deflib/test-deflib mode=0555
+file path=opt/elf-tests/tests/linker-sets/in-use-check mode=0555
+file path=opt/elf-tests/tests/linker-sets/simple mode=0555
+file path=opt/elf-tests/tests/linker-sets/simple-src.c mode=0444
+file path=opt/elf-tests/tests/linker-sets/simple.out mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/Makefile.test mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/style1-func-with-r12.s mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/style1-func-with-r13.s mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/style1-func.s mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/style1-main.s mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/style2-with-badness.s mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/style2-with-r12.s mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/style2-with-r13.s mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/style2.s mode=0444
+file path=opt/elf-tests/tests/tls/x64/ie/x64-ie-test mode=0555
+file path=opt/elf-tests/tests/tls/x86/ld/Makefile.test mode=0444
+file path=opt/elf-tests/tests/tls/x86/ld/half-ldm.s mode=0444
+file path=opt/elf-tests/tests/tls/x86/ld/x86-ld-test mode=0555
+license lic_CDDL license=lic_CDDL
+depend fmri=developer/linker type=require
+depend fmri=developer/object-file type=require
+depend fmri=system/test/testrunner type=require
--- old/usr/src/test/Makefile	2019-02-11 00:23:21.580432679 +0000
+++ new/usr/src/test/Makefile	2019-02-11 00:23:21.594155412 +0000
@@ -16,7 +16,14 @@
 
 .PARALLEL: $(SUBDIRS)
 
-SUBDIRS = libc-tests crypto-tests os-tests test-runner util-tests zfs-tests \
-	smbclient-tests
+SUBDIRS = \
+	crypto-tests \
+	elf-tests \
+	libc-tests \
+	os-tests \
+	smbclient-tests \
+	test-runner \
+	util-tests \
+	zfs-tests
 
 include Makefile.com
--- /dev/null	2019-02-11 00:23:22.000000000 +0000
+++ new/usr/src/test/elf-tests/Makefile	2019-02-11 00:23:21.983803143 +0000
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+#
+
+.PARALLEL: $(SUBDIRS)
+
+SUBDIRS = cmd doc runfiles tests
+
+include $(SRC)/test/Makefile.com
--- /dev/null	2019-02-11 00:23:22.000000000 +0000
+++ new/usr/src/test/elf-tests/cmd/Makefile	2019-02-11 00:23:22.214152952 +0000
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+#
+
+.PARALLEL: $(SUBDIRS)
+
+SUBDIRS = scripts
+
+include $(SRC)/test/Makefile.com
--- /dev/null	2019-02-11 00:23:22.000000000 +0000
+++ new/usr/src/test/elf-tests/cmd/scripts/Makefile	2019-02-11 00:23:22.427183035 +0000
@@ -0,0 +1,38 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+include $(SRC)/test/Makefile.com
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+ROOTBIN = $(ROOTOPTPKG)/bin
+
+PROGS = elftest
+
+CMDS = $(PROGS:%=$(ROOTBIN)/%)
+$(CMDS) := FILEMODE = 0555
+
+all lint clean clobber:
+
+install: $(CMDS)
+
+$(CMDS): $(ROOTBIN)
+
+$(ROOTBIN):
+	$(INS.dir)
+
+$(ROOTBIN)/%: %.ksh
+	$(INS.rename)
--- /dev/null	2019-02-11 00:23:22.000000000 +0000
+++ new/usr/src/test/elf-tests/cmd/scripts/elftest.ksh	2019-02-11 00:23:22.630160238 +0000
@@ -0,0 +1,49 @@
+#!/usr/bin/ksh
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+#
+
+export ELF_TESTS="/opt/elf-tests"
+runner="/opt/test-runner/bin/run"
+
+function fail
+{
+	echo $1
+	exit ${2:-1}
+}
+
+function find_runfile
+{
+	typeset distro=default
+
+	[[ -n $distro ]] && echo $ELF_TESTS/runfiles/$distro.run
+}
+
+while getopts c: c; do
+	case $c in
+	'c')
+		runfile=$OPTARG
+		[[ -f $runfile ]] || fail "Cannot read file: $runfile"
+		;;
+	esac
+done
+shift $((OPTIND - 1))
+
+[[ -z $runfile ]] && runfile=$(find_runfile)
+[[ -z $runfile ]] && fail "Couldn't determine distro"
+
+$runner -c $runfile
+
+exit $?
--- /dev/null	2019-02-11 00:23:22.000000000 +0000
+++ new/usr/src/test/elf-tests/doc/README	2019-02-11 00:23:22.830655138 +0000
@@ -0,0 +1,59 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+#
+
+ELF Software Generation Utilities Unit Test Suite README
+
+1. Building and installing the ELF/SGS Unit Test Suite
+2. Running the ELF/SGS Unit Test Suite
+3. Test results
+
+--------------------------------------------------------------------------------
+
+1. Building and installing the ELF/SGS Unit Test Suite
+
+The ELF/SGS Unit Test Suite runs under the testrunner framework (which can be
+installed as pkg:/system/test/testrunner). To build both the ELF/SGS Unit Test Suite
+and the testrunner without running a full nightly:
+
+	build_machine$ bldenv [-d] <your_env_file>
+	build_machine$ cd $SRC/test
+	build_machine$ dmake install
+	build_machine$ cd $SRC/pkg
+	build_machine$ dmake install
+
+Then set the publisher on the test machine to point to your repository and
+install the ELF/SGS Unit Test Suite.
+
+	test_machine# pkg install pkg:/system/test/elftest
+
+Note, the framework will be installed automatically, as the ELF/SGS Unit Test Suite
+depends on it.
+
+2. Running the ELF/SGS Unit Test Suite
+
+The pre-requisites for running the ELF/SGS Unit Test Suite are:
+    None
+
+Once the pre-requisites are satisfied, simply run the elftest script:
+
+	test_machine$ /opt/elf-tests/bin/elftest
+
+3. Test results
+
+While the ELF/SGS Unit Test Suite is running, one informational line is printed at
+the end of each test, and a results summary is printed at the end of the run.
+The results summary includes the location of the complete logs, which is of the
+form /var/tmp/test_results/<ISO 8601 date>.
--- /dev/null	2019-02-11 00:23:23.000000000 +0000
+++ new/usr/src/test/elf-tests/runfiles/Makefile	2019-02-11 00:23:23.051653462 +0000
@@ -0,0 +1,40 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+#
+
+include $(SRC)/Makefile.master
+
+SRCS = default.run
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+RUNFILES = $(ROOTOPTPKG)/runfiles
+
+CMDS = $(SRCS:%=$(RUNFILES)/%)
+$(CMDS) := FILEMODE = 0444
+
+all: $(SRCS)
+
+install: $(CMDS)
+
+clean lint clobber:
+
+$(CMDS): $(RUNFILES) $(SRCS)
+
+$(RUNFILES):
+	$(INS.dir)
+
+$(RUNFILES)/%: %
+	$(INS.file)
--- /dev/null	2019-02-11 00:23:23.000000000 +0000
+++ new/usr/src/test/elf-tests/runfiles/default.run	2019-02-11 00:23:23.287699784 +0000
@@ -0,0 +1,36 @@
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2018, Richard Lowe.
+
+[DEFAULT]
+pre =
+verbose = False
+quiet = False
+timeout = 60
+post =
+outputdir = /var/tmp/test_results
+
+[/opt/elf-tests/tests/linker-sets]
+tests = ['simple', 'in-use-check']
+
+[/opt/elf-tests/tests/assert-deflib]
+tests = ['test-deflib']
+
+
+[/opt/elf-tests/tests/tls/x64/ie]
+arch = i86pc
+tests = ['x64-ie-test']
+
+[/opt/elf-tests/tests/tls/x86/ld]
+arch = i86pc
+tests = ['x86-ld-test']
--- /dev/null	2019-02-11 00:23:23.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/Makefile	2019-02-11 00:23:23.526781193 +0000
@@ -0,0 +1,22 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
+#
+
+SUBDIRS =		\
+	assert-deflib	\
+	linker-sets	\
+	tls
+
+include $(SRC)/test/Makefile.com
--- /dev/null	2019-02-11 00:23:23.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/assert-deflib/Makefile	2019-02-11 00:23:23.752487571 +0000
@@ -0,0 +1,49 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2018, Richard Lowe.
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROG =	test-deflib
+
+DATAFILES =	link.c
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/assert-deflib
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+
+DATA = $(DATAFILES:%=$(TESTDIR)/%)
+$(DATA) := FILEMODE = 0444
+
+all: $(PROG)
+
+install: all $(CMDS) $(DATA)
+
+lint:
+
+clobber: clean
+	-$(RM) $(PROG)
+
+clean:
+	-$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+	$(INS.dir)
+
+$(TESTDIR)/%: %
+	$(INS.file)
--- old/usr/src/cmd/sgs/test/ld/assert-deflib/link.c	2019-02-11 00:23:23.998266742 +0000
+++ /dev/null	2019-02-11 00:23:23.000000000 +0000
@@ -1,23 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright (c) 2012, Joyent, Inc.
- */
-
-#include <stdio.h>
-
-int
-main(void)
-{
-	(void) printf("Hello, world!\n");
-	return (0);
-}
--- /dev/null	2019-02-11 00:23:23.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/assert-deflib/link.c	2019-02-11 00:23:24.015917744 +0000
@@ -0,0 +1,23 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2012, Joyent, Inc.
+ */
+
+#include <stdio.h>
+
+int
+main(void)
+{
+	(void) printf("Hello, world!\n");
+	return (0);
+}
--- old/usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh	2019-02-11 00:23:24.229774691 +0000
+++ /dev/null	2019-02-11 00:23:23.000000000 +0000
@@ -1,135 +0,0 @@
-#!/bin/bash
-#
-# This file and its contents are supplied under the terms of the
-# Common Development and Distribution License ("CDDL"), version 1.0.
-# You may only use this file in accordance with the terms of version
-# 1.0 of the CDDL.
-#
-# A full copy of the text of the CDDL should have accompanied this
-# source.  A copy of the CDDL is also available via the Internet at
-# http://www.illumos.org/license/CDDL.
-#
-
-#
-# Copyright (c) 2012, Joyent, Inc.
-#
-
-#
-# This test validates that the -zassert-deflib option of ld(1) works correctly.
-# It requires that some cc is in your path and that you have passed in the path
-# to the proto area with the new version of libld.so.4. One thing that we have
-# to do is be careful with using LD_LIBRARY_PATH. Setting LD_LIBRARY_PATH does
-# not change the default search path so we want to make sure that we use a
-# different ISA (e.g. 32-bit vs 64-bit) from the binary we're generating.
-#
-unalias -a
-
-sh_path=
-sh_lib="lib"
-sh_lib64="$sh_lib/64"
-sh_soname="libld.so.4"
-sh_cc="cc"
-sh_cflags="-m32"
-sh_file="link.c"
-sh_arg0=$(basename $0)
-
-function fatal
-{
-        local msg="$*"
-        [[ -z "$msg" ]] && msg="failed"
-        echo "$sh_arg0: $msg" >&2
-        exit 1
-}
-
-
-#
-# Validate that everything we need is in our path. That includes having cc
-# and the proto area libld.
-#
-function validate
-{
-	[[ -f $sh_path/$sh_lib/$sh_soname ]] || fatal "missing 32-bit $sh_soname"
-	[[ -f $sh_path/$sh_lib64/$sh_soname ]] ||
-	    fatal "missing 64-bit $sh_soname"
-	which $sh_cc >/dev/null || fatal "cc not in path"
-}
-
-#
-# $1 is a series of flags to append
-# $2 is expected exit status
-# $3 is pre-test message
-# $4 is the failure message
-#
-function run
-{
-	local ret
-
-	echo $3
-	LD_LIBRARY_PATH_64="$sh_path/$sh_lib64" $sh_cc $sh_cflags $sh_file $1
-	if [[ $? -eq $2 ]]; then
-		printf "success\n\n"
-	else
-		fatal $4
-	fi
-}
-
-sh_path=$1
-[[ -z "$1" ]] && fatal "<proto root>"
-validate
-
-run "-Wl,-zassert-deflib" 0 \
-    "Testing basic compilation succeeds with warnings..." \
-    "failed to compile with warnings"
-
-run "-Wl,-zassert-deflib -Wl,-zfatal-warnings" 1 \
-    "Testing basic compilation fails if warning are fatal..." \
-    "linking succeeeded, expected failure"
-
-run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \
-    "Testing basic exception with fatal warnings..." \
-    "linking failed despite exception"
-
-run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \
-    "Testing basic exception with fatal warnings..." \
-    "linking failed despite exception"
-
-
-run "-Wl,-zassert-deflib=lib.so -Wl,-zfatal-warnings" 1 \
-    "Testing invalid library name..." \
-    "ld should not allow invalid library name"
-
-run "-Wl,-zassert-deflib=libf -Wl,-zfatal-warnings" 1 \
-    "Testing invalid library name..." \
-    "ld should not allow invalid library name"
-
-run "-Wl,-zassert-deflib=libf.s -Wl,-zfatal-warnings" 1 \
-    "Testing invalid library name..." \
-    "ld should not allow invalid library name"
-
-run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings -lelf" 1 \
-    "Errors even if one library is under exception path..." \
-    "one exception shouldn't stop another"
-
-args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelf.so"
-args="$args -Wl,-zfatal-warnings -lelf"
-
-run "$args" 0 \
-    "Multiple exceptions work..." \
-    "multiple exceptions don't work"
-
-args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelfe.so"
-args="$args -Wl,-zfatal-warnings -lelf"
-
-run "$args" 1 \
-    "Exceptions only catch the specific library" \
-    "exceptions caught the wrong library"
-
-args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libel.so"
-args="$args -Wl,-zfatal-warnings -lelf"
-
-run "$args" 1 \
-    "Exceptions only catch the specific library" \
-    "exceptions caught the wrong library"
-
-echo "Tests passed."
-exit 0
--- /dev/null	2019-02-11 00:23:23.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/assert-deflib/test-deflib.sh	2019-02-11 00:23:24.248387989 +0000
@@ -0,0 +1,139 @@
+#!/bin/bash
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012, Joyent, Inc.
+#
+
+#
+# This test validates that the -zassert-deflib option of ld(1) works correctly.
+# It requires that some cc is in your path and that you have passed in the path
+# to the proto area with the new version of libld.so.4. One thing that we have
+# to do is be careful with using LD_LIBRARY_PATH. Setting LD_LIBRARY_PATH does
+# not change the default search path so we want to make sure that we use a
+# different ISA (e.g. 32-bit vs 64-bit) from the binary we're generating.
+#
+unalias -a
+
+if [[ -z $ELF_TESTS ]]; then
+    print -u2 "Don't know where the test data is rooted";
+    exit 1;
+fi
+
+sh_path=
+sh_lib="lib"
+sh_lib64="$sh_lib/64"
+sh_soname="libld.so.4"
+sh_cc="gcc"
+sh_cflags="-m32"
+sh_file="${ELF_TESTS}/tests/assert-deflib/link.c"
+sh_arg0=$(basename $0)
+
+function fatal
+{
+        local msg="$*"
+        [[ -z "$msg" ]] && msg="failed"
+        echo "$sh_arg0: $msg" >&2
+        exit 1
+}
+
+
+#
+# Validate that everything we need is in our path. That includes having cc
+# and the proto area libld.
+#
+function validate
+{
+	[[ -f $sh_path/$sh_lib/$sh_soname ]] || fatal "missing 32-bit $sh_soname"
+	[[ -f $sh_path/$sh_lib64/$sh_soname ]] ||
+	    fatal "missing 64-bit $sh_soname"
+	which $sh_cc >/dev/null || fatal "cc not in path"
+}
+
+#
+# $1 is a series of flags to append
+# $2 is expected exit status
+# $3 is pre-test message
+# $4 is the failure message
+#
+function run
+{
+	local ret
+
+	echo $3
+	LD_LIBRARY_PATH_64="$sh_path/$sh_lib64" $sh_cc $sh_cflags $sh_file $1
+	if [[ $? -eq $2 ]]; then
+		printf "success\n\n"
+	else
+		fatal $4
+	fi
+}
+
+sh_path=${1:-/}
+validate
+
+run "-Wl,-zassert-deflib" 0 \
+    "Testing basic compilation succeeds with warnings..." \
+    "failed to compile with warnings"
+
+run "-Wl,-zassert-deflib -Wl,-zfatal-warnings" 1 \
+    "Testing basic compilation fails if warning are fatal..." \
+    "linking succeeeded, expected failure"
+
+run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \
+    "Testing basic exception with fatal warnings..." \
+    "linking failed despite exception"
+
+run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \
+    "Testing basic exception with fatal warnings..." \
+    "linking failed despite exception"
+
+
+run "-Wl,-zassert-deflib=lib.so -Wl,-zfatal-warnings" 1 \
+    "Testing invalid library name..." \
+    "ld should not allow invalid library name"
+
+run "-Wl,-zassert-deflib=libf -Wl,-zfatal-warnings" 1 \
+    "Testing invalid library name..." \
+    "ld should not allow invalid library name"
+
+run "-Wl,-zassert-deflib=libf.s -Wl,-zfatal-warnings" 1 \
+    "Testing invalid library name..." \
+    "ld should not allow invalid library name"
+
+run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings -lelf" 1 \
+    "Errors even if one library is under exception path..." \
+    "one exception shouldn't stop another"
+
+args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelf.so"
+args="$args -Wl,-zfatal-warnings -lelf"
+
+run "$args" 0 \
+    "Multiple exceptions work..." \
+    "multiple exceptions don't work"
+
+args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelfe.so"
+args="$args -Wl,-zfatal-warnings -lelf"
+
+run "$args" 1 \
+    "Exceptions only catch the specific library" \
+    "exceptions caught the wrong library"
+
+args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libel.so"
+args="$args -Wl,-zfatal-warnings -lelf"
+
+run "$args" 1 \
+    "Exceptions only catch the specific library" \
+    "exceptions caught the wrong library"
+
+echo "Tests passed."
+exit 0
--- /dev/null	2019-02-11 00:23:24.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/linker-sets/Makefile	2019-02-11 00:23:24.711709742 +0000
@@ -0,0 +1,50 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2018, Richard Lowe.
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROG =	simple in-use-check
+
+DATAFILES =	simple-src.c \
+		simple.out
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/linker-sets
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+
+DATA = $(DATAFILES:%=$(TESTDIR)/%)
+$(DATA) := FILEMODE = 0444
+
+all: $(PROG)
+
+install: all $(CMDS) $(DATA)
+
+lint:
+
+clobber: clean
+	-$(RM) $(PROG)
+
+clean:
+	-$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+	$(INS.dir)
+
+$(TESTDIR)/%: %
+	$(INS.file)
--- /dev/null	2019-02-11 00:23:24.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/linker-sets/in-use-check.sh	2019-02-11 00:23:24.940638671 +0000
@@ -0,0 +1,52 @@
+#!/usr/bin/ksh
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2018, Richard Lowe.
+#
+
+# Test that a simple use of linker-sets, tat is, automatically generated start
+# and end symbols for sections can be generated and used.
+
+tmpdir=/tmp/test.$$
+mkdir $tmpdir
+cd $tmpdir
+
+cleanup() {
+    cd /
+    rm -fr $tmpdir
+}
+
+trap 'cleanup' EXIT
+
+cat > broken.c <<EOF
+void *__start_text;
+
+int
+main()
+{
+	return (0);
+}
+EOF
+
+# We expect any alternate linker to be in LD_ALTEXEC for us already
+gcc -o broken broken.c -Wall -Wextra -Wl,-zfatal-warnings > in-use.$$.out 2>&1
+if (( $? == 0 )); then
+    print -u2 "use of a reserved symbol didn't fail"
+    exit 1;
+fi
+
+grep -q "^ld: warning: reserved symbol '__start_text' already defined in file" in-use.$$.out
+if (( $? != 0 )); then
+    print -u2 "use of a reserved symbol failed for the wrong reason"
+    exit 1;
+fi
--- /dev/null	2019-02-11 00:23:25.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/linker-sets/simple-src.c	2019-02-11 00:23:25.175904982 +0000
@@ -0,0 +1,105 @@
+/* The meat of this file is a copy of the FreeBSD sys/link_set.h */
+/*
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 1999 John D. Polstra
+ * Copyright (c) 1999,2001 Peter Wemm <peter@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+
+#define	MAKE_SET(set, sym)					\
+	__asm__(".globl __start_set_" #set);			\
+	__asm__(".globl __stop_set_" #set);			\
+	static __attribute__((section(".set_" #set), used))	\
+	void const *__set_##set##_sym_##sym = &(sym)
+
+/*
+ * Initialize before referring to a given linker set.
+ */
+#define	SET_DECLARE(set, ptype)						\
+	extern  __attribute__((weak)) ptype *__start_set_ ## set;	\
+	extern __attribute__((weak)) ptype *__stop_set_ ## set
+
+#define	SET_BEGIN(set)	(&__start_set_ ## set)
+#define	SET_LIMIT(set)	(&__stop_set_ ## set)
+
+/*
+ * Iterate over all the elements of a set.
+ *
+ * Sets always contain addresses of things, and "pvar" points to words
+ * containing those addresses.  Thus is must be declared as "type **pvar",
+ * and the address of each set item is obtained inside the loop by "*pvar".
+ */
+#define	SET_FOREACH(pvar, set)						\
+	for (pvar = SET_BEGIN(set); pvar < SET_LIMIT(set); pvar++)
+
+#define	SET_ITEM(set, i)						\
+	((SET_BEGIN(set))[i])
+
+/*
+ * Provide a count of the items in a set.
+ */
+#define	SET_COUNT(set)							\
+	(SET_LIMIT(set) - SET_BEGIN(set))
+
+struct foo {
+	char buf[128];
+};
+
+SET_DECLARE(foo, struct foo);
+
+struct foo a = { "foo" };
+struct foo b = { "bar" };
+struct foo c = { "baz" };
+
+MAKE_SET(foo, a);
+MAKE_SET(foo, b);
+MAKE_SET(foo, c);
+
+int
+main(int __attribute__((unused)) argc, char __attribute__((unused)) **argv)
+{
+	struct foo **c;
+	int i = 0;
+
+	printf("Set count: %d\n", SET_COUNT(foo));
+
+
+	printf("a: %s\n", ((struct foo *)__set_foo_sym_a)->buf);
+	printf("b: %s\n", ((struct foo *)__set_foo_sym_b)->buf);
+	printf("c: %s\n", ((struct foo *)__set_foo_sym_c)->buf);
+
+	printf("item(foo, 0): %s\n", SET_ITEM(foo, 0)->buf);
+	printf("item(foo, 1): %s\n", SET_ITEM(foo, 1)->buf);
+	printf("item(foo, 2): %s\n", SET_ITEM(foo, 2)->buf);
+
+	SET_FOREACH(c, foo) {
+		printf("foo[%d]: %s\n", i, (*c)->buf);
+		i++;
+	}
+}
--- /dev/null	2019-02-11 00:23:25.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/linker-sets/simple.out	2019-02-11 00:23:25.383560040 +0000
@@ -0,0 +1,10 @@
+Set count: 3
+a: foo
+b: bar
+c: baz
+item(foo, 0): foo
+item(foo, 1): bar
+item(foo, 2): baz
+foo[0]: foo
+foo[1]: bar
+foo[2]: baz
--- /dev/null	2019-02-11 00:23:25.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/linker-sets/simple.sh	2019-02-11 00:23:25.626130421 +0000
@@ -0,0 +1,54 @@
+#!/usr/bin/ksh
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2018, Richard Lowe.
+#
+
+# Test that a simple use of linker-sets, tat is, automatically generated start
+# and end symbols for sections can be generated and used.
+
+if [[ -z $ELF_TESTS ]]; then
+    print -u2 "Don't know where the test data is rooted";
+    exit 1;
+fi
+
+tmpdir=/tmp/test.$$
+mkdir $tmpdir
+cd $tmpdir
+
+cleanup() {
+    cd /
+    rm -fr $tmpdir
+}
+
+trap 'cleanup' EXIT
+
+# We expect any alternate linker to be in LD_ALTEXEC for us already
+gcc -o simple ${ELF_TESTS}/tests/linker-sets/simple-src.c -Wall -Wextra
+if (( $? != 0 )); then
+    print -u2 "compilation of ${ELF_TESTS}/tests/linker-sets/simple-src.c failed";
+    exit 1;
+fi
+
+./simple > simple.$$.out 2>&1
+
+if (( $? != 0 )); then
+    print -u2 "execution of ${ELF_TESTS}/tests/linker-sets/simple-src.c failed";
+    exit 1;
+fi
+
+diff -u ${ELF_TESTS}/tests/linker-sets/simple.out simple.$$.out
+if (( $? != 0 )); then
+    print -u2 "${ELF_TESTS}/tests/linker-sets/simple-src.c output mismatch"
+    exit 1;
+fi
--- /dev/null	2019-02-11 00:23:25.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/Makefile	2019-02-11 00:23:25.862443334 +0000
@@ -0,0 +1,19 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
+#
+
+SUBDIRS = x64 x86
+
+include $(SRC)/test/Makefile.com
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/Makefile	2019-02-11 00:23:26.092191639 +0000
@@ -0,0 +1,19 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
+#
+
+SUBDIRS = ie
+
+include $(SRC)/test/Makefile.com
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/Makefile	2019-02-11 00:23:26.327275309 +0000
@@ -0,0 +1,58 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2018, Richard Lowe.
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROG =	x64-ie-test
+
+DATAFILES =			\
+	Makefile.test		\
+	style1-func-with-r12.s	\
+	style1-func-with-r13.s	\
+	style1-func.s		\
+	style1-main.s		\
+	style2-with-badness.s	\
+	style2-with-r12.s	\
+	style2-with-r13.s	\
+	style2.s
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/tls/x64/ie
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+
+DATA = $(DATAFILES:%=$(TESTDIR)/%)
+$(DATA) := FILEMODE = 0444
+
+all: $(PROG)
+
+install: all $(CMDS) $(DATA)
+
+lint:
+
+clobber: clean
+	-$(RM) $(PROG)
+
+clean:
+	-$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+	$(INS.dir)
+
+$(TESTDIR)/%: %
+	$(INS.file)
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/Makefile	2019-02-11 00:23:26.550567936 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,87 +0,0 @@
-#
-# This file and its contents are supplied under the terms of the
-# Common Development and Distribution License ("CDDL"), version 1.0.
-# You may only use this file in accordance with the terms of version
-# 1.0 of the CDDL.
-#
-# A full copy of the text of the CDDL should have accompanied this
-# source.  A copy of the CDDL is also available via the Internet at
-# http://www.illumos.org/license/CDDL.
-#
-
-# Copyright 2012, Richard Lowe.
-
-include $(SRC)/Makefile.master
-
-# We have to use GCC, and only GCC.  The best way is to ask cw(1) which GCC to use.
-CC_CMD =	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc -_compiler
-CC =		$(CC_CMD:sh)
-CFLAGS = 	-O1 -m64
-
-LINK.c = env LD_ALTEXEC=$(PROTO)/usr/bin/amd64/ld $(CC) $(CFLAGS) -o $@ $^
-COMPILE.c = $(CC) $(CFLAGS) -c -o $@ $^
-COMPILE.s = $(CC) $(CFLAGS) -c -o $@ $^
-
-.KEEP_STATE:
-
-install default: all
-
-.c.o:
-	$(COMPILE.c)
-
-.s.o:
-	$(COMPILE.s)
-
-# A basic use of TLS that uses the movq m/r --> movq i/r variant
-PROGS += 	style2
-STYLE2OBJS =	style2.o
-style2: $(STYLE2OBJS)
-	$(LINK.c)
-
-# A copy of style2 that uses %r13 in the TLS sequence, and thus excercises the
-# REX transitions of the movq mem,reg -> movq imm,reg variant.
-PROGS +=	style2-with-r13
-STYLE2R13OBJS =	style2-with-r13.o
-style2-with-r13: $(STYLE2R13OBJS)
-	$(LINK.c)
-
-# A copy of style2 that uses %r12 in the TLS sequence, so we can verify that
-# it is _not_ special to this variant
-PROGS +=	style2-with-r12
-STYLE2R12OBJS =	style2-with-r12.o
-style2-with-r12: $(STYLE2R12OBJS)
-	$(LINK.c)
-
-# A copy of style2 that has a R_AMD64_GOTTPOFF relocation with a bad insn sequence
-STYLE2BADNESSOBJS =	style2-with-badness.o
-style2-with-badness: $(STYLE2BADNESSOBJS)
-	-$(LINK.c)
-
-# A basic use of TLS that uses the addq mem/reg --> leaq mem,reg variant
-PROGS +=	style1
-STYLE1OBJS =	style1-main.o style1-func.o
-style1: $(STYLE1OBJS)
-	$(LINK.c)
-
-# A copy of style1-func that uses %r13 in the TLS sequence and thus excercises
-# the REX transitions. of the addq mem,reg --> leaq mem,reg variant
-PROGS +=	style1-with-r13
-STYLE1R13OBJS =	style1-main.o style1-func-with-r13.o
-style1-with-r13: $(STYLE1R13OBJS)
-	$(LINK.c)
-
-# A copy of style1-func that uses %r12 to test the addq mem,reg --> addq imm,reg variant
-PROGS +=	style1-with-r12
-STYLE1R12OBJS =	style1-main.o style1-func-with-r12.o
-style1-with-r12: $(STYLE1R12OBJS)
-	$(LINK.c)
-
-all:	$(PROGS)
-
-clobber clean: 
-	rm -f $(PROGS) $(STYLE1OBJS) $(STYLE1R13OBJS) $(STYLE1R12OBJS) \
-	    $(STYLE2OBJS) $(STYLE2R13OBJS) $(STYLE2R12OBJS) $(STYLE2BADNESSOBJS)
-
-fail: style2-with-badness FRC
-
-FRC:
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/Makefile.test	2019-02-11 00:23:26.568517713 +0000
@@ -0,0 +1,82 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2012, Richard Lowe.
+
+CC =		gcc
+CFLAGS =	-O1 -m64
+
+LINK.c =  $(CC) $(CFLAGS) -o $@ $^
+COMPILE.c = $(CC) $(CFLAGS) -c -o $@ $^
+COMPILE.s = $(CC) $(CFLAGS) -c -o $@ $^
+
+.KEEP_STATE:
+
+install default: all
+
+%.o: $(ELF_TESTS)/tests/tls/x64/ie/%.c
+	$(COMPILE.c)
+%.o: $(ELF_TESTS)/tests/tls/x64/ie/%.s
+	$(COMPILE.s)
+
+# A basic use of TLS that uses the movq m/r --> movq i/r variant
+PROGS +=	style2
+STYLE2OBJS =	style2.o
+style2: $(STYLE2OBJS)
+	$(LINK.c)
+
+# A copy of style2 that uses %r13 in the TLS sequence, and thus excercises the
+# REX transitions of the movq mem,reg -> movq imm,reg variant.
+PROGS +=	style2-with-r13
+STYLE2R13OBJS =	style2-with-r13.o
+style2-with-r13: $(STYLE2R13OBJS)
+	$(LINK.c)
+
+# A copy of style2 that uses %r12 in the TLS sequence, so we can verify that
+# it is _not_ special to this variant
+PROGS +=	style2-with-r12
+STYLE2R12OBJS =	style2-with-r12.o
+style2-with-r12: $(STYLE2R12OBJS)
+	$(LINK.c)
+
+# A copy of style2 that has a R_AMD64_GOTTPOFF relocation with a bad insn sequence
+STYLE2BADNESSOBJS =	style2-with-badness.o
+style2-with-badness: $(STYLE2BADNESSOBJS)
+	-$(LINK.c)
+
+# A basic use of TLS that uses the addq mem/reg --> leaq mem,reg variant
+PROGS +=	style1
+STYLE1OBJS =	style1-main.o style1-func.o
+style1: $(STYLE1OBJS)
+	$(LINK.c)
+
+# A copy of style1-func that uses %r13 in the TLS sequence and thus excercises
+# the REX transitions. of the addq mem,reg --> leaq mem,reg variant
+PROGS +=	style1-with-r13
+STYLE1R13OBJS =	style1-main.o style1-func-with-r13.o
+style1-with-r13: $(STYLE1R13OBJS)
+	$(LINK.c)
+
+# A copy of style1-func that uses %r12 to test the addq mem,reg --> addq imm,reg variant
+PROGS +=	style1-with-r12
+STYLE1R12OBJS =	style1-main.o style1-func-with-r12.o
+style1-with-r12: $(STYLE1R12OBJS)
+	$(LINK.c)
+
+all:	$(PROGS)
+
+clobber clean:
+	rm -f $(PROGS) $(STYLE1OBJS) $(STYLE1R13OBJS) $(STYLE1R12OBJS) \
+	    $(STYLE2OBJS) $(STYLE2R13OBJS) $(STYLE2R12OBJS) $(STYLE2BADNESSOBJS)
+
+fail: style2-with-badness FRC
+
+FRC:
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/README	2019-02-11 00:23:27.043767497 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,9 +0,0 @@
-This tests the x64 link-editor's handling of Initial Executable TLS sequences.
-
-The original C source files are in orig/ but unused, since we need to avoid
-any changes to the compiler influencing our tests.
-
-    % ksh x64-ie-test.sh /path/to/proto/root
-    pass: addq-->leaq 1
-    ...
-    pass: bad insn sequence
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/README	2019-02-11 00:23:27.059542282 +0000
@@ -0,0 +1,9 @@
+This tests the x64 link-editor's handling of Initial Executable TLS sequences.
+
+The original C source files are in orig/ but unused, since we need to avoid
+any changes to the compiler influencing our tests.
+
+    % ksh x64-ie-test.sh /path/to/proto/root
+    pass: addq-->leaq 1
+    ...
+    pass: bad insn sequence
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-func.c	2019-02-11 00:23:27.241262420 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,24 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */
-
-#include <stdio.h>
-
-extern __thread char *foo, *bar;
-
-void
-func()
-{
-	printf("foo: %p bar: %p\n", &foo, &bar);
-}
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/orig/style1-func.c	2019-02-11 00:23:27.252315289 +0000
@@ -0,0 +1,24 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+#include <stdio.h>
+
+extern __thread char *foo, *bar;
+
+void
+func()
+{
+	printf("foo: %p bar: %p\n", &foo, &bar);
+}
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-main.c	2019-02-11 00:23:27.451554800 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,29 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */
-
-#include <stdio.h>
-
-extern void func();
-
-__thread char *foo = "foo";
-__thread char *bar = "bar";
-
-int
-main(void)
-{
-	printf("foo: %p bar: %p\n", &foo, &bar);
-	func();
-	return (0);
-}
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/orig/style1-main.c	2019-02-11 00:23:27.467357509 +0000
@@ -0,0 +1,29 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+#include <stdio.h>
+
+extern void func();
+
+__thread char *foo = "foo";
+__thread char *bar = "bar";
+
+int
+main(void)
+{
+	printf("foo: %p bar: %p\n", &foo, &bar);
+	func();
+	return (0);
+}
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style2.c	2019-02-11 00:23:27.666177209 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,25 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */
-
-#include <stdio.h>
-
-__thread char *foo __attribute__((tls_model("initial-exec"))) = "foo";
-
-int
-main(void)
-{
-	printf("foo: %p\n", &foo);
-	return (0);
-}
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/orig/style2.c	2019-02-11 00:23:27.682708055 +0000
@@ -0,0 +1,25 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+#include <stdio.h>
+
+__thread char *foo __attribute__((tls_model("initial-exec"))) = "foo";
+
+int
+main(void)
+{
+	printf("foo: %p\n", &foo);
+	return (0);
+}
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r12.s	2019-02-11 00:23:27.893809897 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,39 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */
-
-	.section	.rodata.str1.1,"aMS",@progbits,1
-.LC0:
-	.string	"foo: %p bar: %p\n"
-	.text
-.globl func
-	.type	func, @function
-func:
-.LFB0:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	movq	%fs:0, %r12
-	movq	%r12, %rdx
-	addq	bar@GOTTPOFF(%rip), %rdx
-	addq	foo@GOTTPOFF(%rip), %r12
-        movq    %r12, %rsi     
-	movl	$.LC0, %edi
-	movl	$0, %eax
-	call	printf
-	leave
-	ret
-.LFE0:
-	.size	func, .-func
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/style1-func-with-r12.s	2019-02-11 00:23:27.909879096 +0000
@@ -0,0 +1,39 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+	.section	.rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string	"foo: %p bar: %p\n"
+	.text
+.globl func
+	.type	func, @function
+func:
+.LFB0:
+	pushq	%rbp
+.LCFI0:
+	movq	%rsp, %rbp
+.LCFI1:
+	movq	%fs:0, %r12
+	movq	%r12, %rdx
+	addq	bar@GOTTPOFF(%rip), %rdx
+	addq	foo@GOTTPOFF(%rip), %r12
+        movq    %r12, %rsi
+	movl	$.LC0, %edi
+	movl	$0, %eax
+	call	printf
+	leave
+	ret
+.LFE0:
+	.size	func, .-func
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r13.s	2019-02-11 00:23:28.375672260 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,38 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */
-	.section	.rodata.str1.1,"aMS",@progbits,1
-.LC0:
-	.string	"foo: %p bar: %p\n"
-	.text
-.globl func
-	.type	func, @function
-func:
-.LFB0:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	movq	%fs:0, %r13
-	movq	%r13, %rdx
-	addq	bar@GOTTPOFF(%rip), %rdx
-	addq	foo@GOTTPOFF(%rip), %r13
-        movq    %r13, %rsi
-	movl	$.LC0, %edi
-	movl	$0, %eax
-	call	printf
-	leave
-	ret
-.LFE0:
-	.size	func, .-func
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/style1-func-with-r13.s	2019-02-11 00:23:28.393679040 +0000
@@ -0,0 +1,38 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+	.section	.rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string	"foo: %p bar: %p\n"
+	.text
+.globl func
+	.type	func, @function
+func:
+.LFB0:
+	pushq	%rbp
+.LCFI0:
+	movq	%rsp, %rbp
+.LCFI1:
+	movq	%fs:0, %r13
+	movq	%r13, %rdx
+	addq	bar@GOTTPOFF(%rip), %rdx
+	addq	foo@GOTTPOFF(%rip), %r13
+        movq    %r13, %rsi
+	movl	$.LC0, %edi
+	movl	$0, %eax
+	call	printf
+	leave
+	ret
+.LFE0:
+	.size	func, .-func
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func.s	2019-02-11 00:23:28.601153053 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,38 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */
-
-	.section	.rodata.str1.1,"aMS",@progbits,1
-.LC0:
-	.string	"foo: %p bar: %p\n"
-	.text
-.globl func
-	.type	func, @function
-func:
-.LFB0:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	movq	%fs:0, %rsi
-	movq	%rsi, %rdx
-	addq	bar@GOTTPOFF(%rip), %rdx
-	addq	foo@GOTTPOFF(%rip), %rsi
-	movl	$.LC0, %edi
-	movl	$0, %eax
-	call	printf
-	leave
-	ret
-.LFE0:
-	.size	func, .-func
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/style1-func.s	2019-02-11 00:23:28.618398369 +0000
@@ -0,0 +1,38 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+	.section	.rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string	"foo: %p bar: %p\n"
+	.text
+.globl func
+	.type	func, @function
+func:
+.LFB0:
+	pushq	%rbp
+.LCFI0:
+	movq	%rsp, %rbp
+.LCFI1:
+	movq	%fs:0, %rsi
+	movq	%rsi, %rdx
+	addq	bar@GOTTPOFF(%rip), %rdx
+	addq	foo@GOTTPOFF(%rip), %rsi
+	movl	$.LC0, %edi
+	movl	$0, %eax
+	call	printf
+	leave
+	ret
+.LFE0:
+	.size	func, .-func
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-main.s	2019-02-11 00:23:28.841231653 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,60 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */
-
-	.section	.rodata.str1.1,"aMS",@progbits,1
-.LC0:
-	.string	"foo: %p bar: %p\n"
-	.text
-.globl main
-	.type	main, @function
-main:
-.LFB0:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	movq	%fs:0, %rsi
-	leaq	bar@TPOFF(%rsi), %rdx
-	addq	$foo@TPOFF, %rsi
-	movl	$.LC0, %edi
-	movl	$0, %eax
-	call	printf
-	movl	$0, %eax
-	call	func
-	movl	$0, %eax
-	leave
-	ret
-.LFE0:
-	.size	main, .-main
-.globl foo
-	.section	.rodata.str1.1
-.LC1:
-	.string	"foo"
-	.section	.tdata,"awT",@progbits
-	.align 8
-	.type	foo, @object
-	.size	foo, 8
-foo:
-	.quad	.LC1
-.globl bar
-	.section	.rodata.str1.1
-.LC2:
-	.string	"bar"
-	.section	.tdata
-	.align 8
-	.type	bar, @object
-	.size	bar, 8
-bar:
-	.quad	.LC2
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/style1-main.s	2019-02-11 00:23:28.857987532 +0000
@@ -0,0 +1,60 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+	.section	.rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string	"foo: %p bar: %p\n"
+	.text
+.globl main
+	.type	main, @function
+main:
+.LFB0:
+	pushq	%rbp
+.LCFI0:
+	movq	%rsp, %rbp
+.LCFI1:
+	movq	%fs:0, %rsi
+	leaq	bar@TPOFF(%rsi), %rdx
+	addq	$foo@TPOFF, %rsi
+	movl	$.LC0, %edi
+	movl	$0, %eax
+	call	printf
+	movl	$0, %eax
+	call	func
+	movl	$0, %eax
+	leave
+	ret
+.LFE0:
+	.size	main, .-main
+.globl foo
+	.section	.rodata.str1.1
+.LC1:
+	.string	"foo"
+	.section	.tdata,"awT",@progbits
+	.align 8
+	.type	foo, @object
+	.size	foo, 8
+foo:
+	.quad	.LC1
+.globl bar
+	.section	.rodata.str1.1
+.LC2:
+	.string	"bar"
+	.section	.tdata
+	.align 8
+	.type	bar, @object
+	.size	bar, 8
+bar:
+	.quad	.LC2
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-badness.s	2019-02-11 00:23:29.059191628 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,47 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */	
-
-	.section	.rodata.str1.1,"aMS",@progbits,1
-.LC0:
-	.string	"foo: %p\n"
-	.text
-.globl main
-	.type	main, @function
-main:
-.LFB0:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	leaq	foo@GOTTPOFF(%rip), %rsi
-	addq	%fs:0, %rsi
-	movl	$.LC0, %edi
-	movl	$0, %eax
-	call	printf
-	movl	$0, %eax
-	leave
-	ret
-.LFE0:
-	.size	main, .-main
-.globl foo
-	.section	.rodata.str1.1
-.LC1:
-	.string	"foo"
-	.section	.tdata,"awT",@progbits
-	.align 8
-	.type	foo, @object
-	.size	foo, 8
-foo:
-	.quad	.LC1
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/style2-with-badness.s	2019-02-11 00:23:29.076160306 +0000
@@ -0,0 +1,47 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+	.section	.rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string	"foo: %p\n"
+	.text
+.globl main
+	.type	main, @function
+main:
+.LFB0:
+	pushq	%rbp
+.LCFI0:
+	movq	%rsp, %rbp
+.LCFI1:
+	leaq	foo@GOTTPOFF(%rip), %rsi
+	addq	%fs:0, %rsi
+	movl	$.LC0, %edi
+	movl	$0, %eax
+	call	printf
+	movl	$0, %eax
+	leave
+	ret
+.LFE0:
+	.size	main, .-main
+.globl foo
+	.section	.rodata.str1.1
+.LC1:
+	.string	"foo"
+	.section	.tdata,"awT",@progbits
+	.align 8
+	.type	foo, @object
+	.size	foo, 8
+foo:
+	.quad	.LC1
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r12.s	2019-02-11 00:23:29.558655523 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,48 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */	
-
-	.section	.rodata.str1.1,"aMS",@progbits,1
-.LC0:
-	.string	"foo: %p\n"
-	.text
-.globl main
-	.type	main, @function
-main:
-.LFB0:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	movq	foo@GOTTPOFF(%rip), %r12
-	addq	%fs:0, %r12
-        movq    %r12, %rsi
-	movl	$.LC0, %edi
-	movl	$0, %eax
-	call	printf
-	movl	$0, %eax
-	leave
-	ret
-.LFE0:
-	.size	main, .-main
-.globl foo
-	.section	.rodata.str1.1
-.LC1:
-	.string	"foo"
-	.section	.tdata,"awT",@progbits
-	.align 8
-	.type	foo, @object
-	.size	foo, 8
-foo:
-	.quad	.LC1
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/style2-with-r12.s	2019-02-11 00:23:29.575910499 +0000
@@ -0,0 +1,49 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+	.section	.rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string	"foo: %p\n"
+	.text
+.globl main
+	.type	main, @function
+main:
+.LFB0:
+	pushq	%rbp
+.LCFI0:
+	movq	%rsp, %rbp
+.LCFI1:
+	movq	foo@GOTTPOFF(%rip), %r12
+	addq	%fs:0, %r12
+        movq    %r12, %rsi
+	movl	$.LC0, %edi
+	movl	$0, %eax
+	call	printf
+	movl	$0, %eax
+	leave
+	ret
+.LFE0:
+	.size	main, .-main
+.globl foo
+	.section	.rodata.str1.1
+.LC1:
+	.string	"foo"
+
+	.section	.tdata,"awT",@progbits
+	.align 8
+	.type	foo, @object
+	.size	foo, 8
+foo:
+	.quad	.LC1
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r13.s	2019-02-11 00:23:30.057576529 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,48 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */	
-
-	.section	.rodata.str1.1,"aMS",@progbits,1
-.LC0:
-	.string	"foo: %p\n"
-	.text
-.globl main
-	.type	main, @function
-main:
-.LFB0:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	movq	foo@GOTTPOFF(%rip), %r13
-	addq	%fs:0, %r13
-        movq    %r13, %rsi
-	movl	$.LC0, %edi
-	movl	$0, %eax
-	call	printf
-	movl	$0, %eax
-	leave
-	ret
-.LFE0:
-	.size	main, .-main
-.globl foo
-	.section	.rodata.str1.1
-.LC1:
-	.string	"foo"
-	.section	.tdata,"awT",@progbits
-	.align 8
-	.type	foo, @object
-	.size	foo, 8
-foo:
-	.quad	.LC1
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/style2-with-r13.s	2019-02-11 00:23:30.074205758 +0000
@@ -0,0 +1,48 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+	.section	.rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string	"foo: %p\n"
+	.text
+.globl main
+	.type	main, @function
+main:
+.LFB0:
+	pushq	%rbp
+.LCFI0:
+	movq	%rsp, %rbp
+.LCFI1:
+	movq	foo@GOTTPOFF(%rip), %r13
+	addq	%fs:0, %r13
+        movq    %r13, %rsi
+	movl	$.LC0, %edi
+	movl	$0, %eax
+	call	printf
+	movl	$0, %eax
+	leave
+	ret
+.LFE0:
+	.size	main, .-main
+.globl foo
+	.section	.rodata.str1.1
+.LC1:
+	.string	"foo"
+	.section	.tdata,"awT",@progbits
+	.align 8
+	.type	foo, @object
+	.size	foo, 8
+foo:
+	.quad	.LC1
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2.s	2019-02-11 00:23:30.557434798 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,47 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2012, Richard Lowe.
- */	
-
-	.section	.rodata.str1.1,"aMS",@progbits,1
-.LC0:
-	.string	"foo: %p\n"
-	.text
-.globl main
-	.type	main, @function
-main:
-.LFB0:
-	pushq	%rbp
-.LCFI0:
-	movq	%rsp, %rbp
-.LCFI1:
-	movq	foo@GOTTPOFF(%rip), %rsi
-	addq	%fs:0, %rsi
-	movl	$.LC0, %edi
-	movl	$0, %eax
-	call	printf
-	movl	$0, %eax
-	leave
-	ret
-.LFE0:
-	.size	main, .-main
-.globl foo
-	.section	.rodata.str1.1
-.LC1:
-	.string	"foo"
-	.section	.tdata,"awT",@progbits
-	.align 8
-	.type	foo, @object
-	.size	foo, 8
-foo:
-	.quad	.LC1
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/style2.s	2019-02-11 00:23:30.574619683 +0000
@@ -0,0 +1,47 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012, Richard Lowe.
+ */
+
+	.section	.rodata.str1.1,"aMS",@progbits,1
+.LC0:
+	.string	"foo: %p\n"
+	.text
+.globl main
+	.type	main, @function
+main:
+.LFB0:
+	pushq	%rbp
+.LCFI0:
+	movq	%rsp, %rbp
+.LCFI1:
+	movq	foo@GOTTPOFF(%rip), %rsi
+	addq	%fs:0, %rsi
+	movl	$.LC0, %edi
+	movl	$0, %eax
+	call	printf
+	movl	$0, %eax
+	leave
+	ret
+.LFE0:
+	.size	main, .-main
+.globl foo
+	.section	.rodata.str1.1
+.LC1:
+	.string	"foo"
+	.section	.tdata,"awT",@progbits
+	.align 8
+	.type	foo, @object
+	.size	foo, 8
+foo:
+	.quad	.LC1
--- old/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh	2019-02-11 00:23:31.030143319 +0000
+++ /dev/null	2019-02-11 00:23:26.000000000 +0000
@@ -1,62 +0,0 @@
-#!/bin/ksh
-#
-# This file and its contents are supplied under the terms of the
-# Common Development and Distribution License ("CDDL"), version 1.0.
-# You may only use this file in accordance with the terms of version
-# 1.0 of the CDDL.
-#
-# A full copy of the text of the CDDL should have accompanied this
-# source.  A copy of the CDDL is also available via the Internet at
-# http://www.illumos.org/license/CDDL.
-#
-
-# Copyright 2012, Richard Lowe.
-
-function grep_test {
-    name=$1
-    pattern=$2
-
-    if /usr/bin/fgrep -q "${pattern}"; then
-	print -u2 "pass: $name"
-    else
-        print -u2 "FAIL: $name"
-    fi
-}        
-
-function dis_test {
-    name=${1}
-    func=${2}
-    file=${3}
-    pattern=${4}
-
-    dis -F${func} ${file} | grep_test "${name}" "${pattern}"
-}
-
-make PROTO="${1}"
-
-dis_test "addq-->leaq 1" func style1 \
-    'func+0x10: 48 8d 92 f8 ff ff  leaq   -0x8(%rdx),%rdx'
-dis_test "addq-->leaq 2" func style1 \
-    'func+0x17: 48 8d b6 f0 ff ff  leaq   -0x10(%rsi),%rsi'
-
-dis_test "addq-->leaq w/REX 1" func style1-with-r13 \
-    'func+0x10: 48 8d 92 f8 ff ff  leaq   -0x8(%rdx),%rdx'
-dis_test "addq-->leaq w/REX 2" func style1-with-r13 \
-    'func+0x17: 4d 8d ad f0 ff ff  leaq   -0x10(%r13),%r13'
-
-dis_test "addq-->addq for SIB 1" func style1-with-r12 \
-    'func+0x10: 48 8d 92 f8 ff ff  leaq   -0x8(%rdx),%rdx'
-dis_test "addq-->addq for SIB 2" func style1-with-r12 \
-    'func+0x17: 49 81 c4 f0 ff ff  addq   $-0x10,%r12	<0xfffffffffffffff0>'
-
-dis_test "movq-->movq" main style2 \
-    'main+0x4:  48 c7 c6 f0 ff ff  movq   $-0x10,%rsi	<0xfffffffffffffff0>'
-
-dis_test "movq-->movq w/REX" main style2-with-r13 \
-    'main+0x4:  49 c7 c5 f0 ff ff  movq   $-0x10,%r13	<0xfffffffffffffff0>'
-
-dis_test "movq-->movq incase of SIB" main style2-with-r12 \
-    'main+0x4:  49 c7 c4 f0 ff ff  movq   $-0x10,%r12	<0xfffffffffffffff0>'
-
-make PROTO="${1}" fail 2>&1 | grep_test "bad insn sequence" \
-   'ld: fatal: relocation error: R_AMD64_TPOFF32: file style2-with-badness.o: symbol foo: section .text: offset 0x7, relocation against unknown TLS instruction sequence'
--- /dev/null	2019-02-11 00:23:26.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x64/ie/x64-ie-test.sh	2019-02-11 00:23:31.047579582 +0000
@@ -0,0 +1,68 @@
+#!/bin/ksh
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2012, Richard Lowe.
+
+function grep_test {
+    name=$1
+    pattern=$2
+
+    if /usr/bin/fgrep -q "${pattern}"; then
+	print -u2 "pass: $name"
+    else
+        print -u2 "FAIL: $name"
+        exit 1
+    fi
+}
+
+function dis_test {
+    name=${1}
+    func=${2}
+    file=${3}
+    pattern=${4}
+
+    dis -F${func} ${file} | grep_test "${name}" "${pattern}"
+}
+
+if [[ -z $ELF_TESTS ]]; then
+    print -u2 "Don't know where the test data is rooted";
+    exit 1;
+fi
+
+make -f ${ELF_TESTS}/tests/tls/x64/ie/Makefile.test
+
+dis_test "addq-->leaq 1" func style1 \
+    'func+0x10: 48 8d 92 f8 ff ff  leaq   -0x8(%rdx),%rdx'
+dis_test "addq-->leaq 2" func style1 \
+    'func+0x17: 48 8d b6 f0 ff ff  leaq   -0x10(%rsi),%rsi'
+
+dis_test "addq-->leaq w/REX 1" func style1-with-r13 \
+    'func+0x10: 48 8d 92 f8 ff ff  leaq   -0x8(%rdx),%rdx'
+dis_test "addq-->leaq w/REX 2" func style1-with-r13 \
+    'func+0x17: 4d 8d ad f0 ff ff  leaq   -0x10(%r13),%r13'
+
+dis_test "addq-->addq for SIB 1" func style1-with-r12 \
+    'func+0x10: 48 8d 92 f8 ff ff  leaq   -0x8(%rdx),%rdx'
+dis_test "addq-->addq for SIB 2" func style1-with-r12 \
+    'func+0x17: 49 81 c4 f0 ff ff  addq   $-0x10,%r12	<0xfffffffffffffff0>'
+
+dis_test "movq-->movq" main style2 \
+    'main+0x4:  48 c7 c6 f0 ff ff  movq   $-0x10,%rsi	<0xfffffffffffffff0>'
+
+dis_test "movq-->movq w/REX" main style2-with-r13 \
+    'main+0x4:  49 c7 c5 f0 ff ff  movq   $-0x10,%r13	<0xfffffffffffffff0>'
+
+dis_test "movq-->movq incase of SIB" main style2-with-r12 \
+    'main+0x4:  49 c7 c4 f0 ff ff  movq   $-0x10,%r12	<0xfffffffffffffff0>'
+
+make -f ${ELF_TESTS}/tests/tls/x64/ie/Makefile.test fail 2>&1 | grep_test "bad insn sequence" \
+   'ld: fatal: relocation error: R_AMD64_TPOFF32: file style2-with-badness.o: symbol foo: section .text: offset 0x7, relocation against unknown TLS instruction sequence'
--- /dev/null	2019-02-11 00:23:31.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x86/Makefile	2019-02-11 00:23:31.497741688 +0000
@@ -0,0 +1,19 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
+#
+
+SUBDIRS = ld
+
+include $(SRC)/test/Makefile.com
--- /dev/null	2019-02-11 00:23:31.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x86/ld/Makefile	2019-02-11 00:23:31.712675199 +0000
@@ -0,0 +1,51 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2018, Richard Lowe.
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROG =	x86-ld-test
+
+DATAFILES =		\
+	Makefile.test	\
+	half-ldm.s	\
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/tls/x86/ld
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+
+DATA = $(DATAFILES:%=$(TESTDIR)/%)
+$(DATA) := FILEMODE = 0444
+
+all: $(PROG)
+
+install: all $(CMDS) $(DATA)
+
+lint:
+
+clobber: clean
+	-$(RM) $(PROG)
+
+clean:
+	-$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+	$(INS.dir)
+
+$(TESTDIR)/%: %
+	$(INS.file)
--- /dev/null	2019-02-11 00:23:31.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x86/ld/Makefile.test	2019-02-11 00:23:31.949255887 +0000
@@ -0,0 +1,44 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2012, Richard Lowe.
+
+CC =		gcc
+CFLAGS =	-O1 -m32
+
+LINK.c =  $(CC) $(CFLAGS) -o $@ $^
+COMPILE.c = $(CC) $(CFLAGS) -c -o $@ $^
+COMPILE.s = $(CC) $(CFLAGS) -c -o $@ $^
+
+.KEEP_STATE:
+
+install default: all
+
+%.o: $(ELF_TESTS)/tests/tls/x86/ld/%.c
+	$(COMPILE.c)
+%.o: $(ELF_TESTS)/tests/tls/x86/ld/%.s
+	$(COMPILE.s)
+
+# an R_386_TLS_LDM with a regular R_386_PLT32 not a R_386_TLS_LDM_PLT
+PROGS +=	half-ldm
+
+half-ldm: half-ldm.o
+	$(LINK.c)
+
+all:	$(PROGS)
+
+clobber clean:
+	rm -f $(PROGS) $(STYLE1OBJS) $(STYLE1R13OBJS) $(STYLE1R12OBJS) \
+	    $(STYLE2OBJS) $(STYLE2R13OBJS) $(STYLE2R12OBJS) $(STYLE2BADNESSOBJS)
+
+fail: style2-with-badness FRC
+
+FRC:
--- /dev/null	2019-02-11 00:23:32.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x86/ld/half-ldm.s	2019-02-11 00:23:32.170267884 +0000
@@ -0,0 +1,49 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.u
+ */
+
+/*
+ * Copyright 2019, Richard Lowe.
+ */
+
+        .section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+        .string "foo: %s (%p)\n"
+        .section .tdata,"awT",@progbits
+        .align 4
+	.type foo, @object
+        .size foo,4
+.local foo
+foo:
+	.string	"foo"
+        .text
+.globl main
+        .type main, @function
+main:
+        pushl %ebp
+        movl %esp, %ebp
+	/*
+         * an R_386_TLS_LDM relocation without a following
+         * followed by an R_386_PLT32 relocation, rather than an
+	 * R_386_TLS_LDM_PLT the call should be removed, and _not_
+         * left alone unrelocated as it was prior to:
+         * 10267 ld and GCC disagree about i386 local dynamic TLS
+         */
+        leal foo@TLSLDM(%ebx), %eax
+        call ___tls_get_addr@PLT
+        leal  foo@DTPOFF(%eax), %edx
+        pushl %edx
+        pushl %edx
+        pushl $.LC0
+        call printf@PLT
+        movl $0x0,%eax
+        leave
+        ret
+	.size main, .-main
--- /dev/null	2019-02-11 00:23:32.000000000 +0000
+++ new/usr/src/test/elf-tests/tests/tls/x86/ld/x86-ld-test.sh	2019-02-11 00:23:32.371129059 +0000
@@ -0,0 +1,47 @@
+#!/bin/ksh
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2012, Richard Lowe.
+
+function grep_test {
+    name=$1
+    pattern=$2
+
+    if /usr/bin/grep -q "${pattern}"; then
+	print -u2 "pass: $name"
+        else
+        print -u2 "FAIL: $name"
+        exit 1
+    fi
+}
+
+function dis_test {
+    name=${1}
+    func=${2}
+    file=${3}
+    pattern=${4}
+
+    dis -F${func} ${file} | grep_test "${name}" "${pattern}"
+}
+
+if [[ -z $ELF_TESTS ]]; then
+    print -u2 "Don't know where the test data is rooted";
+    exit 1;
+fi
+
+make -f ${ELF_TESTS}/tests/tls/x86/ld/Makefile.test
+
+dis_test "call-->nop" main half-ldm \
+    'main\+0x9:  0f 1f 44 00 00     nopl   0x0(%eax,%eax)'
+
+./half-ldm | grep_test 'half-ldm execution' \
+    '^foo: foo ([a-f0-9]*)$'
