--- old/usr/src/Makefile.master	Thu Apr 25 02:20:38 2019
+++ new/usr/src/Makefile.master	Thu Apr 25 02:20:38 2019
@@ -967,7 +967,7 @@
 #
 # Default label for CTF sections
 #
-CTFCVTFLAGS=		-i -L VERSION
+CTFCVTFLAGS=		-L VERSION
 
 #
 # Override to pass module-specific flags to ctfmerge.  Currently used only by
@@ -990,11 +990,14 @@
 # Rules (normally from make.rules) and macros which are used for post
 # processing files. Normally, these do stripping of the comment section
 # automatically.
-#    RELEASE_CM:	Should be editted to reflect the release.
-#    POST_PROCESS_O:	Post-processing for `.o' files.
-#    POST_PROCESS_A:	Post-processing for `.a' files (currently null).
+#    RELEASE_CM:	Should be edited to reflect the release.
+#    POST_PROCESS_O:	Post-processing for `.o' files (typically C source)
+#    POST_PROCESS_S_O:	Post-processing for `.o' files built from asssembly
+#    POST_PROCESS_CC_O:	Post-processing for `.o' files built from C++
+#    POST_PROCESS_A:		Post-processing for `.a' files (currently null).
 #    POST_PROCESS_SO:	Post-processing for `.so' files.
 #    POST_PROCESS:	Post-processing for executable files (no suffix).
+#
 # Note that these macros are not completely generalized as they are to be
 # used with the file name to be processed following.
 #
@@ -1046,6 +1049,8 @@
 $(SRCDBGBLD)STRIP_STABS=	   :
 
 POST_PROCESS_O=
+POST_PROCESS_S_O=
+POST_PROCESS_CC_O=
 POST_PROCESS_A=
 POST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
 			$(ELFSIGN_OBJECT)
@@ -1091,7 +1096,7 @@
 	$(RM) $%
 .s.o:
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 .s.a:
 	$(COMPILE.s) -o $% $<
 	$(PROCESS_COMMENT) $%
@@ -1102,7 +1107,7 @@
 	$(POST_PROCESS)
 .cc.o:
 	$(COMPILE.cc) $(OUTPUT_OPTION) $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_CC_O)
 .cc.a:
 	$(COMPILE.cc) -o $% $<
 	$(AR) $(ARFLAGS) $@ $%
--- old/usr/src/cmd/ctfconvert/ctfconvert.c	Thu Apr 25 02:20:39 2019
+++ new/usr/src/cmd/ctfconvert/ctfconvert.c	Thu Apr 25 02:20:39 2019
@@ -10,7 +10,7 @@
  */
 
 /*
- * Copyright (c) 2015, Joyent, Inc.
+ * Copyright (c) 2019, Joyent, Inc.
  */
 
 /*
@@ -69,12 +69,13 @@
 		va_end(ap);
 	}
 
-	(void) fprintf(stderr, "Usage: %s [-is] [-j nthrs] [-l label | "
+	(void) fprintf(stderr, "Usage: %s [-ims] [-j nthrs] [-l label | "
 	    "-L labelenv] [-o outfile] input\n"
 	    "\n"
 	    "\t-i  ignore files not built partially from C sources\n"
 	    "\t-j  use nthrs threads to perform the merge\n"
 	    "\t-k  keep around original input file on failure\n"
+	    "\t-m  allow input to have missing debug info\n"
 	    "\t-o  copy input to outfile and add CTF\n"
 	    "\t-l  set output container's label to specified value\n"
 	    "\t-L  set output container's label to value from environment\n",
@@ -259,22 +260,17 @@
 	char *eptr;
 	char buf[4096];
 	boolean_t optx = B_FALSE;
+	boolean_t ignore_non_c = B_FALSE;
 
 	ctfconvert_progname = basename(argv[0]);
 
 	ctfconvert_altexec(argv);
 
-	while ((c = getopt(argc, argv, ":j:kl:L:o:iX")) != -1) {
+	while ((c = getopt(argc, argv, ":ij:kl:L:mo:X")) != -1) {
 		switch (c) {
-		case 'k':
-			keep = B_TRUE;
+		case 'i':
+			ignore_non_c = B_TRUE;
 			break;
-		case 'l':
-			label = optarg;
-			break;
-		case 'L':
-			label = getenv(optarg);
-			break;
 		case 'j':
 			errno = 0;
 			argj = strtol(optarg, &eptr, 10);
@@ -285,12 +281,21 @@
 			}
 			nthreads = (uint_t)argj;
 			break;
+		case 'k':
+			keep = B_TRUE;
+			break;
+		case 'l':
+			label = optarg;
+			break;
+		case 'L':
+			label = getenv(optarg);
+			break;
+		case 'm':
+			flags |= CTF_ALLOW_MISSING_DEBUG;
+			break;
 		case 'o':
 			outfile = optarg;
 			break;
-		case 'i':
-			flags |= CTF_CONVERT_F_IGNNONC;
-			break;
 		case 'X':
 			optx = B_TRUE;
 			break;
@@ -307,8 +312,8 @@
 	argv += optind;
 	argc -= optind;
 
-	if (argc < 1) {
-		ctfconvert_usage("Missing required input file\n");
+	if (argc != 1) {
+		ctfconvert_usage("Exactly one input file is required\n");
 		return (CTFCONVERT_USAGE);
 	}
 	infile = argv[0];
@@ -334,19 +339,32 @@
 	    sizeof (buf));
 	if (ofp == NULL) {
 		/*
-		 * -i says that we shouldn't concern ourselves with source files
-		 * that weren't built from C source code in part. Because this
-		 * has been traditionally used across all of illumos, we still
-		 * honor it.
+		 * Normally, ctfconvert requires that its input file has at
+		 * least one C-source compilation unit, and that every C-source
+		 * compilation unit has DWARF. This is to avoid accidentally
+		 * leaving out useful CTF.
+		 *
+		 * However, for the benefit of intransigent build environments,
+		 * the -i and -m options can be used to relax this.
 		 */
-		if ((flags & CTF_CONVERT_F_IGNNONC) != 0 &&
-		    err == ECTF_CONVNOCSRC) {
+		if (err == ECTF_CONVNOCSRC && ignore_non_c) {
 			exit(CTFCONVERT_OK);
 		}
+
+		if (err == ECTF_CONVNODEBUG &&
+		    (flags & CTF_ALLOW_MISSING_DEBUG) != 0) {
+			exit(CTFCONVERT_OK);
+		}
+
 		if (keep == B_FALSE)
 			(void) unlink(infile);
-		ctfconvert_fatal("CTF conversion failed: %s\n",
-		    err == ECTF_CONVBKERR ? buf : ctf_errmsg(err));
+
+		if (err == ECTF_CONVBKERR || err == ECTF_CONVNODEBUG) {
+			ctfconvert_fatal("%s", buf);
+		} else {
+			ctfconvert_fatal("CTF conversion failed: %s\n",
+			    ctf_errmsg(err));
+		}
 	}
 
 	if (optx == B_TRUE)
--- old/usr/src/cmd/ctfmerge/ctfmerge.c	Thu Apr 25 02:20:39 2019
+++ new/usr/src/cmd/ctfmerge/ctfmerge.c	Thu Apr 25 02:20:39 2019
@@ -10,7 +10,7 @@
  */
 
 /*
- * Copyright (c) 2017, Joyent, Inc.
+ * Copyright (c) 2019, Joyent, Inc.
  */
 
 /*
@@ -38,7 +38,6 @@
 static char *g_progname;
 static char *g_unique;
 static char *g_outfile;
-static boolean_t g_req;
 static uint_t g_nctf;
 
 #define	CTFMERGE_OK	0
@@ -64,65 +63,31 @@
 	exit(CTFMERGE_FATAL);
 }
 
-static boolean_t
-ctfmerge_expect_ctf(const char *name, Elf *elf)
+/*
+ * We failed to find CTF for this file, check if it's OK. If we're not derived
+ * from C, or we have the -m option, we let missing CTF pass.
+ */
+static void
+ctfmerge_check_for_c(const char *name, Elf *elf, uint_t flags)
 {
-	Elf_Scn *scn, *strscn;
-	Elf_Data *data, *strdata;
-	GElf_Shdr shdr;
-	ulong_t i;
+	char errmsg[1024];
 
-	if (g_req == B_FALSE)
-		return (B_FALSE);
+	if (flags & CTF_ALLOW_MISSING_DEBUG)
+		return;
 
-	scn = NULL;
-	while ((scn = elf_nextscn(elf, scn)) != NULL) {
-		if (gelf_getshdr(scn, &shdr) == NULL) {
-			ctfmerge_fatal("failed to get section header for file "
-			    "%s: %s\n", name, elf_errmsg(elf_errno()));
-		}
+	switch (ctf_has_c_source(elf, errmsg, sizeof (errmsg))) {
+	case CHR_ERROR:
+		ctfmerge_fatal("failed to open %s: %s\n", name, errmsg);
+		break;
 
-		if (shdr.sh_type == SHT_SYMTAB)
-			break;
-	}
+	case CHR_NO_C_SOURCE:
+		return;
 
-	if (scn == NULL)
-		return (B_FALSE);
-
-	if ((strscn = elf_getscn(elf, shdr.sh_link)) == NULL)
-		ctfmerge_fatal("failed to get section header for file %s: %s\n",
-		    name, elf_errmsg(elf_errno()));
-
-	if ((data = elf_getdata(scn, NULL)) == NULL)
-		ctfmerge_fatal("failed to read symbol table for %s: %s\n",
-		    name, elf_errmsg(elf_errno()));
-
-	if ((strdata = elf_getdata(strscn, NULL)) == NULL)
-		ctfmerge_fatal("failed to read string table for %s: %s\n",
-		    name, elf_errmsg(elf_errno()));
-
-	for (i = 0; i < shdr.sh_size / shdr.sh_entsize; i++) {
-		GElf_Sym sym;
-		const char *file;
-		size_t len;
-
-		if (gelf_getsym(data, i, &sym) == NULL)
-			ctfmerge_fatal("failed to read symbol table entry %lu "
-			    "for %s: %s\n", i, name, elf_errmsg(elf_errno()));
-
-		if (GELF_ST_TYPE(sym.st_info) != STT_FILE)
-			continue;
-
-		file = (const char *)((uintptr_t)strdata->d_buf + sym.st_name);
-		len = strlen(file);
-		if (len < 2 || name[len - 2] != '.')
-			continue;
-
-		if (name[len - 1] == 'c')
-			return (B_TRUE);
+	default:
+		ctfmerge_fatal("failed to open %s: %s\n", name,
+		    ctf_errmsg(ECTF_NOCTFDATA));
+		break;
 	}
-
-	return (B_FALSE);
 }
 
 /*
@@ -129,8 +94,8 @@
  * Go through and construct enough information for this Elf Object to try and do
  * a ctf_bufopen().
  */
-static void
-ctfmerge_elfopen(const char *name, Elf *elf, ctf_merge_t *cmh)
+static int
+ctfmerge_elfopen(const char *name, Elf *elf, ctf_merge_t *cmh, uint_t flags)
 {
 	GElf_Ehdr ehdr;
 	GElf_Shdr shdr;
@@ -214,10 +179,8 @@
 	}
 
 	if (ctfsect.cts_type == SHT_NULL) {
-		if (ctfmerge_expect_ctf(name, elf) == B_FALSE)
-			return;
-		ctfmerge_fatal("failed to open %s: %s\n", name,
-		    ctf_errmsg(ECTF_NOCTFDATA));
+		ctfmerge_check_for_c(name, elf, flags);
+		return (ENOENT);
 	}
 
 	if (symsect.cts_type != SHT_NULL && strsect.cts_type != SHT_NULL) {
@@ -227,36 +190,37 @@
 	}
 
 	if (fp == NULL) {
-		if (ctfmerge_expect_ctf(name, elf) == B_TRUE) {
-			ctfmerge_fatal("failed to open file %s: %s\n",
-			    name, ctf_errmsg(err));
-		}
-	} else {
-		if ((err = ctf_merge_add(cmh, fp)) != 0) {
-			ctfmerge_fatal("failed to add input %s: %s\n",
-			    name, ctf_errmsg(err));
-		}
-		g_nctf++;
+		ctfmerge_fatal("failed to open file %s: %s\n",
+		    name, ctf_errmsg(err));
 	}
+
+	if ((err = ctf_merge_add(cmh, fp)) != 0) {
+		ctfmerge_fatal("failed to add input %s: %s\n",
+		    name, ctf_errmsg(err));
+	}
+
+	g_nctf++;
+	return (0);
 }
 
 static void
 ctfmerge_read_archive(const char *name, int fd, Elf *elf,
-    ctf_merge_t *cmh)
+    ctf_merge_t *cmh, uint_t flags)
 {
-	Elf *aelf;
 	Elf_Cmd cmd = ELF_C_READ;
 	int cursec = 1;
-	char *nname;
+	Elf *aelf;
 
 	while ((aelf = elf_begin(fd, cmd, elf)) != NULL) {
+		char *nname = NULL;
 		Elf_Arhdr *arhdr;
-		boolean_t leakelf = B_FALSE;
 
 		if ((arhdr = elf_getarhdr(aelf)) == NULL)
 			ctfmerge_fatal("failed to get archive header %d for "
 			    "%s: %s\n", cursec, name, elf_errmsg(elf_errno()));
 
+		cmd = elf_next(aelf);
+
 		if (*(arhdr->ar_name) == '/')
 			goto next;
 
@@ -267,28 +231,64 @@
 
 		switch (elf_kind(aelf)) {
 		case ELF_K_AR:
-			ctfmerge_read_archive(nname, fd, aelf, cmh);
-			free(nname);
+			ctfmerge_read_archive(nname, fd, aelf, cmh, flags);
 			break;
 		case ELF_K_ELF:
-			ctfmerge_elfopen(nname, aelf, cmh);
-			free(nname);
-			leakelf = B_TRUE;
+			/* ctfmerge_elfopen() takes ownership of aelf. */
+			if (ctfmerge_elfopen(nname, aelf, cmh, flags) == 0)
+				aelf = NULL;
 			break;
 		default:
 			ctfmerge_fatal("unknown elf kind (%d) in archive %d "
 			    "for %s\n", elf_kind(aelf), cursec, name);
+			break;
 		}
 
 next:
-		cmd = elf_next(aelf);
-		if (leakelf == B_FALSE)
-			(void) elf_end(aelf);
+		(void) elf_end(aelf);
+		free(nname);
 		cursec++;
 	}
 }
 
 static void
+ctfmerge_file_add(ctf_merge_t *cmh, const char *file, uint_t flags)
+{
+	Elf *e;
+	int fd;
+
+	if ((fd = open(file, O_RDONLY)) < 0) {
+		ctfmerge_fatal("failed to open file %s: %s\n",
+		    file, strerror(errno));
+	}
+
+	if ((e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
+		(void) close(fd);
+		ctfmerge_fatal("failed to open %s: %s\n",
+		    file, elf_errmsg(elf_errno()));
+	}
+
+	switch (elf_kind(e)) {
+	case ELF_K_AR:
+		ctfmerge_read_archive(file, fd, e, cmh, flags);
+		break;
+
+	case ELF_K_ELF:
+		/* ctfmerge_elfopen() takes ownership of e. */
+		if (ctfmerge_elfopen(file, e, cmh, flags) == 0)
+			e = NULL;
+		break;
+
+	default:
+		ctfmerge_fatal("unknown elf kind (%d) for %s\n",
+		    elf_kind(e), file);
+	}
+
+	(void) elf_end(e);
+	(void) close(fd);
+}
+
+static void
 ctfmerge_usage(const char *fmt, ...)
 {
 	if (fmt != NULL) {
@@ -300,7 +300,7 @@
 		va_end(ap);
 	}
 
-	(void) fprintf(stderr, "Usage: %s [-t] [-d uniqfile] [-l label] "
+	(void) fprintf(stderr, "Usage: %s [-m] [-d uniqfile] [-l label] "
 	    "[-L labelenv] [-j nthrs] -o outfile file ...\n"
 	    "\n"
 	    "\t-d  uniquify merged output against uniqfile\n"
@@ -307,8 +307,8 @@
 	    "\t-j  use nthrs threads to perform the merge\n"
 	    "\t-l  set output container's label to specified value\n"
 	    "\t-L  set output container's label to value from environment\n"
-	    "\t-o  file to add CTF data to\n"
-	    "\t-t  require CTF data from all inputs built from C sources\n",
+	    "\t-m  allow C-based input files to not have CTF\n"
+	    "\t-o  file to add CTF data to\n",
 	    g_progname);
 }
 
@@ -341,8 +341,9 @@
 	uint_t nthreads = CTFMERGE_DEFAULT_NTHREADS;
 	char *tmpfile = NULL, *label = NULL;
 	int wflags = CTF_ELFWRITE_F_COMPRESS;
-	ctf_file_t *ofp;
+	uint_t flags = 0;
 	ctf_merge_t *cmh;
+	ctf_file_t *ofp;
 	long argj;
 	char *eptr;
 
@@ -352,9 +353,9 @@
 
 	/*
 	 * We support a subset of the old CTF merge flags, mostly for
-	 * compatability.
+	 * compatibility.
 	 */
-	while ((c = getopt(argc, argv, ":d:fgj:l:L:o:t")) != -1) {
+	while ((c = getopt(argc, argv, ":d:fgj:l:L:mo:t")) != -1) {
 		switch (c) {
 		case 'd':
 			g_unique = optarg;
@@ -381,11 +382,14 @@
 		case 'L':
 			label = getenv(optarg);
 			break;
+		case 'm':
+			flags |= CTF_ALLOW_MISSING_DEBUG;
+			break;
 		case 'o':
 			g_outfile = optarg;
 			break;
 		case 't':
-			g_req = B_TRUE;
+			/* Silently ignored for compatibility */
 			break;
 		case ':':
 			ctfmerge_usage("Option -%c requires an operand\n",
@@ -430,58 +434,7 @@
 		    nthreads, ctf_errmsg(err));
 
 	for (i = 0; i < argc; i++) {
-		ctf_file_t *ifp;
-		int fd;
-
-		if ((fd = open(argv[i], O_RDONLY)) < 0)
-			ctfmerge_fatal("failed to open file %s: %s\n",
-			    argv[i], strerror(errno));
-		ifp = ctf_fdopen(fd, &err);
-		if (ifp == NULL) {
-			Elf *e;
-
-			if ((e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
-				(void) close(fd);
-				ctfmerge_fatal("failed to open %s: %s\n",
-				    argv[i], ctf_errmsg(err));
-			}
-
-			/*
-			 * It's an ELF file, check if we have an archive or if
-			 * we're expecting CTF here.
-			 */
-			switch (elf_kind(e)) {
-			case ELF_K_AR:
-				break;
-			case ELF_K_ELF:
-				if (ctfmerge_expect_ctf(argv[i], e) == B_TRUE) {
-					(void) elf_end(e);
-					(void) close(fd);
-					ctfmerge_fatal("failed to "
-					    "open %s: file was built from C "
-					    "sources, but missing CTF\n",
-					    argv[i]);
-				}
-				(void) elf_end(e);
-				(void) close(fd);
-				continue;
-			default:
-				(void) elf_end(e);
-				(void) close(fd);
-				ctfmerge_fatal("failed to open %s: "
-				    "unsupported ELF file type", argv[i]);
-			}
-
-			ctfmerge_read_archive(argv[i], fd, e, cmh);
-			(void) elf_end(e);
-			(void) close(fd);
-			continue;
-		}
-		(void) close(fd);
-		if ((err = ctf_merge_add(cmh, ifp)) != 0)
-			ctfmerge_fatal("failed to add input %s: %s\n",
-			    argv[i], ctf_errmsg(err));
-		g_nctf++;
+		ctfmerge_file_add(cmh, argv[i], flags);
 	}
 
 	if (g_nctf == 0) {
--- old/usr/src/cmd/mdb/Makefile.module	Thu Apr 25 02:20:39 2019
+++ new/usr/src/cmd/mdb/Makefile.module	Thu Apr 25 02:20:39 2019
@@ -23,9 +23,9 @@
 # Use is subject to license terms.
 #
 # Copyright (c) 2013 by Delphix. All rights reserved.
-# Copyright (c) 2018, Joyent, Inc.
 # Copyright (c) 2019 Carlos Neira <cneirabustos@gmail.com>
 # Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
+# Copyright (c) 2019, Joyent, Inc.
 #
 
 .KEEP_STATE:
@@ -234,7 +234,6 @@
 
 dmod/%.o kmod%.o: %.s
 	$(COMPILE.s) -o $@ $<
-	$(CTFCONVERT_O)
 
 dmod/%.o kmod/%.o: ../%.c
 	$(COMPILE.c) -o $@ $<
@@ -242,7 +241,6 @@
 
 dmod/%.o kmod%.o: ../%.s
 	$(COMPILE.s) -o $@ $<
-	$(CTFCONVERT_O)
 
 dmod/%.o kmod/%.o: ../../../common/modules/$(MODNAME)/%.c
 	$(COMPILE.c) -o $@ $<
@@ -250,7 +248,6 @@
 
 dmod/%.o kmod%.o: ../../../common/modules/$(MODNAME)/%.s
 	$(COMPILE.s) -o $@ $<
-	$(CTFCONVERT_O)
 
 dmod/%.o kmod/%.o: $$(MODSRCS_DIR)/%.c
 	$(COMPILE.c) -o $@ $<
@@ -258,7 +255,6 @@
 
 dmod/%.o kmod%.o: $$(MODSRCS_DIR)/%.s
 	$(COMPILE.s) -o $@ $<
-	$(CTFCONVERT_O)
 
 #
 # Lint
--- old/usr/src/cmd/mdb/common/modules/genunix/Makefile.files	Thu Apr 25 02:20:40 2019
+++ new/usr/src/cmd/mdb/common/modules/genunix/Makefile.files	Thu Apr 25 02:20:40 2019
@@ -21,7 +21,7 @@
 #
 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2016 Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 # Copyright (c) 2013 by Delphix. All rights reserved.
 #
 
@@ -48,7 +48,6 @@
 	findstack.c	\
 	findstack_subr.c \
 	fm.c		\
-	gcore.c		\
 	gcore_isadep.c	\
 	genunix.c	\
 	group.c		\
--- old/usr/src/cmd/mdb/intel/amd64/genunix/Makefile	Thu Apr 25 02:20:40 2019
+++ new/usr/src/cmd/mdb/intel/amd64/genunix/Makefile	Thu Apr 25 02:20:40 2019
@@ -26,6 +26,8 @@
 #
 # Copyright (c) 2013 by Delphix. All rights reserved.
 #
+# Copyright (c) 2019, Joyent, Inc.
+#
 
 MODULE = genunix.so
 MDBTGT = kvm
@@ -40,6 +42,7 @@
 
 MODSRCS = \
 	$(COMMONSRCS) \
+	gcore.c \
 	typegraph.c
 
 #
--- old/usr/src/cmd/sgs/rtld/Makefile.targ	Thu Apr 25 02:20:40 2019
+++ new/usr/src/cmd/sgs/rtld/Makefile.targ	Thu Apr 25 02:20:40 2019
@@ -25,6 +25,8 @@
 #
 # Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
 #
+# Copyright (c) 2019, Joyent, Inc.
+#
 
 # Don't generate separate sections for this module
 pics/debugdata.o :=	XFFLAG=
@@ -34,11 +36,11 @@
 
 pics/%.o:	%.s
 		$(BUILD.s)
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
 
 pics/%.o:	$(CRTSRCS)/%.s
 		$(BUILD.s)
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
 
 pics/%.o:	%.c
 		$(COMPILE.c) -o $@ $<
--- old/usr/src/common/ctf/ctf_error.c	Thu Apr 25 02:20:40 2019
+++ new/usr/src/common/ctf/ctf_error.c	Thu Apr 25 02:20:40 2019
@@ -24,7 +24,7 @@
  * Use is subject to license terms.
  */
 /*
- * Copyright (c) 2015, Joyent, Inc.
+ * Copyright (c) 2019, Joyent, Inc.
  */
 
 #include <ctf_impl.h>
@@ -83,7 +83,7 @@
 	"Zlib library failure",				 /* ECTF_ZLIB */
 	"CTF conversion backend error",			 /* ECTF_CONVBKERR */
 	"No C source to convert from",			 /* ECTF_CONVNOCSRC */
-	"No applicable conversion backend"		 /* ECTF_NOCONVBKEND */
+	"No debug info found to convert from"		 /* ECTF_CONVNODEBUG */
 };
 
 static const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]);
--- old/usr/src/lib/Makefile.lib	Thu Apr 25 02:20:41 2019
+++ new/usr/src/lib/Makefile.lib	Thu Apr 25 02:20:41 2019
@@ -22,7 +22,7 @@
 # Copyright 2015 Gary Mills
 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2015, Joyent, Inc.
+# Copyright 2019, Joyent, Inc.
 #
 #
 # Definitions common to libraries.
@@ -212,7 +212,7 @@
 
 objs/%.o pics/%.o: %.cc
 	$(COMPILE.cc) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_CC_O)
 
 .PRECIOUS: $(LIBS)
 
--- old/usr/src/lib/Makefile.targ	Thu Apr 25 02:20:41 2019
+++ new/usr/src/lib/Makefile.targ	Thu Apr 25 02:20:41 2019
@@ -20,6 +20,7 @@
 #
 #
 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2019, Joyent, Inc.
 #
 
 #
@@ -47,11 +48,11 @@
 $(ROOTLIBDIR)/%: %
 	$(INS.file)
 $(ROOTLIBDIR64)/%: %
-	$(INS.file)	
+	$(INS.file)
 $(ROOTFS_LIBDIR)/%: %
 	$(INS.file)
 $(ROOTFS_LIBDIR64)/%: %
-	$(INS.file)	
+	$(INS.file)
 
 $(ROOTLIBDIR)/$(LIBLINKS): $(ROOTLIBDIR)/$(LIBLINKS)$(VERS)
 	$(INS.liblink)
@@ -79,7 +80,7 @@
 
 objs/%.o pics/%.o: $(SRCDIR)/%.cc
 	$(COMPILE.cc) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_CC_O)
 
 objs pics:
 	-@mkdir -p $@
@@ -98,7 +99,7 @@
 	$(BUILDCCC.SO)
 	$(POST_PROCESS_SO)
 
-$(LINTLIB): $$(SRCS) 
+$(LINTLIB): $$(SRCS)
 	$(LINT.c) -o $(LIBNAME) $(SRCS) > $(LINTOUT) 2>&1
 
 lintcheck: $$(SRCS)
--- old/usr/src/lib/brand/shared/brand/Makefile.com	Thu Apr 25 02:20:41 2019
+++ new/usr/src/lib/brand/shared/brand/Makefile.com	Thu Apr 25 02:20:41 2019
@@ -23,6 +23,8 @@
 #
 # Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
 #
+# Copyright (c) 2019, Joyent, Inc.
+#
 
 COBJS =		brand_util.o
 ASOBJS =	crt.o handler.o runexe.o
@@ -74,6 +76,6 @@
 
 pics/%.o: $(ISASRCDIR)/%.s
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 include $(SRC)/lib/Makefile.targ
--- old/usr/src/lib/commpage/Makefile.shared.targ	Thu Apr 25 02:20:42 2019
+++ new/usr/src/lib/commpage/Makefile.shared.targ	Thu Apr 25 02:20:42 2019
@@ -10,7 +10,7 @@
 #
 
 #
-# Copyright 2016 Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 #
 
 #
@@ -23,7 +23,7 @@
 
 pics/%.o: $(SRC)/lib/commpage/$(TARGET_ARCH)/%.s $(COMMPAGE_OFFSETS_H)
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 $(COMMPAGE_OFFSETS_H): $(COMMPAGE_OFFSETS_SRC)
 	$(OFFSETS_CREATE) <$(COMMPAGE_OFFSETS_SRC) >$@
--- old/usr/src/lib/libc/Makefile.targ	Thu Apr 25 02:20:42 2019
+++ new/usr/src/lib/libc/Makefile.targ	Thu Apr 25 02:20:42 2019
@@ -21,8 +21,8 @@
 #
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
-# Copyright 2016 Joyent, Inc.
 #
+# Copyright (c) 2019, Joyent, Inc.
 #
 
 # libc build rules
@@ -32,7 +32,7 @@
 #
 pics/%.o: $(OPTIMIZED_LIBCBASE)/gen/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/crt/%.c
 	$(COMPILE.c) -o $@ $<
@@ -40,7 +40,7 @@
 
 pics/%.o: $(LIBCBASE)/crt/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/gen/%.c
 	$(COMPILE.c) -o $@ $<
@@ -48,15 +48,15 @@
 
 pics/%.o: $(LIBCBASE)/gen/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/gen/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/_stack_grow.o: $(LIBCBASE)/../$(TARGET_ARCH)/gen/_stack_grow.s
 	$(BUILD.s) $(LIBCBASE)/../$(TARGET_ARCH)/gen/_stack_grow.s
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/fp/%.c
 	$(COMPILE.c) -o $@ $<
@@ -68,7 +68,7 @@
 
 pics/%.o: $(LIBCBASE)/fp/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/fp/%.c
 	$(COMPILE.c) -o $@ $<
@@ -76,7 +76,7 @@
 
 pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/fp/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/sys/%.c
 	$(COMPILE.c) -o $@ $<
@@ -84,15 +84,15 @@
 
 pics/%.o: $(LIBCBASE)/../common/sys/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/sys/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/../$(MACH)/sys/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/../$(MACH)/sys/%.c
 	$(COMPILE.c) -o $@ $<
@@ -104,17 +104,17 @@
 
 pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/sys/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 # rules to build large file aware objects (xxx64.o from xxx.s or xxx.c)
 
 pics/%64.o: $(LIBCBASE)/../common/sys/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%64.o: $(LIBCBASE)/sys/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%64.o: $(LIBCBASE)/gen/%.c
 	$(COMPILE.c) -o $@ $<
@@ -245,7 +245,7 @@
 
 pics/%.o: $(LIBCBASE)/threads/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/threads/%.c
 	$(COMPILE.c) -o $@ $<
@@ -253,7 +253,7 @@
 
 pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/threads/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/unwind/%.c
 	$(COMPILE.c) -o $@ $<
@@ -261,7 +261,7 @@
 
 pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/unwind/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/../port/unwind/%.c
 	$(COMPILE.c) -o $@ $<
@@ -269,7 +269,7 @@
 
 pics/%.o: $(LIBCBASE)/../$(MACH)/unwind/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(LIBCBASE)/../port/sys/%.c
 	$(COMPILE.c) -o $@ $<
@@ -281,12 +281,12 @@
 
 pics/%.o: $(LIBCBASE)/$(CRTSRCS)/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 # $(SRC)/common rules
 pics/%.o: $(SRC)/common/atomic/$(TARGETMACH)/%.s
 	$(BUILD.s)
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 $(COMOBJS:%=pics/%): $(SRC)/common/util/$$(@F:.o=.c)
 	$(COMPILE.c) -o $@ $(SRC)/common/util/$(@F:.o=.c)
--- old/usr/src/lib/libc/capabilities/Makefile.targ	Thu Apr 25 02:20:42 2019
+++ new/usr/src/lib/libc/capabilities/Makefile.targ	Thu Apr 25 02:20:42 2019
@@ -22,6 +22,8 @@
 #
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 #
+# Copyright (c) 2019, Joyent, Inc.
+#
 
 $(SYMCAP):	$(OBJCAP)
 $(OBJCAP):	$(PICS)
@@ -31,11 +33,11 @@
 
 pics/%.o:	../../$(TRG_PLATFORM)/common/%.s
 		$(COMPILE.s) $< -o $@
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
 
 pics/%.o:	../../$(ALT_PLATFORM)/common/%.s
 		$(COMPILE.s) $< -o $@
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
 
 # Combine all pic objects into one relocatable object.  Assign any capabilities
 # to this object, and define the interface.
--- old/usr/src/lib/libc_db/Makefile.com	Thu Apr 25 02:20:42 2019
+++ new/usr/src/lib/libc_db/Makefile.com	Thu Apr 25 02:20:42 2019
@@ -22,7 +22,7 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 
 LIBRARY = libc_db.a
 VERS = .1
@@ -63,4 +63,4 @@
 
 pics/%.o: $(CRTSRCS)/%.s
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
--- old/usr/src/lib/libcpc/Makefile.com	Thu Apr 25 02:20:43 2019
+++ new/usr/src/lib/libcpc/Makefile.com	Thu Apr 25 02:20:43 2019
@@ -21,7 +21,7 @@
 #
 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
 #
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 
 LIBRARY = libcpc.a
 VERS	= .1
@@ -31,7 +31,7 @@
 
 include ../../Makefile.lib
 
-SRCS = 	$(ASOBJS:%.o=../$(MACH)/%.s)	\
+SRCS =	$(ASOBJS:%.o=../$(MACH)/%.s)	\
 	$(MACHCOBJS:%.o=../$(MACH)/%.c)	\
 	$(V1_OBJS:%.o=../common/%.c)	\
 	$(COBJS:%.o=../common/%.c)
@@ -66,4 +66,4 @@
 
 pics/%.o: ../$(MACH)/%.s
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
--- old/usr/src/lib/libctf/common/ctf_convert.c	Thu Apr 25 02:20:43 2019
+++ new/usr/src/lib/libctf/common/ctf_convert.c	Thu Apr 25 02:20:43 2019
@@ -21,6 +21,7 @@
  */
 
 #include <libctf_impl.h>
+#include <assert.h>
 #include <gelf.h>
 
 ctf_convert_f ctf_converters[] = {
@@ -29,42 +30,48 @@
 
 #define	NCONVERTS	(sizeof (ctf_converters) / sizeof (ctf_convert_f))
 
-typedef enum ctf_convert_source {
-	CTFCONV_SOURCE_NONE = 0x0,
-	CTFCONV_SOURCE_UNKNOWN = 0x01,
-	CTFCONV_SOURCE_C = 0x02,
-	CTFCONV_SOURCE_S = 0x04
-} ctf_convert_source_t;
-
-static void
-ctf_convert_ftypes(Elf *elf, ctf_convert_source_t *types)
+ctf_hsc_ret_t
+ctf_has_c_source(Elf *elf, char *errmsg, size_t errlen)
 {
-	int i;
-	Elf_Scn *scn = NULL, *strscn;
-	*types = CTFCONV_SOURCE_NONE;
-	GElf_Shdr shdr;
+	ctf_hsc_ret_t ret = CHR_NO_C_SOURCE;
+	Elf_Scn *scn, *strscn;
 	Elf_Data *data, *strdata;
+	GElf_Shdr shdr;
+	ulong_t i;
 
+	scn = NULL;
 	while ((scn = elf_nextscn(elf, scn)) != NULL) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
+			(void) snprintf(errmsg, errlen,
+			    "failed to get section header: %s",
+			    elf_errmsg(elf_errno()));
+			return (CHR_ERROR);
+		}
 
-		if (gelf_getshdr(scn, &shdr) == NULL)
-			return;
-
 		if (shdr.sh_type == SHT_SYMTAB)
 			break;
 	}
 
 	if (scn == NULL)
-		return;
+		return (CHR_NO_C_SOURCE);
 
-	if ((strscn = elf_getscn(elf, shdr.sh_link)) == NULL)
-		return;
+	if ((strscn = elf_getscn(elf, shdr.sh_link)) == NULL) {
+		(void) snprintf(errmsg, errlen, "failed to get str section: %s",
+		    elf_errmsg(elf_errno()));
+		return (CHR_ERROR);
+	}
 
-	if ((data = elf_getdata(scn, NULL)) == NULL)
-		return;
+	if ((data = elf_getdata(scn, NULL)) == NULL) {
+		(void) snprintf(errmsg, errlen, "failed to read section: %s",
+		    elf_errmsg(elf_errno()));
+		return (CHR_ERROR);
+	}
 
-	if ((strdata = elf_getdata(strscn, NULL)) == NULL)
-		return;
+	if ((strdata = elf_getdata(strscn, NULL)) == NULL) {
+		(void) snprintf(errmsg, errlen,
+		    "failed to read string table: %s", elf_errmsg(elf_errno()));
+		return (CHR_ERROR);
+	}
 
 	for (i = 0; i < shdr.sh_size / shdr.sh_entsize; i++) {
 		GElf_Sym sym;
@@ -71,8 +78,12 @@
 		const char *file;
 		size_t len;
 
-		if (gelf_getsym(data, i, &sym) == NULL)
-			return;
+		if (gelf_getsym(data, i, &sym) == NULL) {
+			(void) snprintf(errmsg, errlen,
+			    "failed to read sym %lu: %s",
+			    i, elf_errmsg(elf_errno()));
+			return (CHR_ERROR);
+		}
 
 		if (GELF_ST_TYPE(sym.st_info) != STT_FILE)
 			continue;
@@ -79,26 +90,13 @@
 
 		file = (const char *)((uintptr_t)strdata->d_buf + sym.st_name);
 		len = strlen(file);
-		if (len < 2 || file[len - 2] != '.') {
-			*types |= CTFCONV_SOURCE_UNKNOWN;
-			continue;
-		}
-
-		switch (file[len - 1]) {
-		case 'c':
-			*types |= CTFCONV_SOURCE_C;
+		if (len >= 2 && strncmp(".c", &file[len - 2], 2) == 0) {
+			ret = CHR_HAS_C_SOURCE;
 			break;
-		case 'h':
-			/* We traditionally ignore header files... */
-			break;
-		case 's':
-			*types |= CTFCONV_SOURCE_S;
-			break;
-		default:
-			*types |= CTFCONV_SOURCE_UNKNOWN;
-			break;
 		}
 	}
+
+	return (ret);
 }
 
 static ctf_file_t *
@@ -107,8 +105,6 @@
 {
 	int err, i;
 	ctf_file_t *fp = NULL;
-	boolean_t notsup = B_TRUE;
-	ctf_convert_source_t type;
 
 	if (errp == NULL)
 		errp = &err;
@@ -118,7 +114,7 @@
 		return (NULL);
 	}
 
-	if (flags & ~CTF_CONVERT_F_IGNNONC) {
+	if (flags & ~CTF_ALLOW_MISSING_DEBUG) {
 		*errp = EINVAL;
 		return (NULL);
 	}
@@ -128,47 +124,35 @@
 		return (NULL);
 	}
 
-	ctf_convert_ftypes(elf, &type);
-	ctf_dprintf("got types: %d\n", type);
-	if (flags & CTF_CONVERT_F_IGNNONC) {
-		if (type == CTFCONV_SOURCE_NONE ||
-		    (type & CTFCONV_SOURCE_UNKNOWN)) {
-			*errp = ECTF_CONVNOCSRC;
-			return (NULL);
-		}
+	switch (ctf_has_c_source(elf, errbuf, errlen)) {
+	case CHR_ERROR:
+		*errp = ECTF_ELF;
+		return (NULL);
+
+	case CHR_NO_C_SOURCE:
+		*errp = ECTF_CONVNOCSRC;
+		return (NULL);
+
+	default:
+		break;
 	}
 
 	for (i = 0; i < NCONVERTS; i++) {
-		ctf_conv_status_t cs;
-
 		fp = NULL;
-		cs = ctf_converters[i](fd, elf, nthrs, errp, &fp, errbuf,
-		    errlen);
-		if (cs == CTF_CONV_SUCCESS) {
-			notsup = B_FALSE;
+		err = ctf_converters[i](fd, elf, nthrs, flags,
+		    &fp, errbuf, errlen);
+
+		if (err != ECTF_CONVNODEBUG)
 			break;
-		}
-		if (cs == CTF_CONV_ERROR) {
-			fp = NULL;
-			notsup = B_FALSE;
-			break;
-		}
 	}
 
-	if (notsup == B_TRUE) {
-		if ((flags & CTF_CONVERT_F_IGNNONC) != 0 &&
-		    (type & CTFCONV_SOURCE_C) == 0) {
-			*errp = ECTF_CONVNOCSRC;
-			return (NULL);
-		}
-		*errp = ECTF_NOCONVBKEND;
+	if (err != 0) {
+		assert(fp == NULL);
+		*errp = err;
 		return (NULL);
 	}
 
-	/*
-	 * Succsesful conversion.
-	 */
-	if (fp != NULL && label != NULL) {
+	if (label != NULL) {
 		if (ctf_add_label(fp, label, fp->ctf_typemax, 0) == CTF_ERR) {
 			*errp = ctf_errno(fp);
 			ctf_close(fp);
--- old/usr/src/lib/libctf/common/ctf_dwarf.c	Thu Apr 25 02:20:43 2019
+++ new/usr/src/lib/libctf/common/ctf_dwarf.c	Thu Apr 25 02:20:43 2019
@@ -883,7 +883,7 @@
 		break;
 	default:
 		(void) snprintf(cup->cu_errbuf, cup->cu_errlen,
-		    "encountered unkown DWARF encoding: %d", type);
+		    "encountered unknown DWARF encoding: %d", type);
 		return (ECTF_CONVBKERR);
 	}
 
@@ -1778,6 +1778,7 @@
 		break;
 	default:
 		ctf_dprintf("ignoring tag type %x\n", tag);
+		*idp = CTF_ERR;
 		ret = 0;
 		break;
 	}
@@ -2677,7 +2678,8 @@
 	}
 
 	ctf_dprintf("Trying to clean up dwarf_t: %p\n", cup->cu_dwarf);
-	(void) dwarf_finish(cup->cu_dwarf, &derr);
+	if (cup->cu_dwarf != NULL)
+		(void) dwarf_finish(cup->cu_dwarf, &derr);
 	cup->cu_dwarf = NULL;
 	ctf_close(cup->cu_ctfp);
 
@@ -2727,13 +2729,6 @@
 		*ndies = *ndies + 1;
 	}
 
-	if (*ndies == 0) {
-		(void) snprintf(errbuf, errlen,
-		    "file does not contain valid DWARF data: %s\n",
-		    dwarf_errmsg(*derr));
-		return (ECTF_CONVBKERR);
-	}
-
 	return (0);
 }
 
@@ -2769,10 +2764,9 @@
 		cup->cu_elf = elf;
 		cup->cu_maxoff = nexthdr - 1;
 		cup->cu_ctfp = ctf_fdcreate(fd, &ret);
-		if (cup->cu_ctfp == NULL) {
-			ctf_free(cup, sizeof (ctf_cu_t));
+		if (cup->cu_ctfp == NULL)
 			return (ret);
-		}
+
 		avl_create(&cup->cu_map, ctf_dwmap_comp, sizeof (ctf_dwmap_t),
 		    offsetof(ctf_dwmap_t, cdm_avl));
 		cup->cu_errbuf = errbuf;
@@ -2782,46 +2776,32 @@
 		bzero(&cup->cu_bitfields, sizeof (ctf_list_t));
 
 		if ((ret = ctf_dwarf_die_elfenc(elf, cup, errbuf,
-		    errlen)) != 0) {
-			avl_destroy(&cup->cu_map);
-			ctf_free(cup, sizeof (ctf_cu_t));
+		    errlen)) != 0)
 			return (ret);
-		}
 
-		if ((ret = ctf_dwarf_sib(cup, NULL, &cu)) != 0) {
-			avl_destroy(&cup->cu_map);
-			ctf_free(cup, sizeof (ctf_cu_t));
+		if ((ret = ctf_dwarf_sib(cup, NULL, &cu)) != 0)
 			return (ret);
-		}
+
 		if (cu == NULL) {
 			(void) snprintf(errbuf, errlen,
-			    "file does not contain DWARF data\n");
-			avl_destroy(&cup->cu_map);
-			ctf_free(cup, sizeof (ctf_cu_t));
-			return (ECTF_CONVBKERR);
+			    "file does not contain DWARF data");
+			return (ECTF_CONVNODEBUG);
 		}
 
-		if ((ret = ctf_dwarf_child(cup, cu, &child)) != 0) {
-			avl_destroy(&cup->cu_map);
-			ctf_free(cup, sizeof (ctf_cu_t));
+		if ((ret = ctf_dwarf_child(cup, cu, &child)) != 0)
 			return (ret);
-		}
+
 		if (child == NULL) {
 			(void) snprintf(errbuf, errlen,
-			    "file does not contain DWARF data\n");
-			avl_destroy(&cup->cu_map);
-			ctf_free(cup, sizeof (ctf_cu_t));
-			return (ECTF_CONVBKERR);
+			    "file does not contain DWARF data");
+			return (ECTF_CONVNODEBUG);
 		}
 
 		cup->cu_cuoff = offset;
 		cup->cu_cu = child;
 
-		if ((cup->cu_cmh = ctf_merge_init(fd, &ret)) == NULL) {
-			avl_destroy(&cup->cu_map);
-			ctf_free(cup, sizeof (ctf_cu_t));
+		if ((cup->cu_cmh = ctf_merge_init(fd, &ret)) == NULL)
 			return (ret);
-		}
 
 		if (ctf_dwarf_string(cup, cu, DW_AT_name, &name) == 0) {
 			size_t len = strlen(name) + 1;
@@ -2835,11 +2815,123 @@
 	return (0);
 }
 
+/*
+ * This is our only recourse to identify a C source file that is missing debug
+ * info: it will be mentioned as an STT_FILE, but not have a compile unit entry.
+ * (A traditional ctfmerge works on individual files, so can identify missing
+ * DWARF more directly, via ctf_has_c_source() on the .o file.)
+ *
+ * As we operate on basenames, this can of course miss some cases, but it's
+ * better than not checking at all.
+ *
+ * We explicitly whitelist some CRT components.  Failing that, there's always
+ * the -m option.
+ */
+static boolean_t
+c_source_has_debug(const char *file, ctf_cu_t *cus, size_t nr_cus)
+{
+	const char *basename = strrchr(file, '/');
 
-ctf_conv_status_t
-ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, int *errp, ctf_file_t **fpp,
+	if (basename == NULL)
+		basename = file;
+	else
+		basename++;
+
+	if (strcmp(basename, "common-crt.c") == 0 ||
+	    strcmp(basename, "gmon.c") == 0 ||
+	    strcmp(basename, "dlink_init.c") == 0 ||
+	    strcmp(basename, "dlink_common.c") == 0 ||
+	    strncmp(basename, "crt", strlen("crt")) == 0 ||
+	    strncmp(basename, "values-", strlen("values-")) == 0)
+		return (B_TRUE);
+
+	for (size_t i = 0; i < nr_cus; i++) {
+		if (strcmp(basename, cus[i].cu_name) == 0)
+			return (B_TRUE);
+	}
+
+	return (B_FALSE);
+}
+
+static int
+ctf_dwarf_check_missing(ctf_cu_t *cus, size_t nr_cus, Elf *elf,
     char *errmsg, size_t errlen)
 {
+	Elf_Scn *scn, *strscn;
+	Elf_Data *data, *strdata;
+	GElf_Shdr shdr;
+	ulong_t i;
+
+	scn = NULL;
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
+			(void) snprintf(errmsg, errlen,
+			    "failed to get section header: %s\n",
+			    elf_errmsg(elf_errno()));
+			return (EINVAL);
+		}
+
+		if (shdr.sh_type == SHT_SYMTAB)
+			break;
+	}
+
+	if (scn == NULL)
+		return (0);
+
+	if ((strscn = elf_getscn(elf, shdr.sh_link)) == NULL) {
+		(void) snprintf(errmsg, errlen,
+		    "failed to get str section: %s\n",
+		    elf_errmsg(elf_errno()));
+		return (EINVAL);
+	}
+
+	if ((data = elf_getdata(scn, NULL)) == NULL) {
+		(void) snprintf(errmsg, errlen, "failed to read section: %s\n",
+		    elf_errmsg(elf_errno()));
+		return (EINVAL);
+	}
+
+	if ((strdata = elf_getdata(strscn, NULL)) == NULL) {
+		(void) snprintf(errmsg, errlen,
+		    "failed to read string table: %s\n",
+		    elf_errmsg(elf_errno()));
+		return (EINVAL);
+	}
+
+	for (i = 0; i < shdr.sh_size / shdr.sh_entsize; i++) {
+		GElf_Sym sym;
+		const char *file;
+		size_t len;
+
+		if (gelf_getsym(data, i, &sym) == NULL) {
+			(void) snprintf(errmsg, errlen,
+			    "failed to read sym %lu: %s\n",
+			    i, elf_errmsg(elf_errno()));
+			return (EINVAL);
+		}
+
+		if (GELF_ST_TYPE(sym.st_info) != STT_FILE)
+			continue;
+
+		file = (const char *)((uintptr_t)strdata->d_buf + sym.st_name);
+		len = strlen(file);
+		if (len < 2 || strncmp(".c", &file[len - 2], 2) != 0)
+			continue;
+
+		if (!c_source_has_debug(file, cus, nr_cus)) {
+			(void) snprintf(errmsg, errlen,
+			    "file %s is missing debug info\n", file);
+			return (ECTF_CONVNODEBUG);
+		}
+	}
+
+	return (0);
+}
+
+int
+ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, uint_t flags,
+    ctf_file_t **fpp, char *errbuf, size_t errlen)
+{
 	int err, ret, ndies, i;
 	Dwarf_Debug dw;
 	Dwarf_Error derr;
@@ -2846,30 +2938,20 @@
 	ctf_cu_t *cdies = NULL, *cup;
 	workq_t *wqp = NULL;
 
-	if (errp == NULL)
-		errp = &err;
-	*errp = 0;
 	*fpp = NULL;
 
 	ret = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &dw, &derr);
 	if (ret != DW_DLV_OK) {
-		/*
-		 * We may want to expect DWARF data here and fail conversion if
-		 * it's missing. In this case, if we actually have some amount
-		 * of DWARF, but no section, for now, just go ahead and create
-		 * an empty CTF file.
-		 */
 		if (ret == DW_DLV_NO_ENTRY ||
 		    dwarf_errno(derr) == DW_DLE_DEBUG_INFO_NULL) {
-			*fpp = ctf_create(errp);
-			return (*fpp != NULL ? CTF_CONV_SUCCESS :
-			    CTF_CONV_ERROR);
+			(void) snprintf(errbuf, errlen,
+			    "file does not contain DWARF data\n");
+			return (ECTF_CONVNODEBUG);
 		}
-		(void) snprintf(errmsg, errlen,
-		    "failed to initialize DWARF: %s\n",
-		    dwarf_errmsg(derr));
-		*errp = ECTF_CONVBKERR;
-		return (CTF_CONV_ERROR);
+
+		(void) snprintf(errbuf, errlen,
+		    "dwarf_elf_init() failed: %s\n", dwarf_errmsg(derr));
+		return (ECTF_CONVBKERR);
 	}
 
 	/*
@@ -2880,19 +2962,24 @@
 	 * only a single Dwarf_Debug as well.
 	 */
 	ndies = 0;
-	ret = ctf_dwarf_count_dies(dw, &derr, &ndies, errmsg, errlen);
-	if (ret != 0) {
-		*errp = ret;
-		goto out;
+	err = ctf_dwarf_count_dies(dw, &derr, &ndies, errbuf, errlen);
+
+	ctf_dprintf("found %d DWARF CUs\n", ndies);
+
+	if (ndies == 0) {
+		(void) snprintf(errbuf, errlen,
+		    "file does not contain DWARF data\n");
+		return (ECTF_CONVNODEBUG);
 	}
 
 	(void) dwarf_finish(dw, &derr);
 	cdies = ctf_alloc(sizeof (ctf_cu_t) * ndies);
 	if (cdies == NULL) {
-		*errp = ENOMEM;
-		return (CTF_CONV_ERROR);
+		return (ENOMEM);
 	}
 
+	bzero(cdies, sizeof (ctf_cu_t) * ndies);
+
 	for (i = 0; i < ndies; i++) {
 		cup = &cdies[i];
 		ret = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL,
@@ -2899,23 +2986,23 @@
 		    &cup->cu_dwarf, &derr);
 		if (ret != 0) {
 			ctf_free(cdies, sizeof (ctf_cu_t) * ndies);
-			(void) snprintf(errmsg, errlen,
+			(void) snprintf(errbuf, errlen,
 			    "failed to initialize DWARF: %s\n",
 			    dwarf_errmsg(derr));
-			*errp = ECTF_CONVBKERR;
-			return (CTF_CONV_ERROR);
+			return (ECTF_CONVBKERR);
 		}
 
-		ret = ctf_dwarf_init_die(fd, elf, &cdies[i], i, errmsg, errlen);
-		if (ret != 0) {
-			*errp = ret;
+		err = ctf_dwarf_init_die(fd, elf, cup, i, errbuf, errlen);
+		if (err != 0)
 			goto out;
-		}
 
 		cup->cu_doweaks = ndies > 1 ? B_FALSE : B_TRUE;
 	}
 
-	ctf_dprintf("found %d DWARF CUs\n", ndies);
+	if (!(flags & CTF_ALLOW_MISSING_DEBUG) &&
+	    (err = ctf_dwarf_check_missing(cdies, ndies,
+	    elf, errbuf, errlen)) != 0)
+		goto out;
 
 	/*
 	 * If we only have one compilation unit, there's no reason to use
@@ -2926,7 +3013,7 @@
 		nthrs = 1;
 
 	if (workq_init(&wqp, nthrs) == -1) {
-		*errp = errno;
+		err = errno;
 		goto out;
 	}
 
@@ -2935,18 +3022,18 @@
 		ctf_dprintf("adding cu %s: %p, %x %x\n", cup->cu_name,
 		    cup->cu_cu, cup->cu_cuoff, cup->cu_maxoff);
 		if (workq_add(wqp, cup) == -1) {
-			*errp = errno;
+			err = errno;
 			goto out;
 		}
 	}
 
-	ret = workq_work(wqp, ctf_dwarf_convert_one, NULL, errp);
+	ret = workq_work(wqp, ctf_dwarf_convert_one, NULL, &err);
 	if (ret == WORKQ_ERROR) {
-		*errp = errno;
+		err = errno;
 		goto out;
 	} else if (ret == WORKQ_UERROR) {
 		ctf_dprintf("internal convert failed: %s\n",
-		    ctf_errmsg(*errp));
+		    ctf_errmsg(err));
 		goto out;
 	}
 
@@ -2954,44 +3041,37 @@
 	if (ndies != 1) {
 		ctf_merge_t *cmp;
 
-		cmp = ctf_merge_init(fd, &ret);
-		if (cmp == NULL) {
-			*errp = ret;
+		cmp = ctf_merge_init(fd, &err);
+		if (cmp == NULL)
 			goto out;
-		}
 
 		ctf_dprintf("setting threads\n");
-		if ((ret = ctf_merge_set_nthreads(cmp, nthrs)) != 0) {
+		if ((err = ctf_merge_set_nthreads(cmp, nthrs)) != 0) {
 			ctf_merge_fini(cmp);
-			*errp = ret;
 			goto out;
 		}
 
 		for (i = 0; i < ndies; i++) {
 			cup = &cdies[i];
-			ctf_dprintf("adding cu %s (%p)\n", cup->cu_name,
-			    cup->cu_ctfp);
-			if ((ret = ctf_merge_add(cmp, cup->cu_ctfp)) != 0) {
+			if ((err = ctf_merge_add(cmp, cup->cu_ctfp)) != 0) {
 				ctf_merge_fini(cmp);
-				*errp = ret;
 				goto out;
 			}
 		}
 
 		ctf_dprintf("performing merge\n");
-		ret = ctf_merge_merge(cmp, fpp);
-		if (ret != 0) {
+		err = ctf_merge_merge(cmp, fpp);
+		if (err != 0) {
 			ctf_dprintf("failed merge!\n");
 			*fpp = NULL;
 			ctf_merge_fini(cmp);
-			*errp = ret;
 			goto out;
 		}
 		ctf_merge_fini(cmp);
-		*errp = 0;
+		err = 0;
 		ctf_dprintf("successfully converted!\n");
 	} else {
-		*errp = 0;
+		err = 0;
 		*fpp = cdies->cu_ctfp;
 		cdies->cu_ctfp = NULL;
 		ctf_dprintf("successfully converted!\n");
@@ -3000,5 +3080,5 @@
 out:
 	workq_fini(wqp);
 	ctf_dwarf_free_dies(cdies, ndies);
-	return (*fpp != NULL ? CTF_CONV_SUCCESS : CTF_CONV_ERROR);
+	return (err);
 }
--- old/usr/src/lib/libctf/common/libctf.h	Thu Apr 25 02:20:44 2019
+++ new/usr/src/lib/libctf/common/libctf.h	Thu Apr 25 02:20:44 2019
@@ -24,7 +24,7 @@
  * Use is subject to license terms.
  */
 /*
- * Copyright (c) 2015, Joyent, Inc.
+ * Copyright (c) 2019, Joyent, Inc.
  */
 
 /*
@@ -44,6 +44,7 @@
 #define	_LIBCTF_H
 
 #include <sys/ctf_api.h>
+#include <libelf.h>
 
 #ifdef	__cplusplus
 extern "C" {
@@ -74,10 +75,23 @@
 extern int ctf_diff_objects(ctf_diff_t *, ctf_diff_obj_f, void *);
 extern void ctf_diff_fini(ctf_diff_t *);
 
-#define	CTF_CONVERT_F_IGNNONC	0x01
+/*
+ * Normally, we return a failure if we find a C-derived compilation unit that
+ * lacks DWARF or CTF (as required).  This flag over-rides this check.
+ */
+#define	CTF_ALLOW_MISSING_DEBUG	0x01
+
 extern ctf_file_t *ctf_fdconvert(int, const char *, uint_t, uint_t, int *,
     char *, size_t);
 
+typedef enum ctf_hsc_ret {
+	CHR_ERROR = -1,
+	CHR_NO_C_SOURCE = 0,
+	CHR_HAS_C_SOURCE = 1
+} ctf_hsc_ret_t;
+
+extern ctf_hsc_ret_t ctf_has_c_source(Elf *, char *, size_t);
+
 typedef struct ctf_merge_handle ctf_merge_t;
 extern ctf_merge_t *ctf_merge_init(int, int *);
 extern int ctf_merge_add(ctf_merge_t *, ctf_file_t *);
--- old/usr/src/lib/libctf/common/libctf_impl.h	Thu Apr 25 02:20:44 2019
+++ new/usr/src/lib/libctf/common/libctf_impl.h	Thu Apr 25 02:20:44 2019
@@ -29,15 +29,9 @@
 extern "C" {
 #endif
 
-typedef enum ctf_conv_status {
-	CTF_CONV_SUCCESS	= 0,
-	CTF_CONV_ERROR		= 1,
-	CTF_CONV_NOTSUP		= 2
-} ctf_conv_status_t;
-
-typedef ctf_conv_status_t (*ctf_convert_f)(int, Elf *, uint_t, int *,
+typedef int (*ctf_convert_f)(int, Elf *, uint_t, uint_t,
     ctf_file_t **, char *, size_t);
-extern ctf_conv_status_t ctf_dwarf_convert(int, Elf *, uint_t, int *,
+extern int ctf_dwarf_convert(int, Elf *, uint_t, uint_t,
     ctf_file_t **, char *, size_t);
 
 /*
--- old/usr/src/lib/libctf/common/mapfile-vers	Thu Apr 25 02:20:44 2019
+++ new/usr/src/lib/libctf/common/mapfile-vers	Thu Apr 25 02:20:44 2019
@@ -23,7 +23,7 @@
 #
 
 #
-# Copyright 2018 Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
 #
 
 #
@@ -86,6 +86,7 @@
 	ctf_func_args_by_id;
 	ctf_func_info_by_id;
 	ctf_function_iter;
+	ctf_has_c_source;
 	ctf_kind_name;
 	ctf_label_info;
 	ctf_label_iter;
--- old/usr/src/lib/libfru/Makefile.targ	Thu Apr 25 02:20:44 2019
+++ new/usr/src/lib/libfru/Makefile.targ	Thu Apr 25 02:20:45 2019
@@ -23,10 +23,8 @@
 # Copyright (c) 2000 by Sun Microsystems, Inc.
 # All rights reserved.
 #
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
+# Copyright (c) 2019, Joyent, Inc.
 #
-# lib/libfru/Makefile.targ
-#
 
 include ../../Makefile.targ
 
@@ -33,15 +31,15 @@
 # build rules for pics.  (access sub directories)
 pics/%.o objs/%.o:	../libfru/%.cc
 	$(COMPILE.cc) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_CC_O)
 
 pics/%.o objs/%.o:	../libfrureg/%.cc
 	$(COMPILE.cc) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_CC_O)
 
 pics/%.o objs/%.o:	../libgenutil/%.cc
 	$(COMPILE.cc) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_CC_O)
 
 # some special rules for the yacc and lex parser.  (with sub directories)
 pics/y.tab.cc pics/y.tab.h: ../libfru/nameSyntaxYacc.y
--- old/usr/src/lib/libm/Makefile.targ	Thu Apr 25 02:20:45 2019
+++ new/usr/src/lib/libm/Makefile.targ	Thu Apr 25 02:20:45 2019
@@ -12,10 +12,12 @@
 #
 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 #
+# Copyright (c) 2019, Joyent, Inc.
+#
 
 pics/%.o: $(LIBMDIR)/$(TARGETMACH)/src/%.$(ASSUFFIX)
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: $(SRCDIR)/C/%.c $(LM_IL)
 	$(COMPILE.c) -o $@ $<
--- old/usr/src/lib/libmvec/Makefile.com	Thu Apr 25 02:20:45 2019
+++ new/usr/src/lib/libmvec/Makefile.com	Thu Apr 25 02:20:45 2019
@@ -12,6 +12,8 @@
 #
 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 #
+# Copyright (c) 2019, Joyent, Inc.
+#
 
 LIBMDIR		= $(SRC)/lib/libm
 
@@ -159,7 +161,7 @@
 SRCDIR		= ../common/
 DYNFLAGS	+= $(ZIGNORE)
 
-LINTERROFF	= -erroff=E_FP_DIVISION_BY_ZERO 
+LINTERROFF	= -erroff=E_FP_DIVISION_BY_ZERO
 LINTERROFF	+= -erroff=E_FP_INVALID
 LINTERROFF	+= -erroff=E_BAD_PTR_CAST_ALIGN
 LINTERROFF	+= -erroff=E_ASSIGMENT_CAUSE_LOSS_PREC
@@ -274,8 +276,8 @@
 
 pics/%.o: ../$(TARGET_ARCH)/src/%.S
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 pics/%.o: ../common/$$(CHIP)/%.S
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
--- old/usr/src/lib/libnisdb/Makefile	Thu Apr 25 02:20:45 2019
+++ new/usr/src/lib/libnisdb/Makefile	Thu Apr 25 02:20:45 2019
@@ -23,7 +23,7 @@
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 
 LIBRARY= libnisdb.a
 VERS=	.2
@@ -204,14 +204,6 @@
 
 lint: $(DERIVED_FILES) .WAIT lintcheck
 
-pics/%.o: %.c
-	$(COMPILE.c) -o $@ $<
-	$(POST_PROCESS_O)
-
-pics/%.o: %.cc
-	$(COMPILE.cc) -o $@ $<
-	$(POST_PROCESS_O)
-
 objs/%.o pics/%.o profs/%.o: $(YPTOL_DIR)/%.c
 	$(COMPILE.c) -o $@ $<
 	$(POST_PROCESS_O)
--- old/usr/src/lib/libsqlite/Makefile.com	Thu Apr 25 02:20:45 2019
+++ new/usr/src/lib/libsqlite/Makefile.com	Thu Apr 25 02:20:46 2019
@@ -3,7 +3,7 @@
 # Use is subject to license terms.
 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
 # Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 # Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
 #
 
@@ -158,6 +158,8 @@
 
 $(OBJS) :=		CFLAGS += $(CTF_FLAGS)
 $(OBJS) :=		CTFCONVERT_POST = $(CTFCONVERT_O)
+$(NATIVEOBJS) :=	CFLAGS += $(CTF_FLAGS)
+$(NATIVEOBJS) :=	CTFCONVERT_POST = $(CTFCONVERT_O)
 
 TCLBASE = /usr/sfw
 TCLVERS = tcl8.3
--- old/usr/src/lib/libtnfctl/Makefile.com	Thu Apr 25 02:20:46 2019
+++ new/usr/src/lib/libtnfctl/Makefile.com	Thu Apr 25 02:20:46 2019
@@ -22,7 +22,7 @@
 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 
 LIBRARY=	libtnfctl.a
 VERS=		.1
@@ -107,7 +107,7 @@
 
 objs/%.o pics/%.o: ../%.s
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 objs/%.o pics/%.o: ../%.c
 	$(COMPILE.c) -o $@ $<
--- old/usr/src/lib/libtnfprobe/Makefile.com	Thu Apr 25 02:20:46 2019
+++ new/usr/src/lib/libtnfprobe/Makefile.com	Thu Apr 25 02:20:46 2019
@@ -21,7 +21,7 @@
 #
 # Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
 #
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 
 LIBRARY=	libtnfprobe.a
 VERS=		.1
@@ -97,7 +97,7 @@
 
 objs/%.o pics/%.o: ../%.s
 		$(COMPILE.s) -o $@ $<
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
 
 pics/%.o objs/%.o: ../%.c
 		$(COMPILE.c) -o $@ $<
--- old/usr/src/lib/libumem/Makefile.targ	Thu Apr 25 02:20:46 2019
+++ new/usr/src/lib/libumem/Makefile.targ	Thu Apr 25 02:20:46 2019
@@ -22,6 +22,7 @@
 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
+# Copyright (c) 2019, Joyent, Inc.
 #
 
 #
@@ -74,7 +75,7 @@
 
 objs/%.o pics/%.o: $(ISASRCDIR)/%.s
 	$(COMPILE.s) -o $@ $<
-	$(POST_PROCESS_O)
+	$(POST_PROCESS_S_O)
 
 objs/%.o pics/%.o: ../common/%.c
 	$(COMPILE.c) -o $@ $<
--- old/usr/src/lib/pkcs11/libsoftcrypto/amd64/Makefile	Thu Apr 25 02:20:47 2019
+++ new/usr/src/lib/pkcs11/libsoftcrypto/amd64/Makefile	Thu Apr 25 02:20:47 2019
@@ -22,9 +22,8 @@
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2017 Jason King
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 #
-# Copyright (c) 2018, Joyent, Inc.
 
 LIBRARY =	libsoftcrypto.a
 VERS =		.1
@@ -87,7 +86,7 @@
 
 pics/%.o: $(AES_DIR)/$(MACH64)/%.s
 		$(COMPILE.s) $(AES_FLAGS) -o $@ $<
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
 
 pics/%.o: $(BIGNUM_DIR)/$(MACH64)/%.c
 		$(COMPILE.c) $(BIGNUM_FLAGS) -o $@ $<
@@ -95,11 +94,11 @@
 
 pics/%.o: $(BIGNUM_DIR)/$(MACH64)/%.s
 		$(COMPILE64.s) $(BIGNUM_FLAGS) -o $@ $<
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
 
 pics/%.o: $(MODES_DIR)/$(MACH64)/%.s
 		$(COMPILE64.s) $(MODES_FLAGS) -o $@ $<
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
 
 include		../Makefile.targ
 
@@ -108,4 +107,4 @@
 
 pics/%.o: arcfour-x86_64.s
 		$(COMPILE64.s) $(ARCFOUR_FLAGS) -o $@ $<
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
--- old/usr/src/lib/pkcs11/libsoftcrypto/capabilities/intel/i386/Makefile	Thu Apr 25 02:20:47 2019
+++ new/usr/src/lib/pkcs11/libsoftcrypto/capabilities/intel/i386/Makefile	Thu Apr 25 02:20:47 2019
@@ -22,6 +22,8 @@
 #
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 #
+# Copyright (c) 2019, Joyent, Inc.
+#
 
 BIGNUM_PSM_OBJS =	bignum_i386.o bignum_i386_asm.o
 
@@ -53,4 +55,4 @@
 
 pics/bignum_i386_asm.o: $(BIGNUM_DIR)/i386/bignum_i386_asm.s
 		$(COMPILE.s) -o $@ $(BIGNUM_DIR)/i386/bignum_i386_asm.s
-		$(POST_PROCESS_O)
+		$(POST_PROCESS_S_O)
--- old/usr/src/test/crypto-tests/tests/common/Makefile	Thu Apr 25 02:20:47 2019
+++ new/usr/src/test/crypto-tests/tests/common/Makefile	Thu Apr 25 02:20:47 2019
@@ -12,9 +12,11 @@
 #
 # Copyright (c) 2012 by Delphix. All rights reserved.
 # Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+# Copyright (c) 2019, Joyent, Inc.
 #
 
 include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/cmd/Makefile.ctf
 include $(SRC)/test/Makefile.com
 
 OBJS = testfuncs.o cryptotest_pkcs.o cryptotest_kcf.o
@@ -26,6 +28,7 @@
 
 %.o: %.c
 	$(COMPILE.c) -o $@ $<
+	$(POST_PROCESS_O)
 
 lint:
 
--- old/usr/src/test/util-tests/runfiles/default.run	Thu Apr 25 02:20:47 2019
+++ new/usr/src/test/util-tests/runfiles/default.run	Thu Apr 25 02:20:47 2019
@@ -13,7 +13,7 @@
 # Copyright (c) 2012 by Delphix. All rights reserved.
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
 # Copyright 2014 Nexenta Systems, Inc. All rights reserved.
-# Copyright 2017 Joyent, Inc.
+# Copyright 2019, Joyent, Inc.
 #
 
 [DEFAULT]
@@ -45,3 +45,7 @@
 
 [/opt/util-tests/tests/demangle]
 tests = ['afl-fast', 'gcc-libstdc++', 'llvm-stdcxxabi']
+
+[/opt/util-tests/tests/ctf]
+pre = precheck
+tests = [ 'ctftest' ]
--- old/usr/src/test/util-tests/tests/ctf/Makefile	Thu Apr 25 02:20:48 2019
+++ new/usr/src/test/util-tests/tests/ctf/Makefile	Thu Apr 25 02:20:48 2019
@@ -18,7 +18,11 @@
 ROOTOPTPKG = $(ROOT)/opt/util-tests
 TESTDIR = $(ROOTOPTPKG)/tests/ctf
 
-SCRIPTS =	ctftest.ksh
+SCRIPTS =	precheck.ksh \
+		ctftest.ksh \
+		ctftest-convert-non-c.ksh \
+		ctftest-convert-no-dwarf.ksh \
+		ctftest-merge-no-ctf.ksh \
 
 TESTS =		test-float.c \
 		test-reference.c \
--- /dev/null	Thu Apr 25 02:20:48 2019
+++ new/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh	Thu Apr 25 02:20:48 2019
@@ -0,0 +1,141 @@
+#!/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 (c) 2019, Joyent, Inc.
+#
+
+set -e
+
+result=0
+
+progname=$(basename $0)
+
+fail()
+{
+	echo "Failed: $*" 2>&1
+	result=1
+}
+
+fail_no_debug()
+{
+	cmd="$@"
+	set +e
+	out=$($ctf_convert $cmd 2>&1)
+
+	if [[ $? -eq 0 ]]; then
+		fail "$cmd succeeded but should have failed"
+		set -e
+		return;
+	fi
+
+	set -e
+
+	if echo "$out" | grep "is missing debug info" >/dev/null; then
+		return;
+	fi
+
+	if echo "$out" | grep "does not contain DWARF data" >/dev/null; then
+		return;
+	fi
+	fail "$cmd: incorrect output $out"
+}
+
+has_ctf()
+{
+	for f in "$@"; do
+		if ! elfdump -c -N .SUNW_ctf "$f" |
+		    grep '.SUNW_ctf' >/dev/null; then
+			fail "$f lacks CTF section"
+			return
+		fi
+	done
+}
+
+cat <<EOF >file1.c
+#include <stdio.h>
+struct foo { int a; };
+int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); }
+EOF
+
+cat <<EOF >file2.c
+#include <stdio.h>
+char myfunc(int a) { printf("%d\n", a); }
+EOF
+
+cat <<EOF >file3.cc
+struct bar { char *tar; };
+void mycxxfunc(char *c) { c[0] = '9'; };
+EOF
+
+cat <<EOF >file4.s
+.globl caller
+.type caller,@function
+caller:
+	movl 4(%ebp), %eax
+	ret
+EOF
+
+echo "$progname: An empty file should fail conversion due to no DWARF"
+echo >emptyfile.c
+
+$ctf_cc -c -o emptyfile.o emptyfile.c
+fail_no_debug emptyfile.o
+$ctf_cc -c -o emptyfile.o emptyfile.c
+$ctf_convert -m emptyfile.o
+
+$ctf_cc $ctf_debugflags -c -o emptyfile.o emptyfile.c
+fail_no_debug emptyfile.o
+$ctf_cc $ctf_debugflags -c -o emptyfile.o emptyfile.c
+$ctf_convert -m emptyfile.o
+
+echo "$progname: A file missing DWARF should fail conversion"
+
+$ctf_cc -c -o file1.o file1.c
+fail_no_debug file1.o
+$ctf_cc -c -o file1.o file1.c
+$ctf_convert -m file1.o
+
+echo "$progname: A binary with DWARF but 0 debug dies should fail conversion"
+
+$ctf_cc -o mybin file1.c
+fail_no_debug mybin
+$ctf_cc -o mybin file1.c
+$ctf_convert -m mybin
+
+echo "$progname: One C file missing DWARF should fail ctfconvert"
+
+$ctf_cc -c -o file1.o file1.c
+$ctf_cc $ctf_debugflags -c -o file2.o file2.c
+ld -r -o files.o file2.o file1.o
+fail_no_debug files.o
+ld -r -o files.o file2.o file1.o
+$ctf_convert -m files.o
+has_ctf files.o
+
+echo "$progname: One .cc file missing DWARF should pass"
+
+$ctf_cc $ctf_debugflags -c -o file1.o file1.c
+$ctf_cc $ctf_debugflags -c -o file2.o file2.c
+$ctf_cxx -c -o file3.o file3.cc
+ld -r -o files.o file1.o file2.o file3.o
+$ctf_convert files.o
+has_ctf files.o
+
+echo "$progname: One .s file missing DWARF should pass"
+$ctf_cc $ctf_debugflags -c -o file1.o file1.c
+$ctf_cc $ctf_debugflags -c -o file2.o file2.c
+$ctf_as -o file4.o file4.s
+$ctf_cc -o mybin file1.o file2.o file4.o
+$ctf_convert mybin
+has_ctf mybin
+
+echo "result is $result"
+exit $result
--- /dev/null	Thu Apr 25 02:20:48 2019
+++ new/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh	Thu Apr 25 02:20:48 2019
@@ -0,0 +1,97 @@
+#!/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 (c) 2019, Joyent, Inc.
+#
+
+set -e
+
+result=0
+
+progname=$(basename $0)
+
+fail()
+{
+	echo "Failed: $*" 2>&1
+	result=1
+}
+
+fail_non_c()
+{
+	cmd="$@"
+	set +e
+	out=$($ctf_convert $cmd 2>&1)
+
+	if [[ $? -eq 0 ]]; then
+		fail "$cmd succeeded but should have failed"
+		set -e
+		return;
+	fi
+
+	set -e
+
+	if ! echo "$out" | \
+	    grep "No C source to convert from" >/dev/null; then
+		fail "$cmd: incorrect output $out"
+		return;
+	fi
+}
+
+no_ctf()
+{
+	for f in "$@"; do
+		if elfdump -c -N .SUNW_ctf "$f" |
+		    grep '.SUNW_ctf' >/dev/null; then
+			fail "$f has CTF section"
+			return
+		fi
+	done
+}
+
+cat <<EOF >file1.c
+#include <stdio.h>
+struct foo { int a; };
+int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); }
+EOF
+
+cat <<EOF >file2.cc
+struct bar { char *tar; };
+void mycxxfunc(char *c) { c[0] = '9'; };
+EOF
+
+cat <<EOF >file3.s
+.globl caller
+.type caller,@function
+caller:
+	movl 4(%ebp), %eax
+	ret
+EOF
+
+echo "$progname: ctfconvert should fail on a .cc-derived object"
+$ctf_cxx -c -o file2.o file2.cc
+fail_non_c file2.o
+$ctf_cxx -c -o file2.o file2.cc
+$ctf_convert -i file2.o
+
+echo "$progname: ctfconvert shouldn't process .cc-derived DWARF"
+$ctf_cc $DEBUGFLAGS -c -o file2.o file2.cc
+$ctf_convert -i file2.o
+no_ctf file2.o
+
+echo "$progname: ctfconvert should fail on a .s-derived object"
+$ctf_as -o file3.o file3.s
+fail_non_c file3.o
+$ctf_as -o file3.o file3.s
+$ctf_convert -i file3.o
+no_ctf file3.o
+
+echo "result is $result"
+exit $result
--- /dev/null	Thu Apr 25 02:20:48 2019
+++ new/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh	Thu Apr 25 02:20:48 2019
@@ -0,0 +1,117 @@
+#!/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 (c) 2019, Joyent, Inc.
+#
+
+set -e
+
+result=0
+
+progname=$(basename $0)
+
+fail()
+{
+	echo "Failed: $*" 2>&1
+	result=1
+}
+
+fail_no_ctf()
+{
+	cmd="$@"
+	set +e
+	out=$($cmd 2>&1)
+
+	if [[ $? -eq 0 ]]; then
+		fail "$cmd succeeded but should have failed"
+		set -e
+		return;
+	fi
+
+	set -e
+
+	if ! echo "$out" | \
+	    grep "File does not contain CTF data" >/dev/null; then
+		fail "$cmd: incorrect output $out"
+		return;
+	fi
+}
+
+has_ctf()
+{
+	for f in "$@"; do
+		if ! elfdump -c -N .SUNW_ctf "$f" |
+		    grep '.SUNW_ctf' >/dev/null; then
+			fail "$f lacks CTF section"
+			return
+		fi
+	done
+}
+
+cat <<EOF >file1.c
+#include <stdio.h>
+struct foo { int a; };
+struct foo foos[400];
+int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); }
+EOF
+
+cat <<EOF >file2.c
+#include <stdio.h>
+struct foo { char b; float c; };
+struct foo stuff[90];
+char myfunc(int a) { printf("%d\n", a); }
+EOF
+
+cat <<EOF >file3.cc
+struct bar { char *tar; };
+void mycxxfunc(char *c) { c[0] = '9'; };
+EOF
+
+cat <<EOF >file4.s
+.globl caller
+.type caller,@function
+caller:
+	movl 4(%ebp), %eax
+	ret
+EOF
+
+echo "$progname: ctfmerge should fail if one C-source lacks CTF"
+
+$ctf_cc $ctf_debugflags -c -o file1.o file1.c
+$ctf_convert file1.o
+$ctf_cc -c -o file2.o file2.c
+ld -r -o files.o file2.o file1.o
+fail_no_ctf $ctf_merge -o files.o file2.o file1.o
+ld -r -o files.o file2.o file1.o
+$ctf_merge -m -o files.o file2.o file1.o
+has_ctf files.o
+$ctf_cc -o mybin file2.o file1.o
+fail_no_ctf $ctf_merge -o mybin file2.o file1.o
+$ctf_cc -o mybin file2.o file1.o
+$ctf_merge -m -o mybin file2.o file1.o
+
+
+echo "$progname: ctfmerge should allow a .cc file to lack CTF"
+$ctf_cxx -c -o file3.o file3.cc
+ld -r -o files.o file1.o file3.o
+$ctf_merge -o files.o file1.o file3.o
+ld -r -o files.o file1.o file3.o
+$ctf_merge -m -o files.o file1.o file3.o
+
+echo "$progname: ctfmerge should allow an .s file to lack CTF"
+$ctf_as -o file4.o file4.s
+ld -r -o files.o file4.o file1.o
+$ctf_merge -o files.o file4.o file1.o
+ld -r -o files.o file4.o file1.o
+$ctf_merge -m -o files.o file4.o file1.o
+
+echo "result is $result"
+exit $result
--- old/usr/src/test/util-tests/tests/ctf/ctftest.ksh	Thu Apr 25 02:20:48 2019
+++ new/usr/src/test/util-tests/tests/ctf/ctftest.ksh	Thu Apr 25 02:20:48 2019
@@ -26,17 +26,18 @@
 	TMPDIR="/tmp"
 fi
 
+
 ctf_arg0=$(basename $0)
 ctf_root=$(cd $(dirname $0) && echo $PWD)
 ctf_tests=
-ctf_compiler="gcc"
+ctf_cc="gcc"
+ctf_cxx="g++"
+ctf_as="as"
 ctf_convert="ctfconvert"
 ctf_merge="ctfmerge"
 ctf_debugflags="-gdwarf-2 "
 ctf_mach32="-m32"
 ctf_mach64="-m64"
-ctf_32cflags="$ctf_mach32 $ctf_debugflags"
-ctf_64cflags="$ctf_mach64 $ctf_debugflags"
 ctf_temp="$TMPDIR/ctftest.$$.o"
 ctf_makefile="Makefile.ctftest"
 ctf_nerrs=0
@@ -46,18 +47,19 @@
 	typeset msg="$*"
 	[[ -z "$msg" ]] || echo "$msg" >&2
 	cat <<USAGE >&2
-Usage: $ctf_arg0  [-c compiler] [-g flags] [-m ctfmerge] [-t ctfconvert]
+Usage: $ctf_arg0 [-a as] [-c cc] [-C CC] [-g flags] [-m ctfmerge] [-t ctfconvert]
 
 	Runs the CTF test suite
 
-	-c compiler		Use the specified compiler, defaults to 'gcc'
-				on path.
+	-a assembler		Use the specified assembler, defaults to 'as'
+	-c compiler		Use the specified C compiler, defaults to 'gcc'
+	-C compiler		Use the specified C++ compiler, defaults to 'g++'
 	-g flags		Use flags to generate debug info. Defaults to
 				"-gdwarf-2".
 	-m ctfmerge		Use the specified ctfmerge, defaults to
-				'ctfmerge' on path.
+				'ctfmerge'
 	-t ctfconvert		Use the specified ctfconvert, defaults to
-				'ctfconvert' on path.
+				'ctfconvert'
 USAGE
 	exit 2
 }
@@ -80,22 +82,15 @@
 	exit 1
 }
 
-check_env()
-{
-	if which "$1" 2>/dev/null >/dev/null; then
-		return
-	fi
-
-	[[ -f "$1" ]] || fatal "failed to find tool $1"
-}
-
 announce()
 {
 	cat << EOF
 Beginning CTF tests with the following settings:
-COMPILER:	$(which $ctf_compiler)
-CTFCONVERT:	$(which $ctf_convert)
-CTFMERGE:	$(which $ctf_merge)
+cc:		$(which $ctf_cc)
+CC:		$(which $ctf_cxx)
+as:		$(which $ctf_as)
+ctfconvert:	$(which $ctf_convert)
+ctfmerge:	$(which $ctf_merge)
 32-bit CFLAGS:	$ctf_32cflags
 64-bit CFLAGS:	$ctf_64cflags
 
@@ -106,7 +101,7 @@
 {
 	typeset source=$1 checker=$2 flags=$3
 
-	if ! "$ctf_compiler" $flags -o "$ctf_temp" -c "$source"; then
+	if ! "$ctf_cc" $flags -o "$ctf_temp" -c "$source"; then
 		test_fail "failed to compile $source with flags: $flags"
 		return
 	fi
@@ -146,7 +141,7 @@
 
 	if ! make -C $dir -f Makefile.ctftest \
 	    BUILDDIR="$outdir" \
-	    CC="$ctf_compiler" \
+	    CC="$ctf_cc" \
 	    CFLAGS32="$ctf_mach32" \
 	    CFLAGS64="$ctf_mach64" \
 	    DEBUGFLAGS="$ctf_debugflags" \
@@ -210,12 +205,38 @@
 			test_fail "missing checker for $t"
 		fi
 	done
+
+	outdir="$TMPDIR/ctftest.$$"
+
+	for f in $(find "$ctf_root" -maxdepth 1 -type f -name 'ctftest-*'); do
+		if ! mkdir $outdir; then
+			fatal "failed to make temporary directory '$outdir'"
+		fi
+
+		echo "Running $f in $outdir"
+
+		(cd $outdir && $f)
+
+		if [[ $? -ne 0 ]]; then
+			test_fail "$f failed"
+		else
+			echo "TEST PASSED: $f"
+		fi
+
+		rm -rf $outdir
+	done
 }
 
-while getopts ":c:g:m:t:" c $@; do
+while getopts ":a:C:c:g:m:t:" c $@; do
 	case "$c" in
+	a)
+		ctf_as=$OPTARG
+		;;
+	C)
+		ctf_cxx=$OPTARG
+		;;
 	c)
-		ctf_compiler=$OPTARG
+		ctf_cc=$OPTARG
 		;;
 	g)
 		ctf_debugflags=$OPTARG
@@ -238,9 +259,8 @@
 ctf_32cflags="$ctf_mach32 $ctf_debugflags"
 ctf_64cflags="$ctf_mach64 $ctf_debugflags"
 
-check_env "$ctf_compiler"
-check_env "$ctf_convert"
-check_env "$ctf_merge"
+export ctf_as ctf_cc ctf_cxx ctf_debugflags ctf_merge ctf_convert
+
 announce
 
 run_tests
@@ -251,6 +271,7 @@
 	else
 		printf "\n%s: %u tests failed\n" "$ctf_arg0" "$ctf_nerrs"
 	fi
+	exit 1
 else
 	printf "\n%s: All tests passed successfully\n" "$ctf_arg0"
 	exit 0
--- /dev/null	Thu Apr 25 02:20:49 2019
+++ new/usr/src/test/util-tests/tests/ctf/precheck.ksh	Thu Apr 25 02:20:49 2019
@@ -0,0 +1,39 @@
+#!/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 (c) 2019, Joyent, Inc.
+#
+
+unalias -a
+
+check_env()
+{
+	if which "$1" 2>/dev/null >/dev/null; then
+		return
+	fi
+
+	[[ -f "$1" ]] || {
+		echo "failed to find $1" >&2
+		exit 1
+	}
+}
+
+check_env as
+check_env ctfconvert
+check_env ctfmerge
+check_env elfdump
+check_env gcc
+check_env g++
+check_env ld
+check_env make
--- old/usr/src/uts/common/Makefile.rules	Thu Apr 25 02:20:49 2019
+++ new/usr/src/uts/common/Makefile.rules	Thu Apr 25 02:20:49 2019
@@ -23,7 +23,7 @@
 # Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2016 Garrett D'Amore <garrett@damore.org>
 # Copyright 2013 Saso Kiselkov. All rights reserved.
-# Copyright 2016 Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
 # Copyright 2018 Nexenta Systems, Inc.
 # Copyright (c) 2016 by Delphix. All rights reserved.
 #
@@ -375,7 +375,6 @@
 
 $(OBJS_DIR)/%.o:	$(UTSBASE)/common/io/scsi/adapters/pmcs/%.bin
 	$(COMPILE.b) -o $@ $<
-	$(CTFCONVERT_O)
 
 $(OBJS_DIR)/%.o:		$(COMMONBASE)/fsreparse/%.c
 	$(COMPILE.c) -o $@ $<
--- old/usr/src/uts/common/sys/ctf_api.h	Thu Apr 25 02:20:49 2019
+++ new/usr/src/uts/common/sys/ctf_api.h	Thu Apr 25 02:20:49 2019
@@ -24,7 +24,7 @@
  * Use is subject to license terms.
  */
 /*
- * Copyright 2018 Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
  */
 
 /*
@@ -116,7 +116,7 @@
 	ECTF_ZLIB,		/* zlib library failure */
 	ECTF_CONVBKERR,		/* CTF conversion backend error */
 	ECTF_CONVNOCSRC,	/* No C source to convert from */
-	ECTF_NOCONVBKEND	/* No applicable conversion backend */
+	ECTF_CONVNODEBUG	/* No debug info to convert into CTF */
 };
 
 /*
--- old/usr/src/uts/intel/Makefile.rules	Thu Apr 25 02:20:49 2019
+++ new/usr/src/uts/intel/Makefile.rules	Thu Apr 25 02:20:49 2019
@@ -21,7 +21,7 @@
 #
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
-# Copyright 2018 Joyent, Inc.  All rights reserved.
+# Copyright 2019 Joyent, Inc.  All rights reserved.
 # Copyright 2017 Nexenta Systems, Inc.
 #
 
@@ -298,7 +298,6 @@
 
 $(OBJS_DIR)/%.o:	$(UTSBASE)/intel/$(SUBARCH_DIR)/krtld/%.s
 	$(COMPILE.s) $(KRTLD_INC_PATH) $(KRTLD_CPPFLAGS) -o $@ $<
-	$(CTFCONVERT_O)
 
 $(OBJS_DIR)/%.o:	$(SRC)/common/util/$(SUBARCH_DIR)/%.c
 	$(COMPILE.c) $(KRTLD_INC_PATH) $(KRTLD_CPPFLAGS) -o $@ $<
--- old/usr/src/uts/intel/aes/Makefile	Thu Apr 25 02:20:50 2019
+++ new/usr/src/uts/intel/aes/Makefile	Thu Apr 25 02:20:50 2019
@@ -23,10 +23,8 @@
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#	This makefile drives the production of the AES KEF provider.
+# Copyright (c) 2019, Joyent, Inc.
 #
-#	Intel implementation architecture dependent
-#
 
 #
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
@@ -97,11 +95,10 @@
 
 $(OBJS_DIR)/%.o:  $(COM_DIR)/amd64/%.c
 	$(COMPILE.c) -o $@ $(COM_DIR)/amd64/${@F:.o=.c}
-	$(POST_PROCESS_O)
+	$(CTFCONVERT_O)
 
 $(OBJS_DIR)/%.o: $(COM_DIR)/amd64/%.s
 	$(COMPILE.s) -o $@ $(COM_DIR)/amd64/${@F:.o=.s}
-	$(POST_PROCESS_O)
 
 $(OBJS_DIR)/%.ln: $(COM_DIR)/amd64/%.s
 	@($(LHEAD) $(LINT.s) $(COM_DIR)/amd64/${@F:.ln=.s} $(LTAIL))
--- old/usr/src/uts/intel/arcfour/Makefile	Thu Apr 25 02:20:50 2019
+++ new/usr/src/uts/intel/arcfour/Makefile	Thu Apr 25 02:20:50 2019
@@ -23,10 +23,8 @@
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#	This makefile drives the production of the ARCFOUR KEF provider.
+# Copyright (c) 2019, Joyent, Inc.
 #
-#	Intel implementation architecture dependent
-#
 
 #
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
@@ -92,7 +90,6 @@
 
 $(OBJS_DIR)/arcfour-x86_64.o: arcfour-x86_64.s
 	$(COMPILE.s) -o $@ ${@F:.o=.s}
-	$(POST_PROCESS_O)
 
 $(OBJS_DIR)/arcfour-x86_64.ln: arcfour-x86_64.s
 	@($(LHEAD) $(LINT.s) ${@F:.ln=.s} $(LTAIL))
--- old/usr/src/uts/intel/bignum/Makefile	Thu Apr 25 02:20:50 2019
+++ new/usr/src/uts/intel/bignum/Makefile	Thu Apr 25 02:20:50 2019
@@ -18,13 +18,13 @@
 #
 # CDDL HEADER END
 #
+# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 #
-#	This makefile drives the production of the RSA KEF provider.
+# Copyright (c) 2019, Joyent, Inc.
 #
-#	intel implementation architecture dependent
-#
 
 #
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
@@ -41,9 +41,7 @@
 LINTS		= $(BIGNUM_OBJS:%.o=$(LINTS_DIR)/%.ln)
 ROOTMODULE	= $(ROOT_MISC_DIR)/$(MODULE)
 
-BIGNUM_OBJS_32 = bignum_i386.o bignum_i386_asm.o
-BIGNUM_OBJS_64 = bignum_amd64.o bignum_amd64_asm.o
-BIGNUM_PSR_OBJS = $(BIGNUM_OBJS_$(CLASS))
+BIGNUM_PSR_OBJS = bignum_amd64.o bignum_amd64_asm.o
 
 #
 #	Include common rules.
@@ -90,5 +88,40 @@
 #
 include $(UTSBASE)/intel/Makefile.targ
 
+# Bignum configuration (BIGNUM_CFG):
+#   PSR_MUL:
+#       There is a processor-specific implementation bignum multiply functions
+#   HWCAP:
+#       There are multiple implementations of bignum functions, and the
+#	appropriate one must be chosen at run time, based on testing
+#	hardware capabilites.
+#
+# -DPSR_MUL:
+# For AMD64, there is a processor-specific implementation of
+# the bignum multiply functions, which takes advantage of the
+# 64x64->128 bit multiply instruction.
+#
+# -UHWCAP:
+# There is only one implementation, because the 128 bit multiply using
+# general-purpose registers is faster than any MMX or SSE2 implementation.
 
-include Makefile.$(CLASS)
+BIGNUM_CFG = -DPSR_MUL
+CFLAGS	+= -xO4 -xcrossfile
+$(OBJS_DIR)/bignumimpl.o $(LINTS_DIR)/bignumimpl.ln := \
+	CPPFLAGS += $(BIGNUM_CFG)
+$(OBJS_DIR)/bignum_amd64.o $(LINTS_DIR)/bignum_amd64.ln := \
+	CPPFLAGS += $(BIGNUM_CFG)
+
+$(OBJS_DIR)/bignum_amd64.o: $(BIGNUMDIR)/amd64/bignum_amd64.c
+	$(COMPILE.c) -o $@ $(BIGNUM_CFG) $(BIGNUMDIR)/amd64/bignum_amd64.c
+	$(CTFCONVERT_O)
+
+$(OBJS_DIR)/bignum_amd64_asm.o: $(BIGNUMDIR)/amd64/bignum_amd64_asm.s
+	$(COMPILE.s) -P -o $@ $(BIGNUM_CFG) \
+		$(BIGNUMDIR)/amd64/bignum_amd64_asm.s
+
+$(LINTS_DIR)/bignum_amd64.ln: $(BIGNUMDIR)/amd64/bignum_amd64.c
+	@($(LHEAD) $(LINT.c) $(BIGNUMDIR)/amd64/bignum_amd64.c $(LTAIL))
+
+$(LINTS_DIR)/bignum_amd64_asm.ln: $(BIGNUMDIR)/amd64/bignum_amd64_asm.s
+	@($(LHEAD) $(LINT.s) $(BIGNUMDIR)/amd64/bignum_amd64_asm.s $(LTAIL))
--- old/usr/src/uts/intel/bignum/Makefile.32	Thu Apr 25 02:20:50 2019
+++ /dev/null	Thu Apr 25 02:20:50 2019
@@ -1,64 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-#	Configuration and targets for bignum module
-#	specific to Intel 32-bit architecture, i386.
-#
-# Bignum configuration (BIGNUM_CFG):
-#   PSR_MUL:
-#       There is a processor-specific implementation bignum multiply functions
-#   HWCAP:
-#       There are multiple implementations of bignum functions, and the
-#	appropriate one must be chosen at run time, based on testing
-#	hardware capabilites.
-#   MMX_MANAGE:
-#	Multimedia registers must be saved and restored.
-#	Normally MMX_MANAGE iff _KERNEL, but for testing purposes,
-#	MMX_MANAGE can be defined in userland.
-
-BIGNUM_CFG = -DPSR_MUL -DHWCAP -DMMX_MANAGE
-
-LDFLAGS += -M $(BIGNUMDIR)/i386/cap_mapfile
-
-$(OBJS_DIR)/bignumimpl.o $(LINTS_DIR)/bignumimpl.ln := \
-	CPPFLAGS += $(BIGNUM_CFG)
-$(OBJS_DIR)/bignum_i386.o $(LINTS_DIR)/bignum_i386.ln := \
-	CPPFLAGS += $(BIGNUM_CFG)
-
-$(OBJS_DIR)/bignum_i386.o: $(BIGNUMDIR)/i386/bignum_i386.c
-	$(COMPILE.c) -o $@ $(BIGNUMDIR)/i386/bignum_i386.c
-	$(CTFCONVERT_O)
-	$(POST_PROCESS_O)
-
-$(OBJS_DIR)/bignum_i386_asm.o: $(BIGNUMDIR)/i386/bignum_i386_asm.s
-	$(COMPILE.s) -P -o $@ $(BIGNUM_CFG) $(BIGNUMDIR)/i386/bignum_i386_asm.s
-	$(POST_PROCESS_O)
-
-$(LINTS_DIR)/bignum_i386.ln: $(BIGNUMDIR)/i386/bignum_i386.c
-	@($(LHEAD) $(LINT.c) $(BIGNUMDIR)/i386/bignum_i386.c $(LTAIL))
-
-$(LINTS_DIR)/bignum_i386_asm.ln: $(BIGNUMDIR)/i386/bignum_i386_asm.s
-	@($(LHEAD) $(LINT.s) $(BIGNUMDIR)/i386/bignum_i386_asm.s $(LTAIL))
--- old/usr/src/uts/intel/bignum/Makefile.64	Thu Apr 25 02:20:51 2019
+++ /dev/null	Thu Apr 25 02:20:51 2019
@@ -1,66 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#	Configuration and targets for bignum module
-#	specific to AMD 64-bit architecture, amd64.
-#
-# Bignum configuration (BIGNUM_CFG):
-#   PSR_MUL:
-#       There is a processor-specific implementation bignum multiply functions
-#   HWCAP:
-#       There are multiple implementations of bignum functions, and the
-#	appropriate one must be chosen at run time, based on testing
-#	hardware capabilites.
-#
-# -DPSR_MUL:
-# For AMD64, there is a processor-specific implementation of
-# the bignum multiply functions, which takes advantage of the
-# 64x64->128 bit multiply instruction.
-#
-# -UHWCAP:
-# There is only one implementation, because the 128 bit multiply using
-# general-purpose registers is faster than any MMX or SSE2 implementation.
-
-BIGNUM_CFG = -DPSR_MUL
-CFLAGS	+= -xO4 -xcrossfile
-$(OBJS_DIR)/bignumimpl.o $(LINTS_DIR)/bignumimpl.ln := \
-	CPPFLAGS += $(BIGNUM_CFG)
-$(OBJS_DIR)/bignum_amd64.o $(LINTS_DIR)/bignum_amd64.ln := \
-	CPPFLAGS += $(BIGNUM_CFG)
-
-$(OBJS_DIR)/bignum_amd64.o: $(BIGNUMDIR)/amd64/bignum_amd64.c
-	$(COMPILE.c) -o $@ $(BIGNUM_CFG) $(BIGNUMDIR)/amd64/bignum_amd64.c
-	$(CTFCONVERT_O)
-	$(POST_PROCESS_O)
-
-$(OBJS_DIR)/bignum_amd64_asm.o: $(BIGNUMDIR)/amd64/bignum_amd64_asm.s
-	$(COMPILE.s) -P -o $@ $(BIGNUM_CFG) \
-		$(BIGNUMDIR)/amd64/bignum_amd64_asm.s
-	$(POST_PROCESS_O)
-
-$(LINTS_DIR)/bignum_amd64.ln: $(BIGNUMDIR)/amd64/bignum_amd64.c
-	@($(LHEAD) $(LINT.c) $(BIGNUMDIR)/amd64/bignum_amd64.c $(LTAIL))
-
-$(LINTS_DIR)/bignum_amd64_asm.ln: $(BIGNUMDIR)/amd64/bignum_amd64_asm.s
-	@($(LHEAD) $(LINT.s) $(BIGNUMDIR)/amd64/bignum_amd64_asm.s $(LTAIL))
--- old/usr/src/uts/intel/elfexec/Makefile	Thu Apr 25 02:20:51 2019
+++ new/usr/src/uts/intel/elfexec/Makefile	Thu Apr 25 02:20:51 2019
@@ -23,7 +23,7 @@
 #
 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
-# Copyright 2016 Joyent, Inc.
+# Copyright 2019, Joyent, Inc.
 #
 
 #
@@ -105,12 +105,15 @@
 
 $(OBJS_DIR)/elf32.o:	$(UTSBASE)/common/exec/elf/elf.c
 	$(COMPILE.c) -o $@ -D_ELF32_COMPAT $(UTSBASE)/common/exec/elf/elf.c
+	$(CTFCONVERT_O)
 
 $(OBJS_DIR)/elf32_notes.o: $(UTSBASE)/common/exec/elf/elf_notes.c
 	$(COMPILE.c) -o $@ -D_ELF32_COMPAT $(UTSBASE)/common/exec/elf/elf_notes.c
+	$(CTFCONVERT_O)
 
 $(OBJS_DIR)/old32_notes.o: $(UTSBASE)/common/exec/elf/old_notes.c
 	$(COMPILE.c) -o $@ -D_ELF32_COMPAT $(UTSBASE)/common/exec/elf/old_notes.c
+	$(CTFCONVERT_O)
 
 $(LINTS_DIR)/elf32.ln:	$(UTSBASE)/common/exec/elf/elf.c
 	@($(LHEAD) $(LINT.c) -Celf32 -D_ELF32_COMPAT $(UTSBASE)/common/exec/elf/elf.c $(LTAIL))
--- old/usr/src/uts/intel/kcf/Makefile	Thu Apr 25 02:20:51 2019
+++ new/usr/src/uts/intel/kcf/Makefile	Thu Apr 25 02:20:51 2019
@@ -22,7 +22,7 @@
 # Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright (c) 2019, Joyent, Inc.
 
 #
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
@@ -101,7 +101,6 @@
 
 $(OBJS_DIR)/%.o: $(COM_DIR)/modes/amd64/%.s
 	$(COMPILE.s) -o $@ $(COM_DIR)/modes/amd64/${@F:.o=.s}
-	$(POST_PROCESS_O)
 
 $(OBJS_DIR)/%.ln: $(COM_DIR)/modes/amd64/%.s
 	@($(LHEAD) $(LINT.s) $(COM_DIR)/modes/amd64/${@F:.ln=.s} $(LTAIL))
--- old/usr/src/uts/intel/md5/Makefile	Thu Apr 25 02:20:51 2019
+++ new/usr/src/uts/intel/md5/Makefile	Thu Apr 25 02:20:51 2019
@@ -24,10 +24,8 @@
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#	This makefile drives the production of the md5 crypto kernel module.
+# Copyright (c) 2019, Joyent, Inc.
 #
-#	intel architecture dependent
-#
 
 #
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
@@ -103,7 +101,6 @@
 
 $(OBJS_DIR)/md5_amd64.o: md5_amd64.s
 	$(COMPILE.s) -o $@ md5_amd64.s
-	$(POST_PROCESS_O)
 
 $(OBJS_DIR)/md5_amd64.ln: md5_amd64.s
 	@($(LHEAD) $(LINT.c) md5_amd64.s $(LTAIL))
--- old/usr/src/uts/intel/sha1/Makefile	Thu Apr 25 02:20:51 2019
+++ new/usr/src/uts/intel/sha1/Makefile	Thu Apr 25 02:20:51 2019
@@ -18,17 +18,11 @@
 #
 # CDDL HEADER END
 #
-#
-# uts/intel/sha1/Makefile
-#
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
+# Copyright (c) 2019, Joyent, Inc.
 #
-#	This makefile drives the production of the sha1 crypto kernel module.
-#
-#	intel architecture dependent
-#
 
 #
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
@@ -105,7 +99,6 @@
 
 $(OBJS_DIR)/sha1-x86_64.o: sha1-x86_64.s
 	$(COMPILE.s) -o $@ ${@F:.o=.s}
-	$(POST_PROCESS_O)
 
 $(OBJS_DIR)/sha1-x86_64.ln: sha1-x86_64.s
 	@($(LHEAD) $(LINT.c) ${@F:.ln=.s} $(LTAIL))
--- old/usr/src/uts/intel/sha2/Makefile	Thu Apr 25 02:20:52 2019
+++ new/usr/src/uts/intel/sha2/Makefile	Thu Apr 25 02:20:52 2019
@@ -22,11 +22,7 @@
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#
-#	This makefile drives the production of the sha2 crypto kernel module.
-#
-#	intel architecture dependent
-#
+# Copyright (c) 2019, Joyent, Inc.
 
 #
 #	Path to the base of the uts directory tree (usually /usr/src/uts).
@@ -105,7 +101,6 @@
 
 $(OBJS_DIR)/%.o: %.s
 	$(COMPILE.s) -o $@ ${@F:.o=.s}
-	$(POST_PROCESS_O)
 
 $(OBJS_DIR)/%.ln: %.s
 	@($(LHEAD) $(LINT.c) ${@F:.ln=.s} $(LTAIL))
