1# $NetBSD: README,v 1.3 2015/11/11 16:08:52 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: Its 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 modfied. 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 Makefile: 109--cut-- 110TARGET = loadbsd 111 112CC = gcc -m68020 -Wa,-m68030 -fbaserel 113CFLAGS = -D_STANDALONE -I./include -O -fomit-frame-pointer -msmall-code 114LDFLAGS = -noixemul 115LDLIBS = 116 117OBJS = loadbsd.o loadfile.o loadfile_aout.o loadfile_elf32.o getopt.o 118 119$(TARGET): $(OBJS) 120 $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) 121--cut-- 122 123 include/inttypes.h: 124--cut-- 125#ifndef _INTTYPES_H 126#define _INTTYPES_H 127 128#include <sys/types.h> 129 130typedef unsigned char uint8_t; 131typedef unsigned short uint16_t; 132typedef unsigned int uint32_t; 133typedef unsigned long long uint64_t; 134/* 135typedef int int32_t; 136typedef long long int64_t; 137*/ 138typedef unsigned long vaddr_t; 139typedef unsigned long paddr_t; 140 141#endif /* !_INTTYPES_H */ 142--cut-- 143 144 include/namespace.h 145--cut-- 146#define _DIAGASSERT(x) /**/ 147 148extern char *program_name; 149#define getprogname() program_name 150--cut-- 151 152 include/lib/libsa/stand.h 153--cut-- 154#include <stdio.h> 155#include <string.h> 156#include <errno.h> 157#include <stdlib.h> 158#include <unistd.h> 159#include <fcntl.h> 160#include <err.h> 161#include "inttypes.h" 162--cut-- 163 164 include/lib/libkern/libkern.h 165--cut-- 166/* nothing, must only exist! */ 167--cut-- 168