CVS commit: src/external/cddl/osnet/dist/lib/libctf/common

2020-09-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Sep  6 16:44:17 UTC 2020

Modified Files:
src/external/cddl/osnet/dist/lib/libctf/common: ctf_lib.c

Log Message:
fix zeroing


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c
diff -u src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c:1.8 src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c:1.9
--- src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c:1.8	Thu Aug 20 11:54:11 2020
+++ src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c	Sun Sep  6 12:44:16 2020
@@ -234,7 +234,7 @@ ctf_fdopen(int fd, int *errp)
 	bzero(, sizeof (ctf_sect_t));
 	bzero(, sizeof (ctf_sect_t));
 	bzero(, sizeof (ctf_sect_t));
-	bzero(, sizeof (hdr));
+	bzero(, sizeof (hdr));
 
 	if (fstat64(fd, ) == -1)
 		return (ctf_set_open_errno(errp, errno));



CVS commit: src/external/cddl/osnet/dist/lib/libctf/common

2015-09-29 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Sep 29 06:33:01 UTC 2015

Modified Files:
src/external/cddl/osnet/dist/lib/libctf/common: ctf.5

Log Message:
Remove reference to mdb(1).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dist/lib/libctf/common/ctf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dist/lib/libctf/common/ctf.5
diff -u src/external/cddl/osnet/dist/lib/libctf/common/ctf.5:1.2 src/external/cddl/osnet/dist/lib/libctf/common/ctf.5:1.3
--- src/external/cddl/osnet/dist/lib/libctf/common/ctf.5:1.2	Mon Sep 28 22:00:26 2015
+++ src/external/cddl/osnet/dist/lib/libctf/common/ctf.5	Tue Sep 29 06:33:01 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: ctf.5,v 1.2 2015/09/28 22:00:26 wiz Exp $
+.\" $NetBSD: ctf.5,v 1.3 2015/09/29 06:33:01 wiz Exp $
 .\"
 .\" This file and its contents are supplied under the terms of the
 .\" Common Development and Distribution License ("CDDL"), version 1.0.
@@ -56,10 +56,11 @@ file itself, it may also be referred to 
 On illumos systems,
 .Nm
 data is consumed by multiple programs.
-It can be used by the modular
-debugger,
-.Xr mdb 1 ,
-as well as by
+It can be used by
+.\" the modular
+.\" debugger,
+.\" .Xr mdb 1 ,
+.\" as well as by
 .Xr dtrace 1 .
 Programmatic access to
 .Nm



CVS commit: src/external/cddl/osnet/dist/lib/libctf/common

2015-09-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Sep 28 22:00:26 UTC 2015

Modified Files:
src/external/cddl/osnet/dist/lib/libctf/common: ctf.5

Log Message:
Fix Dt. New sentence, new line. Fix xrefs.

Still leaves:
trailing Xref to mdb(1)
trailing Xref to libctf(3)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dist/lib/libctf/common/ctf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dist/lib/libctf/common/ctf.5
diff -u src/external/cddl/osnet/dist/lib/libctf/common/ctf.5:1.1 src/external/cddl/osnet/dist/lib/libctf/common/ctf.5:1.2
--- src/external/cddl/osnet/dist/lib/libctf/common/ctf.5:1.1	Thu Sep 24 14:20:18 2015
+++ src/external/cddl/osnet/dist/lib/libctf/common/ctf.5	Mon Sep 28 22:00:26 2015
@@ -1,3 +1,4 @@
+.\" $NetBSD: ctf.5,v 1.2 2015/09/28 22:00:26 wiz Exp $
 .\"
 .\" This file and its contents are supplied under the terms of the
 .\" Common Development and Distribution License ("CDDL"), version 1.0.
@@ -11,7 +12,7 @@
 .\"
 .\" Copyright (c) 2014 Joyent, Inc.
 .\"
-.Dd Sep 26, 2014
+.Dd September 26, 2014
 .Dt CTF 5
 .Os
 .Sh NAME
@@ -39,7 +40,8 @@ data contained in each file has informat
 sizes of C types, including intrinsic types, enumerations, structures,
 typedefs, and unions, that are used by the corresponding
 .Sy ELF
-object. The
+object.
+The
 .Nm
 data may also include information about the types of global objects and
 the return type and arguments of functions in the symbol table.
@@ -53,19 +55,21 @@ file itself, it may also be referred to 
 .Lp
 On illumos systems,
 .Nm
-data is consumed by multiple programs. It can be used by the modular
+data is consumed by multiple programs.
+It can be used by the modular
 debugger,
 .Xr mdb 1 ,
 as well as by
-.Xr dtrace 1M .
+.Xr dtrace 1 .
 Programmatic access to
 .Nm
 data can be obtained through
-.Xr libctf 3LIB .
+.Xr libctf 3 .
 .Lp
 The
 .Nm
-file format is broken down into seven different sections. The first
+file format is broken down into seven different sections.
+The first
 section is the
 .Sy preamble
 and
@@ -74,18 +78,22 @@ which describes the version of the
 .Nm
 file, links it has to other
 .Nm
-files, and the sizes of the other sections. The next section is the
+files, and the sizes of the other sections.
+The next section is the
 .Sy label
 section,
 which provides a way of identifying similar groups of
 .Nm
-data across multiple files. This is followed by the
+data across multiple files.
+This is followed by the
 .Sy object
 information section, which describes the type of global
-symbols. The subsequent section is the
+symbols.
+The subsequent section is the
 .Sy function
 information section, which describes the return
-types and arguments of functions. The next section is the
+types and arguments of functions.
+The next section is the
 .Sy type
 information section, which describes
 the format and layout of the C types themselves, and finally the last
@@ -106,28 +114,33 @@ A
 file may contain all of the type information that it requires, or it
 may optionally refer to another
 .Nm
-file which holds the remaining types. When a
+file which holds the remaining types.
+When a
 .Nm
 file refers to another file, it is called the
 .Sy child
 and the file it refers to is called the
 .Sy parent .
-A given file may only refer to one parent. This process is called
+A given file may only refer to one parent.
+This process is called
 .Em uniquification
 because it ensures each child only has type information that is
-unique to it. A common example of this is that most kernel modules in
+unique to it.
+A common example of this is that most kernel modules in
 illumos are uniquified against the kernel module
 .Sy genunix
 and the type information that comes from the
 .Sy IP
-module. This means that a module only has types that are unique to
+module.
+This means that a module only has types that are unique to
 itself and the most common types in the kernel are not duplicated.
 .Sh FILE FORMAT
 This documents version
 .Em two
 of the
 .Nm
-file format. All applications and tools currently produce and operate on
+file format.
+All applications and tools currently produce and operate on
 this version.
 .Lp
 The file format can be summarized with the following image, the
@@ -235,25 +248,31 @@ This
 .Sy preamble
 defines the version of the
 .Nm
-file which defines the format of the rest of the header. While the
+file which defines the format of the rest of the header.
+While the
 header may change in subsequent versions, the preamble will not change
 across versions, though the interpretation of its flags may change from
-version to version. The
+version to version.
+The
 .Em ctp_magic
 member defines the magic number for the
 .Nm
-file format. This must always be
+file format.
+This must always be
 .Li 0xcff1 .
 If another value is encountered, then the file should not be 

CVS commit: src/external/cddl/osnet/dist/lib/libctf/common

2015-09-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 24 14:20:18 UTC 2015

Modified Files:
src/external/cddl/osnet/dist/lib/libctf/common: ctf_lib.c ctf_subr.c
Added Files:
src/external/cddl/osnet/dist/lib/libctf/common: ctf.5

Log Message:
Sync with FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/dist/lib/libctf/common/ctf.5
cvs rdiff -u -r1.5 -r1.6 \
src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/lib/libctf/common/ctf_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c
diff -u src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c:1.5 src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c:1.6
--- src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c:1.5	Sat Feb  7 15:30:03 2015
+++ src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c	Thu Sep 24 10:20:18 2015
@@ -38,14 +38,14 @@
 #include 
 #include 
 #include 
-#if defined(sun)
+#ifdef illumos
 #include 
 #else
 #include 
 #endif
 #include 
 
-#if defined(sun)
+#ifdef illumos
 #ifdef _LP64
 static const char *_libctf_zlib = "/usr/lib/64/libz.so";
 #else
@@ -62,7 +62,7 @@ static struct {
 static size_t _PAGESIZE;
 static size_t _PAGEMASK;
 
-#if defined(sun)
+#ifdef illumos
 #pragma init(_libctf_init)
 #else
 void_libctf_init(void) __attribute__ ((constructor));
@@ -70,7 +70,7 @@ void_libctf_init(void) __attribute__
 void
 _libctf_init(void)
 {
-#if defined(sun)
+#ifdef illumos
 	const char *p = getenv("LIBCTF_DECOMPRESSOR");
 
 	if (p != NULL)
@@ -91,7 +91,7 @@ _libctf_init(void)
 void *
 ctf_zopen(int *errp)
 {
-#if defined(sun)
+#ifdef illumos
 	ctf_dprintf("decompressing CTF data using %s\n", _libctf_zlib);
 
 	if (zlib.z_dlp != NULL)
@@ -220,6 +220,7 @@ ctf_fdopen(int fd, int *errp)
 {
 	ctf_sect_t ctfsect, symsect, strsect;
 	ctf_file_t *fp = NULL;
+	size_t shstrndx, shnum;
 
 	struct stat64 st;
 	ssize_t nbytes;
@@ -256,7 +257,7 @@ ctf_fdopen(int fd, int *errp)
 		if (ctfsect.cts_data == MAP_FAILED)
 			return (ctf_set_open_errno(errp, errno));
 
-		ctfsect.cts_name = __UNCONST(_CTF_SECTION);
+		ctfsect.cts_name = _CTF_SECTION;
 		ctfsect.cts_type = SHT_PROGBITS;
 		ctfsect.cts_flags = SHF_ALLOC;
 		ctfsect.cts_size = (size_t)st.st_size;
@@ -277,16 +278,15 @@ ctf_fdopen(int fd, int *errp)
 	 */
 	if (nbytes >= (ssize_t) sizeof (Elf32_Ehdr) &&
 	bcmp(_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
-#ifdef	_BIG_ENDIAN
+#if BYTE_ORDER == _BIG_ENDIAN
 		uchar_t order = ELFDATA2MSB;
 #else
 		uchar_t order = ELFDATA2LSB;
 #endif
-		GElf_Half i, n;
 		GElf_Shdr *sp;
 
 		void *strs_map;
-		size_t strs_mapsz;
+		size_t strs_mapsz, i;
 		char *strs;
 
 		if (hdr.e32.e_ident[EI_DATA] != order)
@@ -302,11 +302,38 @@ ctf_fdopen(int fd, int *errp)
 			ehdr_to_gelf(, );
 		}
 
-		if (hdr.e64.e_shstrndx >= hdr.e64.e_shnum)
+		shnum = hdr.e64.e_shnum;
+		shstrndx = hdr.e64.e_shstrndx;
+
+		/* Extended ELF sections */
+		if ((shstrndx == SHN_XINDEX) || (shnum == 0)) {
+			if (hdr.e32.e_ident[EI_CLASS] == ELFCLASS32) {
+Elf32_Shdr x32;
+
+if (pread64(fd, , sizeof (x32),
+hdr.e64.e_shoff) != sizeof (x32))
+	return (ctf_set_open_errno(errp,
+	errno));
+
+shnum = x32.sh_size;
+shstrndx = x32.sh_link;
+			} else {
+Elf64_Shdr x64;
+
+if (pread64(fd, , sizeof (x64),
+hdr.e64.e_shoff) != sizeof (x64))
+	return (ctf_set_open_errno(errp,
+	errno));
+
+shnum = x64.sh_size;
+shstrndx = x64.sh_link;
+			}
+		}
+
+		if (shstrndx >= shnum)
 			return (ctf_set_open_errno(errp, ECTF_CORRUPT));
 
-		n = hdr.e64.e_shnum;
-		nbytes = sizeof (GElf_Shdr) * n;
+		nbytes = sizeof (GElf_Shdr) * shnum;
 
 		if ((sp = malloc(nbytes)) == NULL)
 			return (ctf_set_open_errno(errp, errno));
@@ -318,7 +345,7 @@ ctf_fdopen(int fd, int *errp)
 		if (hdr.e32.e_ident[EI_CLASS] == ELFCLASS32) {
 			Elf32_Shdr *sp32;
 
-			nbytes = sizeof (Elf32_Shdr) * n;
+			nbytes = sizeof (Elf32_Shdr) * shnum;
 
 			if ((sp32 = malloc(nbytes)) == NULL || pread64(fd,
 			sp32, nbytes, hdr.e64.e_shoff) != nbytes) {
@@ -326,7 +353,7 @@ ctf_fdopen(int fd, int *errp)
 return (ctf_set_open_errno(errp, errno));
 			}
 
-			for (i = 0; i < n; i++)
+			for (i = 0; i < shnum; i++)
 shdr_to_gelf([i], [i]);
 
 			free(sp32);
@@ -340,14 +367,14 @@ ctf_fdopen(int fd, int *errp)
 		 * Now mmap the section header strings section so that we can
 		 * perform string comparison on the section names.
 		 */
-		strs_mapsz = sp[hdr.e64.e_shstrndx].sh_size +
-		(sp[hdr.e64.e_shstrndx].sh_offset & ~_PAGEMASK);
+		strs_mapsz = sp[shstrndx].sh_size +
+		(sp[shstrndx].sh_offset & ~_PAGEMASK);
 
 		strs_map = mmap64(NULL, strs_mapsz, PROT_READ, MAP_PRIVATE,
-		fd, sp[hdr.e64.e_shstrndx].sh_offset & _PAGEMASK);
+		fd,