[Midnightbsd-cvs] src [10225] trunk/cddl/contrib/opensolaris/tools/ctf/cvt: tag

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jun 2 11:59:10 EDT 2018


Revision: 10225
          http://svnweb.midnightbsd.org/src/?rev=10225
Author:   laffer1
Date:     2018-06-02 11:59:09 -0400 (Sat, 02 Jun 2018)
Log Message:
-----------
tag

Modified Paths:
--------------
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/compare.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fifo.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fifo.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/hash.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/input.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stack.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stack.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h
    trunk/cddl/contrib/opensolaris/tools/ctf/cvt/util.c

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -38,7 +39,7 @@
  */
 
 #include <pthread.h>
-#if defined(sun)
+#ifdef illumos
 #include <synch.h>
 #endif
 #include <stdio.h>
@@ -49,7 +50,7 @@
 barrier_init(barrier_t *bar, int nthreads)
 {
 	pthread_mutex_init(&bar->bar_lock, NULL);
-#if defined(sun)
+#ifdef illumos
 	sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
 #else
 	sem_init(&bar->bar_sem, 0, 0);
@@ -66,7 +67,7 @@
 
 	if (++bar->bar_numin < bar->bar_nthr) {
 		pthread_mutex_unlock(&bar->bar_lock);
-#if defined(sun)
+#ifdef illumos
 		sema_wait(&bar->bar_sem);
 #else
 		sem_wait(&bar->bar_sem);
@@ -80,7 +81,7 @@
 		/* reset for next use */
 		bar->bar_numin = 0;
 		for (i = 1; i < bar->bar_nthr; i++)
-#if defined(sun)
+#ifdef illumos
 			sema_post(&bar->bar_sem);
 #else
 			sem_post(&bar->bar_sem);

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -33,7 +34,7 @@
  * APIs for the barrier synchronization primitive.
  */
 
-#if defined(sun)
+#ifdef illumos
 #include <synch.h>
 #else
 #include <semaphore.h>

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/compare.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/compare.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/compare.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -47,11 +48,13 @@
  *
  * The value is only valid during a call to ctf_load.
  */
-char *curfile;
+static char *curfile;
 
 #define	CTF_BUF_CHUNK_SIZE	(64 * 1024)
 #define	RES_BUF_CHUNK_SIZE	(64 * 1024)
 
+static int ntypes = 0;		/* The number of types. */
+
 struct ctf_buf {
 	strtab_t ctb_strtab;	/* string table */
 	caddr_t ctb_base;	/* pointer to base of buffer */
@@ -62,6 +65,18 @@
 	int ntholes;		/* number of type holes */
 };
 
+/*
+ * Macros to reverse byte order
+ */
+#define	BSWAP_8(x)	((x) & 0xff)
+#define	BSWAP_16(x)	((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
+#define	BSWAP_32(x)	((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
+
+#define	SWAP_16(x)	(x) = BSWAP_16(x)
+#define	SWAP_32(x)	(x) = BSWAP_32(x)
+
+static int target_requires_swap;
+
 /*PRINTFLIKE1*/
 static void
 parseterminate(const char *fmt, ...)
@@ -140,6 +155,11 @@
 	ctl.ctl_label = strtab_insert(&b->ctb_strtab, le->le_name);
 	ctl.ctl_typeidx = le->le_idx;
 
+	if (target_requires_swap) {
+		SWAP_32(ctl.ctl_label);
+		SWAP_32(ctl.ctl_typeidx);
+	}
+
 	ctf_buf_write(b, &ctl, sizeof (ctl));
 
 	return (1);
@@ -152,6 +172,10 @@
 
 	ctf_buf_write(b, &id, sizeof (id));
 
+	if (target_requires_swap) {
+		SWAP_16(id);
+	}
+
 	debug(3, "Wrote object %s (%d)\n", (idp ? idp->ii_name : "(null)"), id);
 }
 
@@ -180,10 +204,21 @@
 
 	fdata[0] = CTF_TYPE_INFO(CTF_K_FUNCTION, 1, nargs);
 	fdata[1] = idp->ii_dtype->t_id;
+
+	if (target_requires_swap) {
+		SWAP_16(fdata[0]);
+		SWAP_16(fdata[1]);
+	}
+
 	ctf_buf_write(b, fdata, sizeof (fdata));
 
 	for (i = 0; i < idp->ii_nargs; i++) {
 		id = idp->ii_args[i]->t_id;
+
+		if (target_requires_swap) {
+			SWAP_16(id);
+		}
+
 		ctf_buf_write(b, &id, sizeof (id));
 	}
 
@@ -208,11 +243,25 @@
 		ctt->ctt_size = CTF_LSIZE_SENT;
 		ctt->ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size);
 		ctt->ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(size);
+		if (target_requires_swap) {
+			SWAP_32(ctt->ctt_name);
+			SWAP_16(ctt->ctt_info);
+			SWAP_16(ctt->ctt_size);
+			SWAP_32(ctt->ctt_lsizehi);
+			SWAP_32(ctt->ctt_lsizelo);
+		}
 		ctf_buf_write(b, ctt, sizeof (*ctt));
 	} else {
 		ctf_stype_t *cts = (ctf_stype_t *)ctt;
 
 		cts->ctt_size = (ushort_t)size;
+
+		if (target_requires_swap) {
+			SWAP_32(cts->ctt_name);
+			SWAP_16(cts->ctt_info);
+			SWAP_16(cts->ctt_size);
+		}
+
 		ctf_buf_write(b, cts, sizeof (*cts));
 	}
 }
@@ -222,6 +271,12 @@
 {
 	ctf_stype_t *cts = (ctf_stype_t *)ctt;
 
+	if (target_requires_swap) {
+		SWAP_32(cts->ctt_name);
+		SWAP_16(cts->ctt_info);
+		SWAP_16(cts->ctt_size);
+	}
+
 	ctf_buf_write(b, cts, sizeof (*cts));
 }
 
@@ -296,6 +351,9 @@
 			encoding = ip->intr_fformat;
 
 		data = CTF_INT_DATA(encoding, ip->intr_offset, ip->intr_nbits);
+		if (target_requires_swap) {
+			SWAP_32(data);
+		}
 		ctf_buf_write(b, &data, sizeof (data));
 		break;
 
@@ -312,6 +370,11 @@
 		cta.cta_contents = tp->t_ardef->ad_contents->t_id;
 		cta.cta_index = tp->t_ardef->ad_idxtype->t_id;
 		cta.cta_nelems = tp->t_ardef->ad_nelems;
+		if (target_requires_swap) {
+			SWAP_16(cta.cta_contents);
+			SWAP_16(cta.cta_index);
+			SWAP_32(cta.cta_nelems);
+		}
 		ctf_buf_write(b, &cta, sizeof (cta));
 		break;
 
@@ -341,6 +404,11 @@
 				    offset);
 				ctm.ctm_type = mp->ml_type->t_id;
 				ctm.ctm_offset = mp->ml_offset;
+				if (target_requires_swap) {
+					SWAP_32(ctm.ctm_name);
+					SWAP_16(ctm.ctm_type);
+					SWAP_16(ctm.ctm_offset);
+				}
 				ctf_buf_write(b, &ctm, sizeof (ctm));
 			}
 		} else {
@@ -355,6 +423,14 @@
 				    CTF_OFFSET_TO_LMEMHI(mp->ml_offset);
 				ctlm.ctlm_offsetlo =
 				    CTF_OFFSET_TO_LMEMLO(mp->ml_offset);
+
+				if (target_requires_swap) {
+					SWAP_32(ctlm.ctlm_name);
+					SWAP_16(ctlm.ctlm_type);
+					SWAP_32(ctlm.ctlm_offsethi);
+					SWAP_32(ctlm.ctlm_offsetlo);
+				}
+
 				ctf_buf_write(b, &ctlm, sizeof (ctlm));
 			}
 		}
@@ -377,6 +453,12 @@
 			offset = strtab_insert(&b->ctb_strtab, ep->el_name);
 			cte.cte_name = CTF_TYPE_NAME(CTF_STRTAB_0, offset);
 			cte.cte_value = ep->el_number;
+
+			if (target_requires_swap) {
+				SWAP_32(cte.cte_name);
+				SWAP_32(cte.cte_value);
+			}
+
 			ctf_buf_write(b, &cte, sizeof (cte));
 			i--;
 		}
@@ -411,7 +493,7 @@
 
 		if (i > CTF_MAX_VLEN) {
 			terminate("function %s has too many args: %d > %d\n",
-			    i, CTF_MAX_VLEN);
+			    tdesc_name(tp), i, CTF_MAX_VLEN);
 		}
 
 		ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FUNCTION, isroot, i);
@@ -420,6 +502,11 @@
 
 		for (i = 0; i < (int) tp->t_fndef->fn_nargs; i++) {
 			id = tp->t_fndef->fn_args[i]->t_id;
+
+			if (target_requires_swap) {
+				SWAP_16(id);
+			}
+
 			ctf_buf_write(b, &id, sizeof (id));
 		}
 
@@ -613,6 +700,9 @@
 
 	int i;
 
+	target_requires_swap = do_compress & CTF_SWAP_BYTES;
+	do_compress &= ~CTF_SWAP_BYTES;
+
 	/*
 	 * Prepare the header, and create the CTF output buffers.  The data
 	 * object section and function section are both lists of 2-byte
@@ -649,6 +739,18 @@
 	h.cth_stroff = ctf_buf_cur(buf);
 	h.cth_strlen = strtab_size(&buf->ctb_strtab);
 
+	if (target_requires_swap) {
+		SWAP_16(h.cth_preamble.ctp_magic);
+		SWAP_32(h.cth_parlabel);
+		SWAP_32(h.cth_parname);
+		SWAP_32(h.cth_lbloff);
+		SWAP_32(h.cth_objtoff);
+		SWAP_32(h.cth_funcoff);
+		SWAP_32(h.cth_typeoff);
+		SWAP_32(h.cth_stroff);
+		SWAP_32(h.cth_strlen);
+	}
+
 	/*
 	 * We only do compression for ctfmerge, as ctfconvert is only
 	 * supposed to be used on intermediary build objects. This is
@@ -1044,6 +1146,10 @@
 					(*mpp)->ml_type = tdarr[ctm->ctm_type];
 					(*mpp)->ml_offset = ctm->ctm_offset;
 					(*mpp)->ml_size = 0;
+					if (ctm->ctm_type > ntypes) {
+						parseterminate("Invalid member type ctm_type=%d",
+						    ctm->ctm_type);
+					}
 				}
 			} else {
 				for (i = 0, mpp = &tdp->t_members; i < vlen;
@@ -1060,6 +1166,10 @@
 					(*mpp)->ml_offset =
 					    (int)CTF_LMEM_OFFSET(ctlm);
 					(*mpp)->ml_size = 0;
+					if (ctlm->ctlm_type > ntypes) {
+						parseterminate("Invalid lmember type ctlm_type=%d",
+						    ctlm->ctlm_type);
+					}
 				}
 			}
 
@@ -1173,9 +1283,10 @@
 {
 	tdata_t *td = tdata_new();
 	tdesc_t **tdarr;
-	int ntypes = count_types(h, buf);
 	int idx, i;
 
+	ntypes = count_types(h, buf);
+
 	/* shudder */
 	tdarr = xcalloc(sizeof (tdesc_t *) * (ntypes + 1));
 	tdarr[0] = NULL;

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -155,7 +156,7 @@
 	int keep_stabs = 0;
 	int c;
 
-#if defined(sun)
+#ifdef illumos
 	sighold(SIGINT);
 	sighold(SIGQUIT);
 	sighold(SIGTERM);
@@ -221,7 +222,7 @@
 	 */
 	set_terminate_cleanup(terminate_cleanup);
 
-#if defined(sun)
+#ifdef illumos
 	sigset(SIGINT, handle_sig);
 	sigset(SIGQUIT, handle_sig);
 	sigset(SIGTERM, handle_sig);

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -176,7 +177,7 @@
 #include <unistd.h>
 #include <pthread.h>
 #include <assert.h>
-#if defined(sun)
+#ifdef illumos
 #include <synch.h>
 #endif
 #include <signal.h>
@@ -183,13 +184,13 @@
 #include <libgen.h>
 #include <string.h>
 #include <errno.h>
-#if defined(sun)
+#ifdef illumos
 #include <alloca.h>
 #endif
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/mman.h>
-#if defined(sun)
+#ifdef illumos
 #include <sys/sysconf.h>
 #endif
 
@@ -232,7 +233,7 @@
 	    progname, progname);
 }
 
-#if defined(sun)
+#ifdef illumos
 static void
 bigheap(void)
 {
@@ -280,7 +281,7 @@
 
 	(void) memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t)&mha, 0, 0);
 }
-#endif
+#endif	/* illumos */
 
 static void
 finalize_phase_one(workqueue_t *wq)
@@ -620,7 +621,7 @@
 		terminate("No CTF data found in source file %s\n", srcfile);
 
 	tmpname = mktmpname(destfile, ".ctf");
-	write_ctf(srctd, destfile, tmpname, CTF_COMPRESS | keep_stabs);
+	write_ctf(srctd, destfile, tmpname, CTF_COMPRESS | CTF_SWAP_BYTES | keep_stabs);
 	if (rename(tmpname, destfile) != 0) {
 		terminate("Couldn't rename temp file %s to %s", tmpname,
 		    destfile);
@@ -707,7 +708,7 @@
 		    (void *(*)(void *))worker_thread, wq);
 	}
 
-#if defined(sun)
+#ifdef illumos
 	sigset(SIGINT, handle_sig);
 	sigset(SIGQUIT, handle_sig);
 	sigset(SIGTERM, handle_sig);
@@ -1015,7 +1016,7 @@
 
 	tmpname = mktmpname(outfile, ".ctf");
 	write_ctf(savetd, outfile, tmpname,
-	    CTF_COMPRESS | write_fuzzy_match | dynsym | keep_stabs);
+	    CTF_COMPRESS | CTF_SWAP_BYTES | write_fuzzy_match | dynsym | keep_stabs);
 	if (rename(tmpname, outfile) != 0)
 		terminate("Couldn't rename output temp file %s", tmpname);
 	free(tmpname);

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -26,8 +27,6 @@
 #ifndef _CTFTOOLS_H
 #define	_CTFTOOLS_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * Functions and data structures used in the manipulation of stabs and CTF data
  */
@@ -39,6 +38,8 @@
 #include <gelf.h>
 #include <pthread.h>
 
+#include <sys/ccompile.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -159,7 +160,7 @@
 /* Auxiliary structure for structure/union tdesc_t */
 typedef struct mlist {
 	int	ml_offset;	/* Offset from start of structure (in bits) */
-	int	ml_size;	/* Member size (in bits) */
+	uint_t	ml_size;	/* Member size (in bits) */
 	char	*ml_name;	/* Member name */
 	struct	tdesc *ml_type;	/* Member type */
 	struct	mlist *ml_next;	/* Next member */
@@ -391,6 +392,7 @@
 #define	CTF_USE_DYNSYM	0x2 /* use .dynsym not .symtab */
 #define	CTF_COMPRESS	0x4 /* compress CTF output */
 #define	CTF_KEEP_STABS	0x8 /* keep .stabs sections */
+#define	CTF_SWAP_BYTES	0x10 /* target byte order is different from host */
 
 void write_ctf(tdata_t *, const char *, const char *, int);
 
@@ -434,8 +436,8 @@
 int findelfsecidx(Elf *, const char *, const char *);
 size_t elf_ptrsz(Elf *);
 char *mktmpname(const char *, const char *);
-void terminate(const char *, ...);
-void aborterr(const char *, ...);
+void terminate(const char *, ...) __NORETURN;
+void aborterr(const char *, ...) __NORETURN;
 void set_terminate_cleanup(void (*)(void));
 void elfterminate(const char *, const char *, ...);
 void warning(const char *, ...);

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -23,8 +24,6 @@
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * DWARF to tdata conversion
  *
@@ -491,17 +490,60 @@
 {
 	Dwarf_Locdesc *loc = NULL;
 	Dwarf_Signed locnum = 0;
+	Dwarf_Attribute at;
+	Dwarf_Half form;
 
-	if (dwarf_locdesc(die, name, &loc, &locnum, &dw->dw_err) != DW_DLV_OK)
+	if (name != DW_AT_data_member_location)
+		terminate("die %llu: can only process attribute "
+		    "DW_AT_data_member_location\n", die_off(dw, die));
+
+	if ((at = die_attr(dw, die, name, 0)) == NULL)
 		return (0);
 
-	if (locnum != 1 || loc->ld_s->lr_atom != DW_OP_plus_uconst) {
-		terminate("die %llu: cannot parse member offset\n",
-		    die_off(dw, die));
+	if (dwarf_whatform(at, &form, &dw->dw_err) != DW_DLV_OK)
+		return (0);
+
+	switch (form) {
+	case DW_FORM_block:
+	case DW_FORM_block1:
+	case DW_FORM_block2:
+	case DW_FORM_block4:
+		/*
+		 * GCC in base and Clang (3.3 or below) generates
+		 * DW_AT_data_member_location attribute with DW_FORM_block*
+		 * form. The attribute contains one DW_OP_plus_uconst
+		 * operator. The member offset stores in the operand.
+		 */
+		if (dwarf_locdesc(die, name, &loc, &locnum, &dw->dw_err) !=
+		    DW_DLV_OK)
+			return (0);
+		if (locnum != 1 || loc->ld_s->lr_atom != DW_OP_plus_uconst) {
+			terminate("die %llu: cannot parse member offset\n",
+			    die_off(dw, die));
+		}
+		*valp = loc->ld_s->lr_number;
+		break;
+
+	case DW_FORM_data1:
+	case DW_FORM_data2:
+	case DW_FORM_data4:
+	case DW_FORM_data8:
+	case DW_FORM_udata:
+		/*
+		 * Clang 3.4 generates DW_AT_data_member_location attribute
+		 * with DW_FORM_data* form (constant class). The attribute
+		 * stores a contant value which is the member offset.
+		 */
+		if (dwarf_attrval_unsigned(die, name, valp, &dw->dw_err) !=
+		    DW_DLV_OK)
+			return (0);
+		break;
+
+	default:
+		terminate("die %llu: cannot parse member offset with form "
+		    "%u\n", die_off(dw, die), form);
 	}
 
-	*valp = loc->ld_s->lr_number;
-
 	if (loc != NULL)
 		if (dwarf_locdesc_free(loc, &dw->dw_err) != DW_DLV_OK)
 			terminate("die %llu: cannot free location descriptor: %s\n",
@@ -634,6 +676,10 @@
 		ar->ad_nelems = uval + 1;
 	else if (die_signed(dw, dim, DW_AT_upper_bound, &sval, 0))
 		ar->ad_nelems = sval + 1;
+	else if (die_unsigned(dw, dim, DW_AT_count, &uval, 0))
+		ar->ad_nelems = uval;
+	else if (die_signed(dw, dim, DW_AT_count, &sval, 0))
+		ar->ad_nelems = sval;
 	else
 		ar->ad_nelems = 0;
 
@@ -674,6 +720,13 @@
 		tdesc_t *dimtdp;
 		int flags;
 
+		/* Check for bogus gcc DW_AT_byte_size attribute */
+		if (uval == (unsigned)-1) {
+			printf("dwarf.c:%s() working around bogus -1 DW_AT_byte_size\n",
+			    __func__);
+			uval = 0;
+		}
+		
 		tdp->t_size = uval;
 
 		/*
@@ -755,11 +808,22 @@
 	Dwarf_Unsigned uval;
 	Dwarf_Signed sval;
 
+	if (die_isdecl(dw, die)) {
+		tdp->t_type = FORWARD;
+		return;
+	}
+
 	debug(3, "die %llu: creating enum\n", off);
 
 	tdp->t_type = ENUM;
 
 	(void) die_unsigned(dw, die, DW_AT_byte_size, &uval, DW_ATTR_REQ);
+	/* Check for bogus gcc DW_AT_byte_size attribute */
+	if (uval == (unsigned)-1) {
+		printf("dwarf.c:%s() working around bogus -1 DW_AT_byte_size\n",
+		    __func__); 
+		uval = 0;
+	}
 	tdp->t_size = uval;
 
 	if ((mem = die_child(dw, die)) != NULL) {
@@ -873,7 +937,10 @@
 die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp,
     int type, const char *typename)
 {
-	Dwarf_Unsigned sz, bitsz, bitoff;
+	Dwarf_Unsigned sz, bitsz, bitoff, maxsz=0;
+#if BYTE_ORDER == _LITTLE_ENDIAN
+	Dwarf_Unsigned bysz;
+#endif
 	Dwarf_Die mem;
 	mlist_t *ml, **mlastp;
 	iidesc_t *ii;
@@ -929,6 +996,8 @@
 			ml->ml_name = NULL;
 
 		ml->ml_type = die_lookup_pass1(dw, mem, DW_AT_type);
+		debug(3, "die_sou_create(): ml_type = %p t_id = %d\n",
+		    ml->ml_type, ml->ml_type->t_id);
 
 		if (die_mem_offset(dw, mem, DW_AT_data_member_location,
 		    &mloff, 0)) {
@@ -946,8 +1015,26 @@
 #if BYTE_ORDER == _BIG_ENDIAN
 			ml->ml_offset += bitoff;
 #else
-			ml->ml_offset += tdesc_bitsize(ml->ml_type) - bitoff -
-			    ml->ml_size;
+			/*
+			 * Note that Clang 3.4 will sometimes generate
+			 * member DIE before generating the DIE for the
+			 * member's type. The code can not handle this
+			 * properly so that tdesc_bitsize(ml->ml_type) will
+			 * return 0 because ml->ml_type is unknown. As a
+			 * result, a wrong member offset will be calculated.
+			 * To workaround this, we can instead try to
+			 * retrieve the value of DW_AT_byte_size attribute
+			 * which stores the byte size of the space occupied
+			 * by the type. If this attribute exists, its value
+			 * should equal to tdesc_bitsize(ml->ml_type)/NBBY.
+			 */
+			if (die_unsigned(dw, mem, DW_AT_byte_size, &bysz, 0) &&
+			    bysz > 0)
+				ml->ml_offset += bysz * NBBY - bitoff -
+					ml->ml_size;
+			else
+				ml->ml_offset += tdesc_bitsize(ml->ml_type) -
+					bitoff - ml->ml_size;
 #endif
 		}
 
@@ -956,8 +1043,24 @@
 
 		*mlastp = ml;
 		mlastp = &ml->ml_next;
+
+		/* Find the size of the largest member to work around a gcc
+		 * bug.  See GCC Bugzilla 35998.
+		 */
+		if (maxsz < ml->ml_size)
+			maxsz = ml->ml_size;
+
 	} while ((mem = die_sibling(dw, mem)) != NULL);
 
+	/* See if we got a bogus DW_AT_byte_size.  GCC will sometimes
+	 * emit this.
+	 */
+	if (sz == (unsigned)-1) {
+		 printf("dwarf.c:%s() working around bogus -1 DW_AT_byte_size\n",
+		     __func__);
+		 tdp->t_size = maxsz / 8;  /* maxsz is in bits, t_size is bytes */
+	}
+
 	/*
 	 * GCC will attempt to eliminate unused types, thus decreasing the
 	 * size of the emitted dwarf.  That is, if you declare a foo_t in your
@@ -1054,7 +1157,7 @@
 		}
 
 		if (ml->ml_size != 0 && mt->t_type == INTRINSIC &&
-		    mt->t_intr->intr_nbits != ml->ml_size) {
+		    mt->t_intr->intr_nbits != (int)ml->ml_size) {
 			/*
 			 * This member is a bitfield, and needs to reference
 			 * an intrinsic type with the same width.  If the
@@ -1283,7 +1386,7 @@
 		mult = 2;
 		col = 1;
 	} else if (enc == DW_ATE_imaginary_float
-#if defined(sun)
+#ifdef illumos
 	    || enc == DW_ATE_SUN_imaginary_float
 #endif
 	    )
@@ -1334,7 +1437,7 @@
 	case DW_ATE_float:
 	case DW_ATE_complex_float:
 	case DW_ATE_imaginary_float:
-#if defined(sun)
+#ifdef illumos
 	case DW_ATE_SUN_imaginary_float:
 	case DW_ATE_SUN_interval_float:
 #endif
@@ -1370,6 +1473,13 @@
 	 */
 	(void) die_unsigned(dw, base, DW_AT_byte_size, &sz, DW_ATTR_REQ);
 
+	/* Check for bogus gcc DW_AT_byte_size attribute */
+	if (sz == (unsigned)-1) {
+		printf("dwarf.c:%s() working around bogus -1 DW_AT_byte_size\n",
+		    __func__);
+		sz = 0;
+	}
+
 	if (tdp->t_name == NULL)
 		terminate("die %llu: base type without name\n", off);
 
@@ -1758,6 +1868,59 @@
 	} while (dw->dw_nunres != 0);
 }
 
+/*
+ * Any object containing a function or object symbol at any scope should also
+ * contain DWARF data.
+ */
+static boolean_t
+should_have_dwarf(Elf *elf)
+{
+	Elf_Scn *scn = NULL;
+	Elf_Data *data = NULL;
+	GElf_Shdr shdr;
+	GElf_Sym sym;
+	uint32_t symdx = 0;
+	size_t nsyms = 0;
+	boolean_t found = B_FALSE;
+
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
+		gelf_getshdr(scn, &shdr);
+
+		if (shdr.sh_type == SHT_SYMTAB) {
+			found = B_TRUE;
+			break;
+		}
+	}
+
+	if (!found)
+		terminate("cannot convert stripped objects\n");
+
+	data = elf_getdata(scn, NULL);
+	nsyms = shdr.sh_size / shdr.sh_entsize;
+
+	for (symdx = 0; symdx < nsyms; symdx++) {
+		gelf_getsym(data, symdx, &sym);
+
+		if ((GELF_ST_TYPE(sym.st_info) == STT_FUNC) ||
+		    (GELF_ST_TYPE(sym.st_info) == STT_TLS) ||
+		    (GELF_ST_TYPE(sym.st_info) == STT_OBJECT)) {
+			char *name;
+
+			name = elf_strptr(elf, shdr.sh_link, sym.st_name);
+
+			/* Studio emits these local symbols regardless */
+			if ((strcmp(name, "Bbss.bss") != 0) &&
+			    (strcmp(name, "Ttbss.bss") != 0) &&
+			    (strcmp(name, "Ddata.data") != 0) &&
+			    (strcmp(name, "Ttdata.data") != 0) &&
+			    (strcmp(name, "Drodata.rodata") != 0))
+				return (B_TRUE);
+		}
+	}
+
+	return (B_FALSE);
+}
+
 /*ARGSUSED*/
 int
 dw_read(tdata_t *td, Elf *elf, char *filename __unused)
@@ -1782,8 +1945,12 @@
 
 	if ((rc = dwarf_elf_init(elf, DW_DLC_READ, &dw.dw_dw,
 	    &dw.dw_err)) == DW_DLV_NO_ENTRY) {
-		errno = ENOENT;
-		return (-1);
+		if (should_have_dwarf(elf)) {
+			errno = ENOENT;
+			return (-1);
+		} else {
+			return (0);
+		}
 	} else if (rc != DW_DLV_OK) {
 		if (dwarf_errno(&dw.dw_err) == DW_DLE_DEBUG_INFO_NULL) {
 			/*
@@ -1801,9 +1968,14 @@
 	    &addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_OK)
 		terminate("rc = %d %s\n", rc, dwarf_errmsg(&dw.dw_err));
 
-	if ((cu = die_sibling(&dw, NULL)) == NULL)
+	if ((cu = die_sibling(&dw, NULL)) == NULL ||
+	    (((child = die_child(&dw, cu)) == NULL) &&
+	    should_have_dwarf(elf))) {
 		terminate("file does not contain dwarf type data "
 		    "(try compiling with -g)\n");
+	} else if (child == NULL) {
+		return (0);
+	}
 
 	dw.dw_maxoff = nxthdr - 1;
 

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fifo.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fifo.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fifo.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fifo.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fifo.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fifo.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/hash.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/hash.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/hash.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/input.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/input.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/input.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -348,7 +349,8 @@
 {
 	tdesc_t *defn = (ctdp->t_type == FORWARD ? mtdp : ctdp);
 
-	return (defn->t_type == STRUCT || defn->t_type == UNION);
+	return (defn->t_type == STRUCT || defn->t_type == UNION ||
+	    defn->t_type == ENUM);
 }
 
 static int
@@ -357,7 +359,7 @@
 	int (*equiv)(tdesc_t *, tdesc_t *, equiv_data_t *);
 	int mapping;
 
-	if (ctdp->t_emark > ed->ed_clear_mark ||
+	if (ctdp->t_emark > ed->ed_clear_mark &&
 	    mtdp->t_emark > ed->ed_clear_mark)
 		return (ctdp->t_emark == mtdp->t_emark);
 

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/output.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/output.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -576,7 +577,7 @@
 			    shdr.sh_name);
 		}
 
-#if !defined(sun)
+#ifndef illumos
 		if (gelf_update_shdr(dscn, &shdr) == 0)
 			elfterminate(dstname, "Cannot update sect %s", sname);
 #endif
@@ -585,7 +586,7 @@
 			elfterminate(srcname, "Cannot get sect %s data", sname);
 		if ((ddata = elf_newdata(dscn)) == NULL)
 			elfterminate(dstname, "Can't make sect %s data", sname);
-#if defined(sun)
+#ifdef illumos
 		bcopy(sdata, ddata, sizeof (Elf_Data));
 #else
 		/*
@@ -645,7 +646,7 @@
 			}
 		}
 
-#if !defined(sun)
+#ifndef illumos
 		if (ddata->d_buf == NULL && sdata->d_buf != NULL) {
 			ddata->d_buf = xmalloc(shdr.sh_size);
 			bcopy(sdata->d_buf, ddata->d_buf, shdr.sh_size);
@@ -719,7 +720,7 @@
 
 	iiburst = sort_iidescs(elf, file, td, flags & CTF_FUZZY_MATCH,
 	    flags & CTF_USE_DYNSYM);
-	data = ctf_gen(iiburst, lenp, flags & CTF_COMPRESS);
+	data = ctf_gen(iiburst, lenp, flags & (CTF_COMPRESS |  CTF_SWAP_BYTES));
 
 	iiburst_free(iiburst);
 
@@ -732,10 +733,12 @@
 	struct stat st;
 	Elf *elf = NULL;
 	Elf *telf = NULL;
+	GElf_Ehdr ehdr;
 	caddr_t data;
 	size_t len;
 	int fd = -1;
 	int tfd = -1;
+	int byteorder;
 
 	(void) elf_version(EV_CURRENT);
 	if ((fd = open(curname, O_RDONLY)) < 0 || fstat(fd, &st) < 0)
@@ -748,6 +751,22 @@
 	if ((telf = elf_begin(tfd, ELF_C_WRITE, NULL)) == NULL)
 		elfterminate(curname, "Cannot write");
 
+	if (gelf_getehdr(elf, &ehdr)) {
+#if BYTE_ORDER == _BIG_ENDIAN
+		byteorder = ELFDATA2MSB;
+#else
+		byteorder = ELFDATA2LSB;
+#endif
+		/*
+		 * If target and host has the same byte order
+		 * clear byte swapping request
+		 */
+		if  (ehdr.e_ident[EI_DATA] == byteorder)
+			flags &= ~CTF_SWAP_BYTES;
+	}
+	else 
+		elfterminate(curname, "Failed to get EHDR");
+
 	data = make_ctf_data(td, elf, curname, &len, flags);
 	write_file(elf, curname, telf, newname, data, len, flags);
 	free(data);

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -54,7 +55,7 @@
 static tdesc_t *hash_table[BUCKETS];
 static tdesc_t *name_table[BUCKETS];
 
-list_t *typedbitfldmems;
+static list_t *typedbitfldmems;
 
 static void reset(void);
 static jmp_buf	resetbuf;
@@ -952,7 +953,7 @@
 
 		itdp = find_intrinsic(tdp);
 		if (itdp->t_type == INTRINSIC) {
-			if (mlp->ml_size != itdp->t_intr->intr_nbits) {
+			if ((int)mlp->ml_size != itdp->t_intr->intr_nbits) {
 				parse_debug(4, cp, "making %d bit intrinsic "
 				    "from %s", mlp->ml_size, tdesc_name(itdp));
 				mlp->ml_type = bitintrinsic(itdp, mlp->ml_size);
@@ -1173,7 +1174,7 @@
 	while (tdp) {
 		switch (tdp->t_type) {
 		case INTRINSIC:
-			if (ml->ml_size != tdp->t_intr->intr_nbits) {
+			if ((int)ml->ml_size != tdp->t_intr->intr_nbits) {
 				debug(3, "making %d bit intrinsic from %s",
 				    ml->ml_size, tdesc_name(tdp));
 				ml->ml_type = bitintrinsic(tdp, ml->ml_size);

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stack.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stack.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stack.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stack.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stack.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/stack.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -173,7 +174,7 @@
 	return (!streq(tdp1->t_name, tdp2->t_name));
 }
 
-#if defined(sun)
+#ifdef illumos
 /*ARGSUSED1*/
 static int
 tdesc_print(void *data, void *private __unused)

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -37,8 +38,8 @@
 #include "traverse.h"
 #include "memory.h"
 
-int (*tddescenders[])(tdesc_t *, tdtrav_data_t *);
-tdtrav_cb_f tdnops[];
+static int (*tddescenders[])(tdesc_t *, tdtrav_data_t *);
+static tdtrav_cb_f tdnops[];
 
 void
 tdtrav_init(tdtrav_data_t *tdtd, int *vgenp, tdtrav_cb_f *firstops,
@@ -111,7 +112,7 @@
 	return (-1);
 }
 
-tdtrav_cb_f tdnops[] = {
+static tdtrav_cb_f tdnops[] = {
 	NULL,
 	NULL,			/* intrinsic */
 	NULL,			/* pointer */
@@ -128,7 +129,7 @@
 	NULL			/* restrict */
 };
 
-int (*tddescenders[])(tdesc_t *, tdtrav_data_t *) = {
+static int (*tddescenders[])(tdesc_t *, tdtrav_data_t *) = {
 	NULL,
 	NULL,			/* intrinsic */
 	tdtrav_plain,		/* pointer */

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *

Modified: trunk/cddl/contrib/opensolaris/tools/ctf/cvt/util.c
===================================================================
--- trunk/cddl/contrib/opensolaris/tools/ctf/cvt/util.c	2018-06-02 15:58:17 UTC (rev 10224)
+++ trunk/cddl/contrib/opensolaris/tools/ctf/cvt/util.c	2018-06-02 15:59:09 UTC (rev 10225)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * CDDL HEADER START
  *
@@ -171,7 +172,7 @@
 	whine("ERROR", format, ap);
 	va_end(ap);
 
-#if defined(sun)
+#ifdef illumos
 	abort();
 #else
 	exit(0);
@@ -249,8 +250,8 @@
 	return (tdp->t_name == NULL ? "(anon)" : tdp->t_name);
 }
 
-char	*watch_address = NULL;
-int	watch_length = 0;
+static char	*watch_address = NULL;
+static int	watch_length = 0;
 
 void
 watch_set(void *addr, int len)



More information about the Midnightbsd-cvs mailing list