CVS commit: src/external/gpl3/binutils/usr.sbin/mdsetimage

2017-07-25 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Jul 25 06:43:03 UTC 2017

Modified Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: bin_bfd.c

Log Message:
initialise some stack variables to zero so that later checking ensures
they are considered "unfound" instead of some random value.

part 1 in fixing the CI20 kernel build.  this one actually will cause
the build to fail, but it's outputting broken objects right now anyway.
part 2 coming up in the CI20 configuration itself.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.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/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c
diff -u src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c:1.1 src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c:1.2
--- src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c:1.1	Wed Sep 21 21:52:26 2016
+++ src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c	Tue Jul 25 06:43:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bin_bfd.c,v 1.1 2016/09/21 21:52:26 christos Exp $	*/
+/*	$NetBSD: bin_bfd.c,v 1.2 2017/07/25 06:43:03 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996, 2002 Christopher G. Demetriou
@@ -34,7 +34,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: bin_bfd.c,v 1.1 2016/09/21 21:52:26 christos Exp $");
+__RCSID("$NetBSD: bin_bfd.c,v 1.2 2017/07/25 06:43:03 mrg Exp $");
 
 #include 
 #include 
@@ -75,6 +75,8 @@ bin_find_md_root(void *bin, const char *
 		size_t offset;
 	} *s, symbols[3];
 
+	symbols[0].offset = 0;
+	symbols[1].offset = 0;
 	symbols[0].name = root_name;
 	symbols[1].name = size_name;
 	symbols[2].name = NULL;



CVS commit: src/external/gpl3/binutils/usr.sbin/mdsetimage

2016-09-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 22 01:53:39 UTC 2016

Modified Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: Makefile

Log Message:
Find bin.h


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile

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

Modified files:

Index: src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile
diff -u src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.12 src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.13
--- src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.12	Wed Sep 21 12:26:18 2016
+++ src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile	Wed Sep 21 21:53:39 2016
@@ -1,8 +1,9 @@
-#	$NetBSD: Makefile,v 1.12 2016/09/21 16:26:18 christos Exp $
+#	$NetBSD: Makefile,v 1.13 2016/09/22 01:53:39 christos Exp $
 
 .include 
 
-.PATH: ${NETBSDSRCDIR}/usr.sbin/mdsetimage
+MDSETIMAGE=${NETBSDSRCDIR}/usr.sbin/mdsetimage
+.PATH: ${MDSETIMAGE}
 
 .if (defined(HOSTPROG) && \
  (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN))) || \
@@ -13,7 +14,7 @@ PROG=		mdsetimage
 SRCS=		mdsetimage.c bin_bfd.c
 MAN=		mdsetimage.8
 
-CPPFLAGS+=	-I${DIST}/bfd -I${DIST}/binutils -I${DIST}/include
+CPPFLAGS+=	-I${DIST}/bfd -I${DIST}/binutils -I${DIST}/include -I${MDSETIMAGE}
 
 .if !defined(HOSTPROG)
 PROGDPLIBS+=	bfd	${TOP}/${BFDSUBDIR}/libbfd



CVS commit: src/external/gpl3/binutils/usr.sbin/mdsetimage

2016-09-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 21 21:52:26 UTC 2016

Added Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: bin_bfd.c

Log Message:
move from /usr/src/usr.sbin/mdsetimage


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c

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

Added files:

Index: src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c
diff -u /dev/null src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c:1.1
--- /dev/null	Wed Sep 21 17:52:26 2016
+++ src/external/gpl3/binutils/usr.sbin/mdsetimage/bin_bfd.c	Wed Sep 21 17:52:26 2016
@@ -0,0 +1,149 @@
+/*	$NetBSD: bin_bfd.c,v 1.1 2016/09/21 21:52:26 christos Exp $	*/
+
+/*
+ * Copyright (c) 1996, 2002 Christopher G. Demetriou
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * <>
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include 
+__RCSID("$NetBSD: bin_bfd.c,v 1.1 2016/09/21 21:52:26 christos Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "bin.h"
+
+void *
+bin_open(int kfd, const char *kfile, const char *bfdname)
+{
+	bfd *abfd;
+	bfd_init();
+	if ((abfd = bfd_fdopenr(kfile, bfdname, kfd)) == NULL) {
+		bfd_perror("open");
+		exit(1);
+	}
+	if (!bfd_check_format(abfd, bfd_object)) {
+		bfd_perror("check format");
+		exit(1);
+	}
+	return abfd;
+}
+
+int
+bin_find_md_root(void *bin, const char *mappedkfile, off_t size,
+unsigned long text_start,
+const char *root_name, const char *size_name, size_t *md_root_offset,
+size_t *md_root_size_offset, uint32_t *md_root_size, int verbose)
+{
+	bfd *abfd = bin;
+	long i;
+	long storage_needed;
+	long number_of_symbols;
+	asymbol **symbol_table = NULL;
+	struct symbols {
+		const char *name;
+		size_t offset;
+	} *s, symbols[3];
+
+	symbols[0].name = root_name;
+	symbols[1].name = size_name;
+	symbols[2].name = NULL;
+
+	storage_needed = bfd_get_symtab_upper_bound(abfd);
+	if (storage_needed <= 0) {
+		warnx("bfd storage needed error");
+		return 1;
+	}
+
+	symbol_table = malloc(storage_needed);
+	if (symbol_table == NULL) {
+		warn("symbol table");
+		return 1;
+	}
+
+	number_of_symbols = bfd_canonicalize_symtab(abfd, symbol_table);
+	if (number_of_symbols <= 0) {
+		warnx("can't canonicalize symbol table");
+		free(symbol_table);
+		return 1;
+	}
+
+	for (i = 0; i < number_of_symbols; i++) {
+		for (s = symbols; s->name != NULL; s++) {
+			const char *sym = symbol_table[i]->name;
+
+			/*
+			 * match symbol prefix '_' or ''.
+			 */
+			if (!strcmp(s->name, sym) ||
+			!strcmp(s->name + 1, sym)) {
+s->offset =
+(size_t)(symbol_table[i]->section->filepos
++ symbol_table[i]->value);
+			}
+		}
+	}
+
+	free(symbol_table);
+
+	for (s = symbols; s->name != NULL; s++) {
+		if (s->offset == 0) {
+			warnx("missing offset for `%s'", s->name);
+			return 1;
+		}
+	}
+
+	*md_root_offset = symbols[0].offset;
+	*md_root_size_offset = symbols[1].offset;
+	*md_root_size = bfd_get_32(abfd, [*md_root_size_offset]);
+
+	return 0;
+}
+
+void
+bin_put_32(void *bin, off_t size, char *buf)
+{
+	bfd_put_32((struct bfd *)bin, size, buf);
+}
+
+void
+bin_close(void *bin)
+{
+	bfd_close_all_done((struct bfd *)bin);
+}
+
+const char **
+bin_supported_targets(void)
+{
+	return bfd_target_list();
+}



CVS commit: src/external/gpl3/binutils/usr.sbin/mdsetimage

2016-09-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 21 16:26:18 UTC 2016

Modified Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: Makefile
Removed Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: mdsetimage.8
mdsetimage.c

Log Message:
remove dup


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile
cvs rdiff -u -r1.3 -r0 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8
cvs rdiff -u -r1.4 -r0 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.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/gpl3/binutils/usr.sbin/mdsetimage/Makefile
diff -u src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.11 src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.12
--- src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.11	Tue Jan 26 14:37:49 2016
+++ src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile	Wed Sep 21 12:26:18 2016
@@ -1,6 +1,8 @@
-#	$NetBSD: Makefile,v 1.11 2016/01/26 19:37:49 christos Exp $
+#	$NetBSD: Makefile,v 1.12 2016/09/21 16:26:18 christos Exp $
 
-.include 
+.include 
+
+.PATH: ${NETBSDSRCDIR}/usr.sbin/mdsetimage
 
 .if (defined(HOSTPROG) && \
  (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN))) || \
@@ -8,6 +10,7 @@
 BFDSUBDIR=	lib
 
 PROG=		mdsetimage
+SRCS=		mdsetimage.c bin_bfd.c
 MAN=		mdsetimage.8
 
 CPPFLAGS+=	-I${DIST}/bfd -I${DIST}/binutils -I${DIST}/include



CVS commit: src/external/gpl3/binutils/usr.sbin/mdsetimage

2016-09-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 21 01:33:42 UTC 2016

Modified Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: mdsetimage.c

Log Message:
fix printf format.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.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/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c
diff -u src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c:1.3 src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c:1.4
--- src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c:1.3	Tue Sep 20 16:57:45 2016
+++ src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c	Tue Sep 20 21:33:42 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: mdsetimage.c,v 1.3 2016/09/20 20:57:45 christos Exp $ */
+/* $NetBSD: mdsetimage.c,v 1.4 2016/09/21 01:33:42 christos Exp $ */
 /* from: NetBSD: mdsetimage.c,v 1.15 2001/03/21 23:46:48 cgd Exp $ */
 
 /*
@@ -38,7 +38,7 @@
 #if !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1996\
  Christopher G. Demetriou.  All rights reserved.");
-__RCSID("$NetBSD: mdsetimage.c,v 1.3 2016/09/20 20:57:45 christos Exp $");
+__RCSID("$NetBSD: mdsetimage.c,v 1.4 2016/09/21 01:33:42 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -168,7 +168,7 @@ main(int argc, char *argv[])
 	md_root_size = bfd_get_32(abfd, [md_root_size_offset]);
 
 	if (verbose)
-		fprintf(stderr, "root @ %#zx/%zu\n",
+		fprintf(stderr, "root @ %#zx/%u\n",
 		md_root_offset, md_root_size);
 
 	munmap(mappedkfile, ksb.st_size);



CVS commit: src/external/gpl3/binutils/usr.sbin/mdsetimage

2016-09-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 20 20:57:45 UTC 2016

Modified Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: mdsetimage.c

Log Message:
Print more info.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.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/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c
diff -u src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c:1.2 src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c:1.3
--- src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c:1.2	Sat Nov  6 12:03:23 2010
+++ src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c	Tue Sep 20 16:57:45 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: mdsetimage.c,v 1.2 2010/11/06 16:03:23 uebayasi Exp $ */
+/* $NetBSD: mdsetimage.c,v 1.3 2016/09/20 20:57:45 christos Exp $ */
 /* from: NetBSD: mdsetimage.c,v 1.15 2001/03/21 23:46:48 cgd Exp $ */
 
 /*
@@ -38,7 +38,7 @@
 #if !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1996\
  Christopher G. Demetriou.  All rights reserved.");
-__RCSID("$NetBSD: mdsetimage.c,v 1.2 2010/11/06 16:03:23 uebayasi Exp $");
+__RCSID("$NetBSD: mdsetimage.c,v 1.3 2016/09/20 20:57:45 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -167,6 +167,10 @@ main(int argc, char *argv[])
 	md_root_size_offset = md_root_symbols[X_MD_ROOT_SIZE].offset;
 	md_root_size = bfd_get_32(abfd, [md_root_size_offset]);
 
+	if (verbose)
+		fprintf(stderr, "root @ %#zx/%zu\n",
+		md_root_offset, md_root_size);
+
 	munmap(mappedkfile, ksb.st_size);
 
 	if (extract) {
@@ -187,8 +191,8 @@ main(int argc, char *argv[])
 	}
 
 	if (verbose)
-		fprintf(stderr, "copying image %s %s %s\n", fsfile,
-		(extract ? "from" : "into"), kfile);
+		fprintf(stderr, "copying image %s %s %s (%zd bytes)\n", fsfile,
+		(extract ? "from" : "into"), kfile, left_to_copy);
 
 	if (lseek(kfd, md_root_offset, SEEK_SET) != md_root_offset)
 		err(1, "seek %s", kfile);



CVS commit: src/external/gpl3/binutils/usr.sbin/mdsetimage

2013-02-18 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Mon Feb 18 15:32:02 UTC 2013

Modified Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: Makefile

Log Message:
Adjust blank lines.  Add comment about missing DPADD for -lz.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile

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

Modified files:

Index: src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile
diff -u src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.8 src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.9
--- src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile:1.8	Sun Feb 17 20:36:02 2013
+++ src/external/gpl3/binutils/usr.sbin/mdsetimage/Makefile	Mon Feb 18 15:32:02 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2013/02/17 20:36:02 christos Exp $
+#	$NetBSD: Makefile,v 1.9 2013/02/18 15:32:02 gdt Exp $
 
 .include bsd.own.mk
 
@@ -35,6 +35,8 @@ LDADD+=		-lintl
 DPADD+=		${LIBINTL}
 DPADD+=		${LIBZ}
 .endif # HOSTPROG
+
 LDADD+=		-lz
-.endif # MKBINUTILS != no
+# No DPADD because we don't know the format and we didn't build it.
 
+.endif # MKBINUTILS != no



CVS commit: src/external/gpl3/binutils/usr.sbin/mdsetimage

2010-11-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Nov  7 11:50:23 UTC 2010

Modified Files:
src/external/gpl3/binutils/usr.sbin/mdsetimage: mdsetimage.8

Log Message:
Sort options.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8

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

Modified files:

Index: src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8
diff -u src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8:1.2 src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8:1.3
--- src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8:1.2	Sat Nov  6 16:03:23 2010
+++ src/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8	Sun Nov  7 11:50:23 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: mdsetimage.8,v 1.2 2010/11/06 16:03:23 uebayasi Exp $
+.\	$NetBSD: mdsetimage.8,v 1.3 2010/11/07 11:50:23 wiz Exp $
 .\
 .\ Copyright (c) 1996 Christopher G. Demetriou
 .\ All rights reserved.
@@ -36,9 +36,9 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl svx
+.Op Fl b Ar bfdname
 .Op Fl I Ar image_symbol
 .Op Fl S Ar size_symbol
-.Op Fl b Ar bfdname
 .Ar kernel
 .Ar image
 .Sh DESCRIPTION
@@ -53,6 +53,10 @@
 will typically be used by the kernel
 as the root file system.
 .Pp
+To recognize kernel executable format, the
+.Fl b
+flag specifies BFD name of kernel.
+.Pp
 The
 .Fl I
 and
@@ -60,10 +64,6 @@
 flags specify the symbol names of image and size of memory disk
 drivers respectively.
 .Pp
-To recognize kernel executable format, the
-.Fl b
-flag specifies BFD name of kernel.
-.Pp
 If the
 .Fl s
 flags is given,