1# $NetBSD: README,v 1.5 2022/09/06 17:50:18 phx Exp $ 2 3BUILD INSTRUCTIONS 4 5Building LoadBSD isn't easy since several sources from the NetBSD repository 6are required. Compiling these sources under AmigaOS without clashes with the 7native GCC headers requires some knowledge. This document tries to describe 8the steps necessary to rebuild LoadBSD with an AmigaOS gcc. These instructions 9do only apply for LoadBSD versions using the loadfile() interface. Previous 10version do only require getopt.c and reboot.h. 11 12Note: It is not possible to build LoadBSD with the native NetBSD compiler! 13 LoadBSD is an *AmigaOS* program and must be built with an AmigaOS 14 compiler. Of course, a properly setup cross-compiler does work. 15 16Required sources from NetBSD (either HEAD or from a release branch) 17 18 From src/sys/lib/libsa: loadfile.h,loadfile.c,loadfile_elf32.c,loadfile_aout.c 19 From src/lib/libc/stdlib: getopt.c 20 21 place these files in the directory where you have loadbsd.c 22 23 From src/sys/arch/m68k/include: aout_machdep.h,elf_machdep.h 24 25 place these files in: <loadbsd directory>/include/m68k 26 27 From src/sys/arch/amiga/include: aout_machdep.h,elf_machdep.h,loadfile_machdep.h 28 29 place these files in: <loadbsd directory>/include/machine 30 31 From src/sys/sys: exec.h,exec_elf.h,exec_aout.h,reboot.h 32 33 place these files in: <loadbsd directory>/include/sys 34 35 Additional headers (see below): inttypes.h,namespace.h,lib/libsa/stand.h,lib/libkern/libkern.h 36 37 place these files in: <loadbsd directory>/include 38 39If all the mentioned files are placed at the correct place, loadfile_machdep.h 40must be modified. The patch is included below. Another small patch to 41loadfile_aout.c must be applied to fix an incompatibility for LoadBSD. 42However, that patch breaks loadfile() for other architectures using a.out! 43Note: This patch is required to be able to suppress loaded symbols when 44 booting ancient a.out kernels that don't support them. Without the 45 patch symbol suppressing doesn't work! That also means ELF isn't 46 affected and LoadBSD could handle it differently but then it could 47 probably break in other unpredictable ways... 48 49Then it should be possible to recompile LoadBSD by typing "make". If make 50fails, fix the problem and try again :-P 51 52Good luck! 53 54--- Missing files/patches --- 55 56 loadfile_aout.c modification: 57--cut-- 58--- loadfile_aout.c~ Mon Feb 11 21:25:56 2002 59+++ loadfile_aout.c Thu Jan 23 10:43:27 2003 60@@ -217,8 +217,8 @@ loadfile_aout(fd, x, marks, flags) 61 BCOPY(&x->a_syms, maxp, sizeof(x->a_syms)); 62 63 if (flags & (LOAD_SYM|COUNT_SYM)) { 64- maxp += sizeof(x->a_syms); 65 aoutp = maxp; 66+ maxp += sizeof(x->a_syms); 67 } 68 69 if (x->a_syms > 0) { 70--cut-- 71 72 loadfile_machdep.h modification: 73--cut-- 74--- loadfile_machdep.h~ Wed Oct 31 18:20:45 2001 75+++ loadfile_machdep.h Thu Jan 16 14:02:39 2003 76@@ -42,6 +42,21 @@ 77 #define BOOT_AOUT 78 #define BOOT_ELF32 79 80+#if 1 81+ 82+#define LOADADDR(a) (((u_long)(a)) + offset) 83+#define ALIGNENTRY(a) 0 84+#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c)) 85+#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c)) 86+#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c)) 87+#define WARN(a) warn a 88+#define PROGRESS(a) /* nothing */ 89+#define ALLOC(a) malloc(a) 90+#define FREE(a, b) free(a) 91+#define OKMAGIC(a) ((a) == NMAGIC) 92+ 93+#else /* ! true, false */ 94+ 95 #define LOAD_KERNEL LOAD_ALL 96 #define COUNT_KERNEL COUNT_ALL 97 98@@ -83,4 +98,7 @@ void vcopy __P((u_long, u_long, u_long * 99 void vzero __P((u_long, u_long *, size_t)); 100 101 #endif 102+ 103+#endif /* ! false */ 104+ 105 #endif /* ! _AMIGA_LOADFILE_MACHDEP_H_ */ 106--cut-- 107 108 include/inttypes.h: 109--cut-- 110#ifndef _INTTYPES_H 111#define _INTTYPES_H 112 113#include <sys/types.h> 114 115typedef unsigned char uint8_t; 116typedef unsigned short uint16_t; 117typedef unsigned int uint32_t; 118typedef unsigned long long uint64_t; 119/* 120typedef int int32_t; 121typedef long long int64_t; 122*/ 123typedef unsigned long vaddr_t; 124typedef unsigned long paddr_t; 125 126#endif /* !_INTTYPES_H */ 127--cut-- 128 129 include/namespace.h 130--cut-- 131#define _DIAGASSERT(x) /**/ 132 133extern char *program_name; 134#define getprogname() program_name 135--cut-- 136 137 include/lib/libsa/stand.h 138--cut-- 139#include <stdio.h> 140#include <string.h> 141#include <errno.h> 142#include <stdlib.h> 143#include <unistd.h> 144#include <fcntl.h> 145#include <err.h> 146#include "inttypes.h" 147--cut-- 148 149 include/lib/libkern/libkern.h 150--cut-- 151/* nothing, must only exist! */ 152--cut-- 153