On Tue, Nov 26, 2019 at 04:51:36PM -0700, Theo de Raadt wrote:
> ok with me

So here is the full diff with all architecture makefiles that may
be affected.

I have done a build release on amd64.  Boot loader on i386, armv7,
arm64, macppc compiles and links.  hppa, landisk, octeon is just a
guess what should be done.

Is more testing needed?

bluhm

Index: arch/amd64/stand/boot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/stand/boot/Makefile,v
retrieving revision 1.43
diff -u -p -r1.43 Makefile
--- arch/amd64/stand/boot/Makefile      29 Oct 2019 02:55:50 -0000      1.43
+++ arch/amd64/stand/boot/Makefile      27 Nov 2019 14:17:56 -0000
@@ -32,7 +32,8 @@ SRCS+=        softraid_amd64.c
 .endif

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c 
printf.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c hexdump.c \
+       memcmp.c memcpy.c memmove.c memset.c printf.c \
        putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \
        strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \
Index: arch/amd64/stand/cdboot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/stand/cdboot/Makefile,v
retrieving revision 1.38
diff -u -p -r1.38 Makefile
--- arch/amd64/stand/cdboot/Makefile    29 Oct 2019 02:55:50 -0000      1.38
+++ arch/amd64/stand/cdboot/Makefile    27 Nov 2019 14:17:56 -0000
@@ -25,7 +25,7 @@ SRCS+=        softraid_amd64.c
 SRCS+= cmd.c vars.c bootarg.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c exit.c getchar.c putchar.c strcmp.c strlen.c \
+SRCS+= alloc.c exit.c getchar.c hexdump.c putchar.c strcmp.c strlen.c \
        strncmp.c memcmp.c memcpy.c memmove.c memset.c printf.c snprintf.c \
        strerror.c strncpy.c strtol.c strtoll.c ctime.c strlcpy.c
 SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fchmod.c fstat.c \
Index: arch/amd64/stand/efi32/Makefile.common
===================================================================
RCS file: 
/data/mirror/openbsd/cvs/src/sys/arch/amd64/stand/efi32/Makefile.common,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile.common
--- arch/amd64/stand/efi32/Makefile.common      29 Oct 2019 02:55:50 -0000      
1.3
+++ arch/amd64/stand/efi32/Makefile.common      27 Nov 2019 14:17:56 -0000
@@ -32,7 +32,8 @@ SRCS+=        memprobe.c
 SRCS+= boot.c bootarg.c cmd.c vars.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c 
printf.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c hexdump.c \
+       memcmp.c memcpy.c memmove.c memset.c printf.c \
        putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \
        strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \
Index: arch/amd64/stand/efi64/Makefile.common
===================================================================
RCS file: 
/data/mirror/openbsd/cvs/src/sys/arch/amd64/stand/efi64/Makefile.common,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile.common
--- arch/amd64/stand/efi64/Makefile.common      29 Oct 2019 02:55:50 -0000      
1.3
+++ arch/amd64/stand/efi64/Makefile.common      27 Nov 2019 14:17:56 -0000
@@ -32,7 +32,8 @@ SRCS+=        memprobe.c
 SRCS+= boot.c bootarg.c cmd.c vars.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c 
printf.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c hexdump.c \
+       memcmp.c memcpy.c memmove.c memset.c printf.c \
        putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \
        strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \
Index: arch/amd64/stand/efiboot/Makefile.common
===================================================================
RCS file: 
/data/mirror/openbsd/cvs/src/sys/arch/amd64/stand/efiboot/Makefile.common,v
retrieving revision 1.18
diff -u -p -r1.18 Makefile.common
--- arch/amd64/stand/efiboot/Makefile.common    29 Oct 2019 02:55:51 -0000      
1.18
+++ arch/amd64/stand/efiboot/Makefile.common    27 Nov 2019 14:17:56 -0000
@@ -32,7 +32,8 @@ SRCS+=        memprobe.c
 SRCS+= boot.c bootarg.c cmd.c vars.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c 
printf.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c hexdump.c \
+       memcmp.c memcpy.c memmove.c memset.c printf.c \
        putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \
        strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c \
Index: arch/amd64/stand/pxeboot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/stand/pxeboot/Makefile,v
retrieving revision 1.36
diff -u -p -r1.36 Makefile
--- arch/amd64/stand/pxeboot/Makefile   29 Oct 2019 02:55:51 -0000      1.36
+++ arch/amd64/stand/pxeboot/Makefile   27 Nov 2019 14:17:56 -0000
@@ -27,8 +27,9 @@ SRCS+=        softraid_amd64.c
 SRCS+= boot.c cmd.c vars.c bootarg.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c exit.c getchar.c getfile.c getln.c globals.c putchar.c \
-       strcmp.c strlen.c strncmp.c memcmp.c memcpy.c memmove.c memset.c 
printf.c \
+SRCS+= alloc.c exit.c getchar.c getfile.c getln.c globals.c hexdump.c \
+       strcmp.c strlen.c strncmp.c memcmp.c memcpy.c memmove.c memset.c \
+       printf.c putchar.c \
        snprintf.c strerror.c strncpy.c strtol.c strtoll.c ctime.c strlcpy.c \
        strlcat.c
 SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \
Index: arch/arm64/stand/efiboot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/arm64/stand/efiboot/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- arch/arm64/stand/efiboot/Makefile   29 Oct 2019 02:55:51 -0000      1.10
+++ arch/arm64/stand/efiboot/Makefile   27 Nov 2019 14:53:55 -0000
@@ -24,9 +24,10 @@ LDFLAGS+=-nostdlib -T ${.CURDIR}/ldscrip
 SRCS+= boot.c cmd.c vars.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c hexdump.c \
+       memcmp.c memcpy.c memmove.c memset.c \
        printf.c putchar.c snprintf.c strchr.c strcmp.c strerror.c strncmp.c \
-       strncpy.c strtol.c
+       strncpy.c strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \
        fstat.c lseek.c open.c read.c readdir.c stat.c
 SRCS+= loadfile.c arc4.c
Index: arch/armv7/stand/efiboot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/armv7/stand/efiboot/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- arch/armv7/stand/efiboot/Makefile   29 Oct 2019 02:55:51 -0000      1.14
+++ arch/armv7/stand/efiboot/Makefile   27 Nov 2019 14:54:47 -0000
@@ -24,9 +24,10 @@ LDFLAGS+=    -z notext -z norelro
 SRCS+= boot.c cmd.c vars.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c hexdump.c \
+       memcmp.c memcpy.c memmove.c memset.c \
        printf.c putchar.c snprintf.c strchr.c strcmp.c strerror.c strncmp.c \
-       strncpy.c strtol.c
+       strncpy.c strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \
        fstat.c lseek.c open.c read.c readdir.c stat.c
 SRCS+= loadfile.c arc4.c
Index: arch/hppa/stand/boot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/hppa/stand/boot/Makefile,v
retrieving revision 1.28
diff -u -p -r1.28 Makefile
--- arch/hppa/stand/boot/Makefile       20 Apr 2019 22:59:03 -0000      1.28
+++ arch/hppa/stand/boot/Makefile       27 Nov 2019 14:54:02 -0000
@@ -12,6 +12,9 @@ SRCS= srt0.S exec.c conf.c
 .PATH: ${S}/stand/boot
 SRCS+= bootarg.c boot.c vars.c cmd.c

+.PATH: ${S}/lib/libsa
+SRCS+= hexdump.c strtoll.c
+
 .PATH: ${S}/lib/libkern/arch/hppa ${S}/lib/libkern
 SRCS+= milli.S ashldi3.c ashrdi3.c memcmp.c memcpy.c memmove.c memset.c \
        moddi3.c muldi3.c qdivrem.c strcmp.c strlcpy.c strlen.c \
Index: arch/i386/stand/boot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/i386/stand/boot/Makefile,v
retrieving revision 1.70
diff -u -p -r1.70 Makefile
--- arch/i386/stand/boot/Makefile       29 Oct 2019 02:55:51 -0000      1.70
+++ arch/i386/stand/boot/Makefile       27 Nov 2019 14:27:58 -0000
@@ -36,7 +36,8 @@ SRCS+=        softraid_i386.c
 .endif

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c 
printf.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c hexdump.c \
+       memcmp.c memcpy.c memmove.c memset.c printf.c \
        putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \
        strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \
Index: arch/i386/stand/cdboot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/i386/stand/cdboot/Makefile,v
retrieving revision 1.34
diff -u -p -r1.34 Makefile
--- arch/i386/stand/cdboot/Makefile     29 Oct 2019 02:55:51 -0000      1.34
+++ arch/i386/stand/cdboot/Makefile     27 Nov 2019 14:28:03 -0000
@@ -27,7 +27,8 @@ SRCS+=        softraid_i386.c
 SRCS+= bootarg.c cmd.c vars.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c 
printf.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c hexdump.c \
+       memcmp.c memcpy.c memmove.c memset.c printf.c \
        putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \
        strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \
Index: arch/i386/stand/pxeboot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/i386/stand/pxeboot/Makefile,v
retrieving revision 1.31
diff -u -p -r1.31 Makefile
--- arch/i386/stand/pxeboot/Makefile    29 Oct 2019 02:55:51 -0000      1.31
+++ arch/i386/stand/pxeboot/Makefile    27 Nov 2019 14:28:10 -0000
@@ -28,7 +28,8 @@ SRCS+=        softraid_i386.c
 SRCS+= boot.c cmd.c vars.c bootarg.c

 .PATH: ${S}/lib/libsa
-SRCS+= alloc.c ctime.c exit.c getchar.c globals.c memcmp.c memmove.c memcpy.c 
memset.c \
+SRCS+= alloc.c ctime.c exit.c getchar.c globals.c hexdump.c \
+       memcmp.c memmove.c memcpy.c memset.c \
        printf.c putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c \
        strncpy.c strtol.c strtoll.c
 SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \
Index: arch/landisk/stand/boot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/landisk/stand/boot/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- arch/landisk/stand/boot/Makefile    29 Oct 2019 02:55:51 -0000      1.15
+++ arch/landisk/stand/boot/Makefile    27 Nov 2019 14:54:09 -0000
@@ -21,6 +21,9 @@ AFLAGS+= -fno-pie
 .PATH:  ${S}/stand/boot
 SRCS+= boot.c cmd.c vars.c bootarg.c

+.PATH: ${S}/lib/libsa
+SRCS+= hexdump.c strtoll.c
+
 .PATH: ${S}/lib/libkern/arch/sh ${S}/lib/libkern
 SRCS+= getchar.c putchar.c strlen.c strlcpy.c
 SRCS+= ashldi3.c ashrdi3.c moddi3.c sdivsi3.S udivsi3.S
Index: arch/loongson/stand/boot/Makefile.inc
===================================================================
RCS file: 
/data/mirror/openbsd/cvs/src/sys/arch/loongson/stand/boot/Makefile.inc,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile.inc
--- arch/loongson/stand/boot/Makefile.inc       6 Nov 2016 16:42:00 -0000       
1.5
+++ arch/loongson/stand/boot/Makefile.inc       27 Nov 2019 16:16:00 -0000
@@ -24,6 +24,10 @@ SRCS+=               pmon.c pmon32.S
 .PATH:         ${S}/stand/boot
 SRCS+=         boot.c cmd.c vars.c

+#### libsa
+.PATH:         ${S}/lib/libsa
+SRCS+=         hexdump.c strtoll.c
+
 #### libkern
 .PATH:         ${S}/lib/libkern/arch/mips64 ${S}/lib/libkern
 SRCS+=         strlcat.c strlcpy.c strlen.c
Index: arch/macppc/stand/boot.mac/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/macppc/stand/boot.mac/Makefile,v
retrieving revision 1.17
diff -u -p -r1.17 Makefile
--- arch/macppc/stand/boot.mac/Makefile 29 Oct 2019 02:55:51 -0000      1.17
+++ arch/macppc/stand/boot.mac/Makefile 27 Nov 2019 14:54:28 -0000
@@ -22,7 +22,7 @@ LDFLAGS+=     -T ${.CURDIR}/elf32_powerpc_me

 .PATH:          ${S}/stand/boot
 .PATH:          ${S}/lib/libsa
-SRCS+=         getchar.c
+SRCS+=         getchar.c hexdump.c strtoll.c

 .PATH:         ${S}/lib/libkern/arch/powerpc ${S}/lib/libkern
 SRCS+=         strlcpy.c memcpy.c memmove.c strlen.c strrchr.c strlcat.c 
ashrdi3.c
Index: arch/macppc/stand/ofwboot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/macppc/stand/ofwboot/Makefile,v
retrieving revision 1.18
diff -u -p -r1.18 Makefile
--- arch/macppc/stand/ofwboot/Makefile  29 Oct 2019 02:55:51 -0000      1.18
+++ arch/macppc/stand/ofwboot/Makefile  27 Nov 2019 14:54:35 -0000
@@ -22,6 +22,7 @@ BINDIR=         /usr/mdec

 .PATH:          ${S}/stand/boot
 .PATH:          ${S}/lib/libsa
+SRCS+=         hexdump.c strtoll.c

 .PATH:         ${S}/lib/libkern/arch/powerpc ${S}/lib/libkern
 SRCS+=         getchar.c strlcpy.c memcpy.c memmove.c strlen.c strrchr.c \
Index: arch/octeon/stand/rdboot/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/octeon/stand/rdboot/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- arch/octeon/stand/rdboot/Makefile   4 Aug 2019 08:53:14 -0000       1.3
+++ arch/octeon/stand/rdboot/Makefile   27 Nov 2019 14:54:38 -0000
@@ -11,6 +11,9 @@ LDSTATIC+=    -static
 NOPROG=
 .endif

+.PATH:  ${S}/lib/libsa
+SRCS+=  hexdump.c strtoll.c
+
 install:

 .include <bsd.prog.mk>
Index: lib/libsa/hexdump.c
===================================================================
RCS file: lib/libsa/hexdump.c
diff -N lib/libsa/hexdump.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/libsa/hexdump.c 27 Nov 2019 14:17:56 -0000
@@ -0,0 +1,52 @@
+/*     $OpenBSD$       */
+/*
+ * Copyright (c) 2019 Alexander Bluhm <[email protected]>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include "stand.h"
+
+void
+hexdump(const void *addr, size_t size)
+{
+       const unsigned char *line, *end;
+       int byte;
+
+       end = (const char *)addr + size;
+       for (line = addr; line < end; line += 16) {
+               printf("%08lx  ", line);
+               for (byte = 0; byte < 16; byte++) {
+                       if (&line[byte] < end)
+                               printf("%02x ", line[byte]);
+                       else
+                               printf("   ");
+                       if (byte == 7)
+                               printf(" ");
+               }
+               printf(" |");
+               for (byte = 0; byte < 16; byte++) {
+                       if (&line[byte] < end) {
+                               if (line[byte] >= ' ' && line[byte] <= '~')
+                                       printf("%c", line[byte]);
+                               else
+                                       printf(".");
+                       } else
+                               break;
+               }
+               printf("|\n");
+       }
+       printf("%08lx\n", end);
+}
Index: lib/libsa/stand.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/lib/libsa/stand.h,v
retrieving revision 1.68
diff -u -p -r1.68 stand.h
--- lib/libsa/stand.h   1 Nov 2019 20:54:52 -0000       1.68
+++ lib/libsa/stand.h   27 Nov 2019 14:17:27 -0000
@@ -146,6 +146,7 @@ __dead void _rtt(void) __attribute__((no
 #define bcmp(s1,s2,n)  (memcmp((s2),(s1),(n)))
 #define        bcopy(s1,s2,n)  ((void)memmove((s2),(s1),(n)))
 void   explicit_bzero(void *, size_t);
+void   hexdump(const void *, size_t);
 void   *memcpy(void *, const void *, size_t);
 void   *memmove(void *, const void *, size_t);
 int    memcmp(const void *, const void *, size_t);
Index: stand/boot/cmd.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/stand/boot/cmd.c,v
retrieving revision 1.65
diff -u -p -r1.65 cmd.c
--- stand/boot/cmd.c    3 Aug 2019 15:22:19 -0000       1.65
+++ stand/boot/cmd.c    27 Nov 2019 14:17:56 -0000
@@ -39,6 +39,7 @@
 static int Xboot(void);
 static int Xecho(void);
 static int Xhelp(void);
+static int Xhexdump(void);
 static int Xls(void);
 static int Xnop(void);
 static int Xreboot(void);
@@ -62,6 +63,7 @@ const struct cmd_table cmd_table[] = {
        {"echo",   CMDT_CMD, Xecho},
        {"env",    CMDT_CMD, Xenv},
        {"help",   CMDT_CMD, Xhelp},
+       {"hexdump",CMDT_CMD, Xhexdump},
        {"ls",     CMDT_CMD, Xls},
 #ifdef MACHINE_CMD
        {"machine",CMDT_MDC, Xmachine},
@@ -345,6 +347,29 @@ Xhelp(void)
 #else
        return 0;
 #endif
+}
+
+static int
+Xhexdump(void)
+{
+       long long val[2];
+       char *ep;
+       int i;
+
+       if (cmd.argc != 3) {
+               printf("hexdump addr size\n");
+               return 0;
+       }
+
+       for (i = 1; i < cmd.argc; i++) {
+               val[i-1] = strtoll(cmd.argv[i], &ep, 0);
+               if (cmd.argv[i][0] == '\0' || *ep != '\0') {
+                       printf("bad '%c' in \"%s\"\n", *ep, cmd.argv[i]);
+                       return 0;
+               }
+       }
+       hexdump((void *)val[0], val[1]);
+       return 0;
 }

 #ifdef MACHINE_CMD

Reply via email to