CVS commit: src/usr.bin/elf2ecoff

2017-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Feb 24 17:19:14 UTC 2017

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
fix printf format


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.32 src/usr.bin/elf2ecoff/elf2ecoff.c:1.33
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.32	Fri Feb 24 08:03:25 2017
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Fri Feb 24 12:19:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.32 2017/02/24 13:03:25 christos Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.33 2017/02/24 17:19:14 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -247,7 +247,7 @@ usage:
 
 			if (debug) {
 fprintf(stderr, "  combinining PH %zu type %d "
-"flags 0x%x with data, ndata = %d, "
+"flags %#x with data, ndata = %d, "
 "nbss =%d\n", i, ph[i].p_type,
 ph[i].p_flags, ndata.len, nbss.len);
 			}
@@ -260,7 +260,7 @@ usage:
 			ntxt.len = ph[i].p_filesz;
 			if (debug) {
 fprintf(stderr, "  combinining PH %zu type %d "
-"flags 0x%x with text, len = %d\n",
+"flags %#x with text, len = %d\n",
 i, ph[i].p_type, ph[i].p_flags, ntxt.len);
 			}
 			combine(, , 0);
@@ -423,8 +423,8 @@ usage:
 
 
 	if (debug)
-		fprintf(stderr, "writing syms at offset 0x%lx\n",
-		(uint32_t) ep.f.f_symptr + sizeof(symhdr));
+		fprintf(stderr, "writing syms at offset %#x\n",
+		(uint32_t)(ep.f.f_symptr + sizeof(symhdr)));
 
 	/* Copy and translate the symbol table... */
 	elf_symbol_table_to_ecoff(outfile, infile, ,
@@ -590,7 +590,7 @@ write_ecoff_symhdr(int out, struct ecoff
 
 	if (debug)
 		fprintf(stderr,
-		"writing symhdr for %d entries at offset 0x%x\n",
+		"writing symhdr for %d entries at offset %#x\n",
 		nesyms, ep->f.f_symptr);
 
 	ep->f.f_nsyms = sizeof(struct ecoff32_symhdr);



CVS commit: src/usr.bin/elf2ecoff

2017-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Feb 24 13:03:25 UTC 2017

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
fix printf format.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.31 src/usr.bin/elf2ecoff/elf2ecoff.c:1.32
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.31	Thu Feb 23 13:49:00 2017
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Fri Feb 24 08:03:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.31 2017/02/23 18:49:00 christos Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.32 2017/02/24 13:03:25 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -512,7 +512,7 @@ saveRead(int file, off_t offset, off_t l
 	if ((off = lseek(file, offset, SEEK_SET)) < 0)
 		err(1, "%s: fseek", name);
 	if ((tmp = malloc(len)) == NULL)
-		err(1, "%s: Can't allocate %td bytes", name, len);
+		err(1, "%s: Can't allocate %jd bytes", name, (intmax_t)len);
 	count = read(file, tmp, len);
 	if (count != len)
 		err(1, "%s: short read", name);



CVS commit: src/usr.bin/elf2ecoff

2017-02-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 23 18:49:00 UTC 2017

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
This only works with 32 bit Elf and COFF files, make it specific this way
and use sized types so that it works on 64 bit systems (so it can become
a tool).


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.30 src/usr.bin/elf2ecoff/elf2ecoff.c:1.31
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.30	Sat Sep  3 07:35:24 2016
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Thu Feb 23 13:49:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.30 2016/09/03 11:35:24 christos Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.31 2017/02/23 18:49:00 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -56,8 +56,8 @@
 #define	ISLAST(p)	(p->n_un.n_name == 0 || p->n_un.n_name[0] == 0)
 
 struct sect {
-	unsigned long vaddr;
-	unsigned long len;
+	uint32_t vaddr;
+	uint32_t len;
 };
 
 struct elf_syms {
@@ -83,12 +83,12 @@ static voidsafewrite(int, const void
 static voidcopy(int, int, off_t, off_t);
 static voidcombine(struct sect *, struct sect *, int);
 static voidtranslate_syms(struct elf_syms *, struct ecoff_syms *);
-static voidelf_symbol_table_to_ecoff(int, int, struct ecoff_exechdr *,
+static voidelf_symbol_table_to_ecoff(int, int, struct ecoff32_exechdr *,
 off_t, off_t, off_t, off_t);
-static int make_ecoff_section_hdrs(struct ecoff_exechdr *,
-struct ecoff_scnhdr *);
-static voidwrite_ecoff_symhdr(int, struct ecoff_exechdr *,
-struct ecoff_symhdr *, long, long, long, long);
+static int make_ecoff_section_hdrs(struct ecoff32_exechdr *,
+struct ecoff32_scnhdr *);
+static voidwrite_ecoff_symhdr(int, struct ecoff32_exechdr *,
+struct ecoff32_symhdr *, int32_t, int32_t, int32_t, int32_t);
 static voidpad16(int, int, const char *);
 static voidbswap32_region(int32_t* , int);
 static voidelf_read_syms(struct elf_syms *, int, off_t, off_t, off_t,
@@ -107,12 +107,12 @@ main(int argc, char **argv)
 	int pad;
 	struct sect text, data, bss;	/* a.out-compatible sections */
 
-	struct ecoff_exechdr ep;
-	struct ecoff_scnhdr esecs[6];
-	struct ecoff_symhdr symhdr;
+	struct ecoff32_exechdr ep;
+	struct ecoff32_scnhdr esecs[6];
+	struct ecoff32_symhdr symhdr;
 
 	int infile, outfile;
-	unsigned long cur_vma = ULONG_MAX;
+	uint32_t cur_vma = UINT32_MAX;
 	int nsecs = 0;
 	int	mipsel;
 
@@ -247,8 +247,8 @@ usage:
 
 			if (debug) {
 fprintf(stderr, "  combinining PH %zu type %d "
-"flags 0x%x with data, ndata = %ld, "
-"nbss =%ld\n", i, ph[i].p_type,
+"flags 0x%x with data, ndata = %d, "
+"nbss =%d\n", i, ph[i].p_type,
 ph[i].p_flags, ndata.len, nbss.len);
 			}
 			combine(, , 0);
@@ -260,7 +260,7 @@ usage:
 			ntxt.len = ph[i].p_filesz;
 			if (debug) {
 fprintf(stderr, "  combinining PH %zu type %d "
-"flags 0x%x with text, len = %ld\n",
+"flags 0x%x with text, len = %d\n",
 i, ph[i].p_type, ph[i].p_flags, ntxt.len);
 			}
 			combine(, , 0);
@@ -312,7 +312,7 @@ usage:
 	ep.f.f_nscns = 6;
 	ep.f.f_timdat = 0;	/* bogus */
 	ep.f.f_symptr = 0;
-	ep.f.f_nsyms = sizeof(struct ecoff_symhdr);
+	ep.f.f_nsyms = sizeof(struct ecoff32_symhdr);
 	ep.f.f_opthdr = sizeof ep.a;
 	ep.f.f_flags = 0x100f;	/* Stripped, not sharable. */
 
@@ -395,13 +395,13 @@ usage:
 		 * that the section can be loaded before copying. */
 		if (ph[i].p_type == PT_LOAD && ph[i].p_filesz) {
 			if (cur_vma != ph[i].p_vaddr) {
-unsigned long gap = ph[i].p_vaddr - cur_vma;
+uint32_t gap = ph[i].p_vaddr - cur_vma;
 charobuf[1024];
 if (gap > 65536)
-	errx(1, "Intersegment gap (%ld bytes) "
+	errx(1, "Intersegment gap (%d bytes) "
 	"too large", gap);
 if (debug)
-	fprintf(stderr, "Warning: %ld byte "
+	fprintf(stderr, "Warning: %d byte "
 	"intersegment gap.\n", gap);
 memset(obuf, 0, sizeof obuf);
 while (gap) {
@@ -424,7 +424,7 @@ usage:
 
 	if (debug)
 		fprintf(stderr, "writing syms at offset 0x%lx\n",
-		(u_long) ep.f.f_symptr + sizeof(symhdr));
+		(uint32_t) ep.f.f_symptr + sizeof(symhdr));
 
 	/* Copy and translate the symbol table... */
 	elf_symbol_table_to_ecoff(outfile, infile, ,
@@ -512,7 +512,7 @@ saveRead(int file, off_t offset, off_t l
 	if ((off = lseek(file, offset, SEEK_SET)) < 0)
 		err(1, "%s: fseek", name);
 	if ((tmp = malloc(len)) == NULL)
-		err(1, "%s: Can't allocate %ld bytes", name, (long) len);
+		err(1, "%s: Can't allocate %td bytes", name, len);
 	count = read(file, tmp, len);
 	if (count != len)
 		err(1, "%s: short read", name);
@@ -535,7 +535,7 @@ safewrite(int outfile, const void *buf, 
  * for text, 

CVS commit: src/usr.bin/elf2ecoff

2016-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 11:35:24 UTC 2016

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
ignore the abiflags section


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.29 src/usr.bin/elf2ecoff/elf2ecoff.c:1.30
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.29	Sun Nov 10 12:14:25 2013
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Sat Sep  3 07:35:24 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.29 2013/11/10 17:14:25 christos Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.30 2016/09/03 11:35:24 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -217,23 +217,25 @@ usage:
 	(int (*) (const void *, const void *)) phcmp);
 
 	for (i = 0; i < ex.e_phnum; i++) {
-		/* Section types we can ignore... */
-		if (ph[i].p_type == PT_NULL || ph[i].p_type == PT_NOTE ||
-		ph[i].p_type == PT_PHDR ||
-		ph[i].p_type == PT_MIPS_REGINFO) {
-
+		switch (ph[i].p_type) {
+		case PT_NOTE:
+		case PT_NULL:
+		case PT_PHDR:
+		case PT_MIPS_ABIFLAGS:
+		case PT_MIPS_REGINFO:
+			/* Section types we can ignore... */
 			if (debug) {
-fprintf(stderr, "  skipping PH %zu type %d "
-"flags 0x%x\n",
+fprintf(stderr, "  skipping PH %zu type %#x "
+"flags %#x\n",
 i, ph[i].p_type, ph[i].p_flags);
 			}
 			continue;
-		}
-		/* Section types we can't handle... */
-		else
+		default:
+			/* Section types we can't handle... */
 			if (ph[i].p_type != PT_LOAD)
-errx(1, "Program header %zu type %d can't be "
+errx(1, "Program header %zu type %#x can't be "
 "converted", i, ph[i].p_type);
+		}
 		/* Writable (data) segment? */
 		if (ph[i].p_flags & PF_W) {
 			struct sect ndata, nbss;



CVS commit: src/usr.bin/elf2ecoff

2013-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 10 17:14:25 UTC 2013

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
remove unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.28 src/usr.bin/elf2ecoff/elf2ecoff.c:1.29
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.28	Tue Aug 23 16:27:22 2011
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Sun Nov 10 12:14:25 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.28 2011/08/23 20:27:22 christos Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.29 2013/11/10 17:14:25 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -106,7 +106,6 @@ main(int argc, char **argv)
 	size_t	i;
 	int pad;
 	struct sect text, data, bss;	/* a.out-compatible sections */
-	struct sect rdata, sdata, sbss;	/* ECOFF-only sections */
 
 	struct ecoff_exechdr ep;
 	struct ecoff_scnhdr esecs[6];
@@ -114,7 +113,6 @@ main(int argc, char **argv)
 
 	int infile, outfile;
 	unsigned long cur_vma = ULONG_MAX;
-	int symflag = 0;
 	int nsecs = 0;
 	int	mipsel;
 
@@ -122,9 +120,6 @@ main(int argc, char **argv)
 	text.len = data.len = bss.len = 0;
 	text.vaddr = data.vaddr = bss.vaddr = 0;
 
-	rdata.len = sdata.len = sbss.len = 0;
-	rdata.vaddr = sdata.vaddr = sbss.vaddr = 0;
-
 	/* Check args... */
 	if (argc  3 || argc  4) {
 usage:
@@ -136,7 +131,6 @@ usage:
 	if (argc == 4) {
 		if (strcmp(argv[3], -s))
 			goto usage;
-		symflag = 1;
 	}
 	/* Try the input file... */
 	if ((infile = open(argv[1], O_RDONLY))  0)
@@ -753,10 +747,9 @@ translate_syms(struct elf_syms *elfp, st
 	/* Copy and translate  symbols... */
 	idx = 0;
 	for (i = 0; i  nsyms; i++) {
-		int binding, type;
+		int binding;
 
 		binding = ELF32_ST_BIND((elfp-elf_syms[i].st_info));
-		type = ELF32_ST_TYPE((elfp-elf_syms[i].st_info));
 
 		/* skip strange symbols */
 		if (binding == 0) {



CVS commit: src/usr.bin/elf2ecoff

2011-08-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 23 20:27:22 UTC 2011

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
misc knf cleanup.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.27 src/usr.bin/elf2ecoff/elf2ecoff.c:1.28
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.27	Tue Jun 28 09:13:15 2011
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Tue Aug 23 16:27:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.27 2011/06/28 13:13:15 tsutsui Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.28 2011/08/23 20:27:22 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -74,45 +74,29 @@
 	char   *stringtab;
 };
 
-int debug = 0;
+static int debug = 0;
+static int needswap;
 
-int phcmp(Elf32_Phdr * h1, Elf32_Phdr * h2);
-
-
-char   *saveRead(int file, off_t offset, off_t len, const char *name);
-voidsafewrite(int outfile, const void *buf, off_t len, const char *msg);
-voidcopy(int, int, off_t, off_t);
-voidcombine(struct sect * base, struct sect * new, int paddable);
-voidtranslate_syms(struct elf_syms *, struct ecoff_syms *);
-void	elf_symbol_table_to_ecoff(int out, int in,
-	struct ecoff_exechdr * ep,
-	off_t symoff, off_t symsize,
-	off_t stroff, off_t strsize);
-
-
-int	make_ecoff_section_hdrs(struct ecoff_exechdr * ep,
-	struct ecoff_scnhdr * esecs);
-
-void	write_ecoff_symhdr(int outfile, struct ecoff_exechdr * ep,
-	struct ecoff_symhdr * symhdrp,
-	long nesyms, long extsymoff, long extstroff,
-	long strsize);
-
-voidpad16(int fd, int size, const char *msg);
-void	bswap32_region(int32_t* , int);
-
-int*symTypeTable;
-int	needswap;
-
-
-
-
-void	elf_read_syms(struct elf_syms * elfsymsp, int infile,
-	off_t symoff, off_t symsize, off_t stroff, off_t strsize);
+static int phcmp(Elf32_Phdr *, Elf32_Phdr *);
+static char   *saveRead(int, off_t, off_t, const char *);
+static voidsafewrite(int, const void *, off_t, const char *);
+static voidcopy(int, int, off_t, off_t);
+static voidcombine(struct sect *, struct sect *, int);
+static voidtranslate_syms(struct elf_syms *, struct ecoff_syms *);
+static voidelf_symbol_table_to_ecoff(int, int, struct ecoff_exechdr *,
+off_t, off_t, off_t, off_t);
+static int make_ecoff_section_hdrs(struct ecoff_exechdr *,
+struct ecoff_scnhdr *);
+static voidwrite_ecoff_symhdr(int, struct ecoff_exechdr *,
+struct ecoff_symhdr *, long, long, long, long);
+static voidpad16(int, int, const char *);
+static voidbswap32_region(int32_t* , int);
+static voidelf_read_syms(struct elf_syms *, int, off_t, off_t, off_t,
+off_t);
 
 
 int
-main(int argc, char **argv, char **envp)
+main(int argc, char **argv)
 {
 	Elf32_Ehdr ex;
 	Elf32_Phdr *ph;
@@ -145,7 +129,8 @@
 	if (argc  3 || argc  4) {
 usage:
 		fprintf(stderr,
-		usage: elf2ecoff elf executable ECOFF executable [-s]\n);
+		Usage: %s elf executable ECOFF executable [-s]\n,
+		getprogname());
 		exit(1);
 	}
 	if (argc == 4) {
@@ -154,27 +139,18 @@
 		symflag = 1;
 	}
 	/* Try the input file... */
-	if ((infile = open(argv[1], O_RDONLY))  0) {
-		fprintf(stderr, Can't open %s for read: %s\n,
-		argv[1], strerror(errno));
-		exit(1);
-	}
+	if ((infile = open(argv[1], O_RDONLY))  0)
+		err(1, Can't open %s for read, argv[1]);
 	/* Read the header, which is at the beginning of the file... */
 	i = read(infile, ex, sizeof ex);
-	if (i != sizeof ex) {
-		fprintf(stderr, ex: %s: %s.\n,
-		argv[1], i ? strerror(errno) : End of file reached);
-		exit(1);
-	}
+	if (i != sizeof ex)
+		err(1, Short header read from %s, argv[1]);
 	if (ex.e_ident[EI_DATA] == ELFDATA2LSB)
 		mipsel = 1;
 	else if (ex.e_ident[EI_DATA] == ELFDATA2MSB)
 		mipsel = 0;
-	else {
-		fprintf(stderr, invalid ELF byte order %d\n,
-		ex.e_ident[EI_DATA]);
-		exit(1);
-	}
+	else
+		errx(1, invalid ELF byte order %d, ex.e_ident[EI_DATA]);
 #if BYTE_ORDER == BIG_ENDIAN
 	if (mipsel)
 		needswap = 1;
@@ -235,11 +211,13 @@
 
 	}
 
-	/* Figure out if we can cram the program header into an ECOFF
+	/*
+	 * Figure out if we can cram the program header into an ECOFF
 	 * header...  Basically, we can't handle anything but loadable
 	 * segments, but we can ignore some kinds of segments.  We can't
 	 * handle holes in the address space.  Segments may be out of order,
-	 * so we sort them first. */
+	 * so we sort them first.
+	 */
 
 	qsort(ph, ex.e_phnum, sizeof(Elf32_Phdr),
 	(int (*) (const void *, const void *)) phcmp);
@@ -251,18 +229,17 @@
 		ph[i].p_type == PT_MIPS_REGINFO) {
 
 			if (debug) {
-fprintf(stderr,   skipping PH %zu type %d flags 0x%x\n,
+fprintf(stderr,   skipping PH %zu type %d 
+flags 0x%x\n,
  

CVS commit: src/usr.bin/elf2ecoff

2011-06-28 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jun 28 13:13:16 UTC 2011

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
ANSIfy, KNF, misc cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.26 src/usr.bin/elf2ecoff/elf2ecoff.c:1.27
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.26	Sat Dec 19 10:27:13 2009
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Tue Jun 28 13:13:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.26 2009/12/19 10:27:13 tsutsui Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.27 2011/06/28 13:13:15 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -84,22 +84,19 @@
 voidcopy(int, int, off_t, off_t);
 voidcombine(struct sect * base, struct sect * new, int paddable);
 voidtranslate_syms(struct elf_syms *, struct ecoff_syms *);
-void 
-elf_symbol_table_to_ecoff(int out, int in,
-struct ecoff_exechdr * ep,
-off_t symoff, off_t symsize,
-off_t stroff, off_t strsize);
-
-
-int 
-make_ecoff_section_hdrs(struct ecoff_exechdr * ep,
-struct ecoff_scnhdr * esecs);
-
-void 
-write_ecoff_symhdr(int outfile, struct ecoff_exechdr * ep,
-struct ecoff_symhdr * symhdrp,
-long nesyms, long extsymoff, long extstroff,
-long strsize);
+void	elf_symbol_table_to_ecoff(int out, int in,
+	struct ecoff_exechdr * ep,
+	off_t symoff, off_t symsize,
+	off_t stroff, off_t strsize);
+
+
+int	make_ecoff_section_hdrs(struct ecoff_exechdr * ep,
+	struct ecoff_scnhdr * esecs);
+
+void	write_ecoff_symhdr(int outfile, struct ecoff_exechdr * ep,
+	struct ecoff_symhdr * symhdrp,
+	long nesyms, long extsymoff, long extstroff,
+	long strsize);
 
 voidpad16(int fd, int size, const char *msg);
 void	bswap32_region(int32_t* , int);
@@ -110,9 +107,8 @@
 
 
 
-void
-elf_read_syms(struct elf_syms * elfsymsp, int infile,
-off_t symoff, off_t symsize, off_t stroff, off_t strsize);
+void	elf_read_syms(struct elf_syms * elfsymsp, int infile,
+	off_t symoff, off_t symsize, off_t stroff, off_t strsize);
 
 
 int
@@ -309,7 +305,7 @@
 	/* If there's a data section but no text section, then the loader
 	 * combined everything into one section.   That needs to be the text
 	 * section, so just make the data section zero length following text. */
-	if (data.len  !text.len) {
+	if (data.len  text.len == 0) {
 		text = data;
 		data.vaddr = text.vaddr + text.len;
 		data.len = 0;
@@ -486,9 +482,7 @@
 }
 
 void
-copy(out, in, offset, size)
-	int out, in;
-	off_t   offset, size;
+copy(int out, int in, off_t offset, off_t size)
 {
 	charibuf[4096];
 	size_t  remaining, cur, count;
@@ -515,11 +509,10 @@
 /* Combine two segments, which must be contiguous.   If pad is true, it's
okay for there to be padding between. */
 void
-combine(base, new, pad)
-	struct sect *base, *new;
-	int pad;
+combine(struct sect *base, struct sect *new, int pad)
 {
-	if (!base-len)
+
+	if (base-len == 0)
 		*base = *new;
 	else
 		if (new-len) {
@@ -537,9 +530,9 @@
 }
 
 int
-phcmp(h1, h2)
-	Elf32_Phdr *h1, *h2;
+phcmp(Elf32_Phdr *h1, Elf32_Phdr *h2)
 {
+
 	if (h1-p_vaddr  h2-p_vaddr)
 		return 1;
 	else
@@ -549,18 +542,18 @@
 			return 0;
 }
 
-char
-   *
+char *
 saveRead(int file, off_t offset, off_t len, const char *name)
 {
 	char   *tmp;
 	int count;
 	off_t   off;
+
 	if ((off = lseek(file, offset, SEEK_SET))  0) {
 		fprintf(stderr, %s: fseek: %s\n, name, strerror(errno));
 		exit(1);
 	}
-	if (!(tmp = (char *) malloc(len))) {
+	if ((tmp = malloc(len)) == NULL) {
 		fprintf(stderr, %s: Can't allocate %ld bytes.\n, name, (long) len);
 		exit(1);
 	}
@@ -577,6 +570,7 @@
 safewrite(int outfile, const void *buf, off_t len, const char *msg)
 {
 	int written;
+
 	written = write(outfile, buf, len);
 	if (written != len) {
 		fprintf(stderr, msg, strerror(errno));
@@ -590,11 +584,9 @@
  * for text, data, and bss.
  */
 int
-make_ecoff_section_hdrs(ep, esecs)
-	struct ecoff_exechdr *ep;
-	struct ecoff_scnhdr *esecs;
-
+make_ecoff_section_hdrs(struct ecoff_exechdr *ep, struct ecoff_scnhdr *esecs)
 {
+
 	ep-f.f_nscns = 6;	/* XXX */
 
 	strcpy(esecs[0].s_name, .text);
@@ -640,12 +632,11 @@
  * Mark all symbols as EXTERN (for now).
  */
 void
-write_ecoff_symhdr(out, ep, symhdrp, nesyms, extsymoff, extstroff, strsize)
-	int out;
-	struct ecoff_exechdr *ep;
-	struct ecoff_symhdr *symhdrp;
-	longnesyms, extsymoff, extstroff, strsize;
+write_ecoff_symhdr(int out, struct ecoff_exechdr *ep,
+struct ecoff_symhdr *symhdrp, long nesyms,
+long extsymoff, long extstroff, long strsize)
 {
+
 	if (debug)
 		fprintf(stderr, writing symhdr for %ld entries at offset 0x%lx\n,
 		nesyms, (u_long) ep-f.f_symptr);
@@ -672,18 +663,15 @@
 		symhdrp-magic = 

CVS commit: src/usr.bin/elf2ecoff

2009-12-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Dec 19 10:27:13 UTC 2009

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
Use %zu for size_t, not %zd.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.25 src/usr.bin/elf2ecoff/elf2ecoff.c:1.26
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.25	Mon Dec 14 14:11:32 2009
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Sat Dec 19 10:27:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.25 2009/12/14 14:11:32 uebayasi Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.26 2009/12/19 10:27:13 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -255,7 +255,7 @@
 		ph[i].p_type == PT_MIPS_REGINFO) {
 
 			if (debug) {
-fprintf(stderr,   skipping PH %zd type %d flags 0x%x\n,
+fprintf(stderr,   skipping PH %zu type %d flags 0x%x\n,
 i, ph[i].p_type, ph[i].p_flags);
 			}
 			continue;
@@ -263,7 +263,7 @@
 		/* Section types we can't handle... */
 		else
 			if (ph[i].p_type != PT_LOAD) {
-fprintf(stderr, Program header %zd type %d can't be converted.\n,
+fprintf(stderr, Program header %zu type %d can't be converted.\n,
 i, ph[i].p_type);
 exit(1);
 			}
@@ -278,7 +278,7 @@
 
 			if (debug) {
 fprintf(stderr,
-  combinining PH %zd type %d flags 0x%x with data, ndata = %ld, nbss =%ld\n, i, ph[i].p_type, ph[i].p_flags, ndata.len, nbss.len);
+  combinining PH %zu type %d flags 0x%x with data, ndata = %ld, nbss =%ld\n, i, ph[i].p_type, ph[i].p_flags, ndata.len, nbss.len);
 			}
 			combine(data, ndata, 0);
 			combine(bss, nbss, 1);
@@ -290,7 +290,7 @@
 			if (debug) {
 
 fprintf(stderr,
-  combinining PH %zd type %d flags 0x%x with text, len = %ld\n,
+  combinining PH %zu type %d flags 0x%x with text, len = %ld\n,
 i, ph[i].p_type, ph[i].p_flags, ntxt.len);
 			}
 			combine(text, ntxt, 0);



CVS commit: src/usr.bin/elf2ecoff

2009-12-14 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Mon Dec 14 14:11:32 UTC 2009

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
Adjust size_t format specifiers for mips64e[bl].


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.24 src/usr.bin/elf2ecoff/elf2ecoff.c:1.25
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.24	Mon Dec 14 00:43:05 2009
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Mon Dec 14 14:11:32 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.24 2009/12/14 00:43:05 matt Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.25 2009/12/14 14:11:32 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -255,7 +255,7 @@
 		ph[i].p_type == PT_MIPS_REGINFO) {
 
 			if (debug) {
-fprintf(stderr,   skipping PH %d type %d flags 0x%x\n,
+fprintf(stderr,   skipping PH %zd type %d flags 0x%x\n,
 i, ph[i].p_type, ph[i].p_flags);
 			}
 			continue;
@@ -263,7 +263,7 @@
 		/* Section types we can't handle... */
 		else
 			if (ph[i].p_type != PT_LOAD) {
-fprintf(stderr, Program header %d type %d can't be converted.\n,
+fprintf(stderr, Program header %zd type %d can't be converted.\n,
 i, ph[i].p_type);
 exit(1);
 			}
@@ -278,7 +278,7 @@
 
 			if (debug) {
 fprintf(stderr,
-  combinining PH %d type %d flags 0x%x with data, ndata = %ld, nbss =%ld\n, i, ph[i].p_type, ph[i].p_flags, ndata.len, nbss.len);
+  combinining PH %zd type %d flags 0x%x with data, ndata = %ld, nbss =%ld\n, i, ph[i].p_type, ph[i].p_flags, ndata.len, nbss.len);
 			}
 			combine(data, ndata, 0);
 			combine(bss, nbss, 1);
@@ -290,7 +290,7 @@
 			if (debug) {
 
 fprintf(stderr,
-  combinining PH %d type %d flags 0x%x with text, len = %ld\n,
+  combinining PH %zd type %d flags 0x%x with text, len = %ld\n,
 i, ph[i].p_type, ph[i].p_flags, ntxt.len);
 			}
 			combine(text, ntxt, 0);



CVS commit: src/usr.bin/elf2ecoff

2009-12-13 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Dec 14 00:43:06 UTC 2009

Modified Files:
src/usr.bin/elf2ecoff: Makefile elf2ecoff.c

Log Message:
Merge from matt-nb5-mips64


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/elf2ecoff/Makefile
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/Makefile
diff -u src/usr.bin/elf2ecoff/Makefile:1.10 src/usr.bin/elf2ecoff/Makefile:1.11
--- src/usr.bin/elf2ecoff/Makefile:1.10	Sun May 18 07:57:34 2003
+++ src/usr.bin/elf2ecoff/Makefile	Mon Dec 14 00:43:05 2009
@@ -1,10 +1,13 @@
-#	$NetBSD: Makefile,v 1.10 2003/05/18 07:57:34 lukem Exp $
+#	$NetBSD: Makefile,v 1.11 2009/12/14 00:43:05 matt Exp $
 #	from: @(#)Makefile	5.4 (Berkeley) 5/11/90
 
 .include bsd.own.mk
 
+ABI64:=  ${CPUFLAGS:M-mabi=64:M-mabi=o64}
 # Build ELF to {ecoff, aout} tools on mips, for old bootblocks/PROMs.
-.if (${MACHINE_ARCH} == mipsel || ${MACHINE_ARCH} == mipseb)
+.if (${MACHINE_ARCH} == mipsel || ${MACHINE_ARCH} == mipseb || \
+ ((${MACHINE_ARCH} == mips64el || ${MACHINE_ARCH} == mips64eb)  \
+  !defined(HOSTPROG)  empty(ABI64)))
 
 PROG=	elf2ecoff
 

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.23 src/usr.bin/elf2ecoff/elf2ecoff.c:1.24
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.23	Thu Apr 23 14:49:32 2009
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Mon Dec 14 00:43:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.23 2009/04/23 14:49:32 tsutsui Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.24 2009/12/14 00:43:05 matt Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -400,16 +400,16 @@
 	/* Write the headers... */
 	safewrite(outfile, ep.f, sizeof(ep.f), ep.f: write: %s\n);
 	if (debug)
-		fprintf(stderr, wrote %d byte file header.\n, sizeof(ep.f));
+		fprintf(stderr, wrote %zu byte file header.\n, sizeof(ep.f));
 
 	safewrite(outfile, ep.a, sizeof(ep.a), ep.a: write: %s\n);
 	if (debug)
-		fprintf(stderr, wrote %d byte a.out header.\n, sizeof(ep.a));
+		fprintf(stderr, wrote %zu byte a.out header.\n, sizeof(ep.a));
 
 	safewrite(outfile, esecs, sizeof(esecs[0]) * nsecs,
 	esecs: write: %s\n);
 	if (debug)
-		fprintf(stderr, wrote %d bytes of section headers.\n,
+		fprintf(stderr, wrote %zu bytes of section headers.\n,
 		sizeof(esecs[0]) * nsecs);
 
 
@@ -661,7 +661,7 @@
 	symhdrp-issExtMax = strsize;
 	if (debug)
 		fprintf(stderr,
-		ECOFF symhdr: symhdr %x, strsize %lx, symsize %lx\n,
+		ECOFF symhdr: symhdr %zx, strsize %lx, symsize %lx\n,
 		sizeof(*symhdrp), strsize,
 		(nesyms * sizeof(struct ecoff_extsym)));
 



CVS commit: src/usr.bin/elf2ecoff

2009-04-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Apr 23 14:49:32 UTC 2009

Modified Files:
src/usr.bin/elf2ecoff: elf2ecoff.c

Log Message:
Fix -Wcast-qual and -Wsign-compare issues.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/elf2ecoff/elf2ecoff.c

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

Modified files:

Index: src/usr.bin/elf2ecoff/elf2ecoff.c
diff -u src/usr.bin/elf2ecoff/elf2ecoff.c:1.22 src/usr.bin/elf2ecoff/elf2ecoff.c:1.23
--- src/usr.bin/elf2ecoff/elf2ecoff.c:1.22	Wed May 31 08:09:55 2006
+++ src/usr.bin/elf2ecoff/elf2ecoff.c	Thu Apr 23 14:49:32 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2ecoff.c,v 1.22 2006/05/31 08:09:55 simonb Exp $	*/
+/*	$NetBSD: elf2ecoff.c,v 1.23 2009/04/23 14:49:32 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1997 Jonathan Stone
@@ -79,8 +79,8 @@
 int phcmp(Elf32_Phdr * h1, Elf32_Phdr * h2);
 
 
-char   *saveRead(int file, off_t offset, off_t len, char *name);
-voidsafewrite(int outfile, void *buf, off_t len, const char *msg);
+char   *saveRead(int file, off_t offset, off_t len, const char *name);
+voidsafewrite(int outfile, const void *buf, off_t len, const char *msg);
 voidcopy(int, int, off_t, off_t);
 voidcombine(struct sect * base, struct sect * new, int paddable);
 voidtranslate_syms(struct elf_syms *, struct ecoff_syms *);
@@ -123,7 +123,8 @@
 	Elf32_Shdr *sh;
 	char   *shstrtab;
 	int strtabix, symtabix;
-	int i, pad;
+	size_t	i;
+	int pad;
 	struct sect text, data, bss;	/* a.out-compatible sections */
 	struct sect rdata, sdata, sbss;	/* ECOFF-only sections */
 
@@ -490,7 +491,7 @@
 	off_t   offset, size;
 {
 	charibuf[4096];
-	int remaining, cur, count;
+	size_t  remaining, cur, count;
 
 	/* Go to the start of the ELF symbol table... */
 	if (lseek(in, offset, SEEK_SET)  0) {
@@ -550,7 +551,7 @@
 
 char
*
-saveRead(int file, off_t offset, off_t len, char *name)
+saveRead(int file, off_t offset, off_t len, const char *name)
 {
 	char   *tmp;
 	int count;
@@ -573,10 +574,10 @@
 }
 
 void
-safewrite(int outfile, void *buf, off_t len, const char *msg)
+safewrite(int outfile, const void *buf, off_t len, const char *msg)
 {
 	int written;
-	written = write(outfile, (char *) buf, len);
+	written = write(outfile, buf, len);
 	if (written != len) {
 		fprintf(stderr, msg, strerror(errno));
 		exit(1);
@@ -859,7 +860,7 @@
 void
 bswap32_region(int32_t* p, int len)
 {
-	int i;
+	size_t i;
 
 	for (i = 0; i  len / sizeof(int32_t); i++, p++)
 		*p = bswap32(*p);