From 0cc27818737d867835985aff042ee77fb02d68d6 Mon Sep 17 00:00:00 2001 From: Boris Gjenero Date: Thu, 22 Oct 2020 19:03:16 -0400 Subject: [PATCH] Use modified NetBSD header files to make mopcopy work for a.out. --- common/Makefile.linux | 3 ++- common/file.c | 8 +++----- mopcopy/Makefile.linux | 3 ++- mopcopy/mopcopy.c | 5 +++-- netbsd_h/exec_aout.h | 27 +++++++++++++++++---------- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/common/Makefile.linux b/common/Makefile.linux index 0a3b78e..8a9462c 100644 --- a/common/Makefile.linux +++ b/common/Makefile.linux @@ -3,7 +3,8 @@ SRCS+=cmp.c device.c dl.c file.c get.c log.c loop-linux2.c mopdef.c nma.c SRCS+=pf-linux2.c print.c put.c rc.c version.c OBJS+=${SRCS:.c=.o} -CFLAGS+=-DNOAOUT +# Not needed as long as including of files from netbsd_h works +#CFLAGS+=-DNOAOUT libcommon.a: ${OBJS} ar cr $@ ${OBJS} diff --git a/common/file.c b/common/file.c index 452d313..90d2c23 100644 --- a/common/file.c +++ b/common/file.c @@ -38,12 +38,10 @@ __RCSID("$NetBSD: file.c,v 1.16 2016/06/08 01:11:49 christos Exp $"); #ifndef NOAOUT # if defined(__NetBSD__) || defined(__OpenBSD__) # include -# endif -# if defined(__bsdi__) -# define NOAOUT -# endif -# if defined(__FreeBSD__) +# elif defined(__FreeBSD__) # include +# else +# include "../netbsd_h/exec_aout.h" # endif # if !defined(MID_VAX) # define MID_VAX 140 diff --git a/mopcopy/Makefile.linux b/mopcopy/Makefile.linux index c1915f7..3567d45 100644 --- a/mopcopy/Makefile.linux +++ b/mopcopy/Makefile.linux @@ -3,7 +3,8 @@ SRCS=mopcopy.c OBJS=${SRCS:.c=.o} LDLIBS+=../common/libcommon.a -CFLAGS+=-I../common -DNOAOUT +CFLAGS+=-I../common +# -DNOAOUT not needed as long as including of files from netbsd_h works mopcopy: ${OBJS} diff --git a/mopcopy/mopcopy.c b/mopcopy/mopcopy.c index 80e38c8..dd13332 100644 --- a/mopcopy/mopcopy.c +++ b/mopcopy/mopcopy.c @@ -59,9 +59,10 @@ __RCSID("$NetBSD: mopcopy.c,v 1.7 2019/12/27 09:41:52 msaitoh Exp $"); #if !defined(NOAOUT) #if defined(__NetBSD__) || defined(__OpenBSD__) #include -#endif -#if defined(__FreeBSD__) +#elif defined(__FreeBSD__) #include +#else +#include "../netbsd_h/exec_aout.h" #endif #endif /* !NOAOUT */ #if defined(__bsdi__) diff --git a/netbsd_h/exec_aout.h b/netbsd_h/exec_aout.h index 5e8c6af..1420870 100644 --- a/netbsd_h/exec_aout.h +++ b/netbsd_h/exec_aout.h @@ -42,15 +42,19 @@ * only manipulate the a_midmag field via the * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros below. */ +/* VAXen are 32 bit and this might get compiled on 64 bit machines, + * so unsigned long changed to uint32_t for mopd portability. + */ +#include struct exec { - unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */ - unsigned long a_text; /* text segment size */ - unsigned long a_data; /* initialized data size */ - unsigned long a_bss; /* uninitialized data size */ - unsigned long a_syms; /* symbol table size */ - unsigned long a_entry; /* entry point */ - unsigned long a_trsize; /* text relocation size */ - unsigned long a_drsize; /* data relocation size */ + uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */ + uint32_t a_text; /* text segment size */ + uint32_t a_data; /* initialized data size */ + uint32_t a_bss; /* uninitialized data size */ + uint32_t a_syms; /* symbol table size */ + uint32_t a_entry; /* entry point */ + uint32_t a_trsize; /* text relocation size */ + uint32_t a_drsize; /* data relocation size */ }; /* a_magic */ @@ -59,7 +63,8 @@ struct exec { #define ZMAGIC 0413 /* demand load format */ #define QMAGIC 0314 /* "compact" demand load format; deprecated */ -#include +/* Changed for mopd, instead using other file in netbsd_h directory */ +#include "aout_mids.h" /* * a_flags @@ -150,7 +155,9 @@ struct exec { #define N_STROFF(ex) \ (N_SYMOFF(ex) + (ex).a_syms) -#include + +/* Not needed for mopd */ +/* #include */ #ifdef _KERNEL