README revision 1.5
11.5Sphx#	$NetBSD: README,v 1.5 2022/09/06 17:50:18 phx Exp $
21.2Sperry
31.3SphxBUILD INSTRUCTIONS
41.1Sis
51.3SphxBuilding LoadBSD isn't easy since several sources from the NetBSD repository
61.3Sphxare required. Compiling these sources under AmigaOS without clashes with the
71.3Sphxnative GCC headers requires some knowledge. This document tries to describe
81.3Sphxthe steps necessary to rebuild LoadBSD with an AmigaOS gcc. These instructions
91.3Sphxdo only apply for LoadBSD versions using the loadfile() interface. Previous
101.3Sphxversion do only require getopt.c and reboot.h.
111.3Sphx
121.5SphxNote: It is not possible to build LoadBSD with the native NetBSD compiler!
131.3Sphx      LoadBSD is an *AmigaOS* program and must be built with an AmigaOS
141.3Sphx      compiler. Of course, a properly setup cross-compiler does work.
151.3Sphx
161.3SphxRequired sources from NetBSD (either HEAD or from a release branch)
171.3Sphx
181.3Sphx   From src/sys/lib/libsa: loadfile.h,loadfile.c,loadfile_elf32.c,loadfile_aout.c
191.3Sphx   From src/lib/libc/stdlib: getopt.c
201.3Sphx
211.3Sphx      place these files in the directory where you have loadbsd.c
221.3Sphx
231.3Sphx   From src/sys/arch/m68k/include: aout_machdep.h,elf_machdep.h
241.3Sphx
251.3Sphx      place these files in: <loadbsd directory>/include/m68k
261.3Sphx
271.3Sphx   From src/sys/arch/amiga/include: aout_machdep.h,elf_machdep.h,loadfile_machdep.h
281.3Sphx
291.3Sphx      place these files in: <loadbsd directory>/include/machine
301.3Sphx
311.3Sphx   From src/sys/sys: exec.h,exec_elf.h,exec_aout.h,reboot.h
321.3Sphx
331.3Sphx      place these files in: <loadbsd directory>/include/sys
341.3Sphx
351.3Sphx   Additional headers (see below): inttypes.h,namespace.h,lib/libsa/stand.h,lib/libkern/libkern.h
361.3Sphx
371.3Sphx      place these files in: <loadbsd directory>/include
381.3Sphx
391.3SphxIf all the mentioned files are placed at the correct place, loadfile_machdep.h
401.4Sandvarmust be modified. The patch is included below. Another small patch to
411.3Sphxloadfile_aout.c must be applied to fix an incompatibility for LoadBSD.
421.3SphxHowever, that patch breaks loadfile() for other architectures using a.out!
431.3SphxNote: This patch is required to be able to suppress loaded symbols when
441.3Sphx      booting ancient a.out kernels that don't support them. Without the
451.3Sphx      patch symbol suppressing doesn't work! That also means ELF isn't
461.3Sphx      affected and LoadBSD could handle it differently but then it could
471.3Sphx      probably break in other unpredictable ways...
481.3Sphx
491.3SphxThen it should be possible to recompile LoadBSD by typing "make". If make
501.3Sphxfails, fix the problem and try again :-P
511.3Sphx
521.3SphxGood luck!
531.3Sphx
541.3Sphx--- Missing files/patches ---
551.3Sphx
561.3Sphx      loadfile_aout.c modification:
571.3Sphx--cut--
581.3Sphx--- loadfile_aout.c~	Mon Feb 11 21:25:56 2002
591.3Sphx+++ loadfile_aout.c	Thu Jan 23 10:43:27 2003
601.3Sphx@@ -217,8 +217,8 @@ loadfile_aout(fd, x, marks, flags)
611.3Sphx 		BCOPY(&x->a_syms, maxp, sizeof(x->a_syms));
621.3Sphx 
631.3Sphx 	if (flags & (LOAD_SYM|COUNT_SYM)) {
641.3Sphx-		maxp += sizeof(x->a_syms);
651.3Sphx 		aoutp = maxp;
661.3Sphx+		maxp += sizeof(x->a_syms);
671.3Sphx 	}
681.3Sphx 
691.3Sphx 	if (x->a_syms > 0) {
701.3Sphx--cut--
711.3Sphx
721.3Sphx      loadfile_machdep.h modification:
731.3Sphx--cut--
741.3Sphx--- loadfile_machdep.h~	Wed Oct 31 18:20:45 2001
751.3Sphx+++ loadfile_machdep.h	Thu Jan 16 14:02:39 2003
761.3Sphx@@ -42,6 +42,21 @@
771.3Sphx #define	BOOT_AOUT
781.3Sphx #define	BOOT_ELF32
791.3Sphx 
801.3Sphx+#if 1
811.3Sphx+
821.3Sphx+#define LOADADDR(a)		(((u_long)(a)) + offset)
831.3Sphx+#define ALIGNENTRY(a)		0
841.3Sphx+#define READ(f, b, c)		read((f), (void *)LOADADDR(b), (c))
851.3Sphx+#define BCOPY(s, d, c)		memcpy((void *)LOADADDR(d), (void *)(s), (c))
861.3Sphx+#define BZERO(d, c)		memset((void *)LOADADDR(d), 0, (c))
871.3Sphx+#define WARN(a)			warn a
881.3Sphx+#define PROGRESS(a)		/* nothing */
891.3Sphx+#define ALLOC(a)		malloc(a)
901.3Sphx+#define FREE(a, b)		free(a)
911.3Sphx+#define OKMAGIC(a)		((a) == NMAGIC)
921.3Sphx+
931.3Sphx+#else /* ! true, false */
941.3Sphx+
951.3Sphx #define	LOAD_KERNEL		LOAD_ALL
961.3Sphx #define	COUNT_KERNEL		COUNT_ALL
971.3Sphx 
981.3Sphx@@ -83,4 +98,7 @@ void vcopy __P((u_long, u_long, u_long *
991.3Sphx void vzero __P((u_long, u_long *, size_t));
1001.3Sphx 
1011.3Sphx #endif
1021.3Sphx+
1031.3Sphx+#endif /* ! false */
1041.3Sphx+
1051.3Sphx #endif /* ! _AMIGA_LOADFILE_MACHDEP_H_ */
1061.3Sphx--cut--
1071.3Sphx
1081.3Sphx      include/inttypes.h:
1091.3Sphx--cut--
1101.3Sphx#ifndef _INTTYPES_H
1111.3Sphx#define _INTTYPES_H
1121.3Sphx
1131.3Sphx#include <sys/types.h>
1141.3Sphx
1151.3Sphxtypedef	unsigned char      uint8_t;
1161.3Sphxtypedef	unsigned short     uint16_t;
1171.3Sphxtypedef	unsigned int       uint32_t;
1181.3Sphxtypedef	unsigned long long uint64_t;
1191.3Sphx/*
1201.3Sphxtypedef	         int       int32_t;
1211.3Sphxtypedef	         long long int64_t;
1221.3Sphx*/
1231.3Sphxtypedef unsigned long vaddr_t;
1241.3Sphxtypedef unsigned long paddr_t;
1251.3Sphx
1261.3Sphx#endif /* !_INTTYPES_H */
1271.3Sphx--cut--
1281.3Sphx
1291.3Sphx    include/namespace.h
1301.3Sphx--cut--
1311.3Sphx#define _DIAGASSERT(x) /**/
1321.3Sphx
1331.3Sphxextern char *program_name;
1341.3Sphx#define getprogname() program_name
1351.3Sphx--cut--
1361.3Sphx
1371.3Sphx      include/lib/libsa/stand.h
1381.3Sphx--cut--
1391.3Sphx#include <stdio.h>
1401.3Sphx#include <string.h>
1411.3Sphx#include <errno.h>
1421.3Sphx#include <stdlib.h>
1431.3Sphx#include <unistd.h>
1441.3Sphx#include <fcntl.h>
1451.3Sphx#include <err.h>
1461.3Sphx#include "inttypes.h"
1471.3Sphx--cut--
1481.3Sphx
1491.3Sphx      include/lib/libkern/libkern.h
1501.3Sphx--cut--
1511.3Sphx/* nothing, must only exist! */
1521.3Sphx--cut--
153