1*34815acdSphx# $NetBSD: README,v 1.6 2023/05/14 16:13:05 phx Exp $ 2b46484bbSperry 3272a1c38SphxBUILD INSTRUCTIONS 4a63c9b84Sis 5272a1c38SphxBuilding LoadBSD isn't easy since several sources from the NetBSD repository 6272a1c38Sphxare required. Compiling these sources under AmigaOS without clashes with the 7272a1c38Sphxnative GCC headers requires some knowledge. This document tries to describe 8*34815acdSphxthe steps necessary to rebuild LoadBSD with a modern AmigaOS gcc, or vbcc 9*34815acdSphxwith PosixLib. 10*34815acdSphxThese instructions do only apply for LoadBSD versions using the loadfile() 11*34815acdSphxinterface. Previous version do only require getopt.c and reboot.h. 12a63c9b84Sis 1378422e2eSphxNote: It is not possible to build LoadBSD with the native NetBSD compiler! 14272a1c38Sphx LoadBSD is an *AmigaOS* program and must be built with an AmigaOS 15272a1c38Sphx compiler. Of course, a properly setup cross-compiler does work. 16a63c9b84Sis 17272a1c38SphxRequired sources from NetBSD (either HEAD or from a release branch) 18a63c9b84Sis 19272a1c38Sphx From src/sys/lib/libsa: loadfile.h,loadfile.c,loadfile_elf32.c,loadfile_aout.c 20a63c9b84Sis 21272a1c38Sphx place these files in the directory where you have loadbsd.c 22272a1c38Sphx 23272a1c38Sphx From src/sys/arch/m68k/include: aout_machdep.h,elf_machdep.h 24272a1c38Sphx 25272a1c38Sphx place these files in: <loadbsd directory>/include/m68k 26272a1c38Sphx 27272a1c38Sphx From src/sys/arch/amiga/include: aout_machdep.h,elf_machdep.h,loadfile_machdep.h 28272a1c38Sphx 29272a1c38Sphx place these files in: <loadbsd directory>/include/machine 30272a1c38Sphx 31*34815acdSphx From src/sys/sys: exec.h,exec_elf.h,exec_aout.h,aout_mids.h,reboot.h 32272a1c38Sphx 33272a1c38Sphx place these files in: <loadbsd directory>/include/sys 34272a1c38Sphx 35272a1c38Sphx Additional headers (see below): inttypes.h,namespace.h,lib/libsa/stand.h,lib/libkern/libkern.h 36272a1c38Sphx 37272a1c38Sphx place these files in: <loadbsd directory>/include 38272a1c38Sphx 39272a1c38SphxIf all the mentioned files are placed at the correct place, loadfile_machdep.h 40e82c4d9bSandvarmust be modified. The patch is included below. Another small patch to 41272a1c38Sphxloadfile_aout.c must be applied to fix an incompatibility for LoadBSD. 42272a1c38SphxHowever, that patch breaks loadfile() for other architectures using a.out! 43272a1c38SphxNote: This patch is required to be able to suppress loaded symbols when 44272a1c38Sphx booting ancient a.out kernels that don't support them. Without the 45272a1c38Sphx patch symbol suppressing doesn't work! That also means ELF isn't 46272a1c38Sphx affected and LoadBSD could handle it differently but then it could 47272a1c38Sphx probably break in other unpredictable ways... 48272a1c38Sphx 49*34815acdSphxThe headers inttypes.h, namespace.h, include/lib/libsa/stand.h and 50*34815acdSphxlib/libkern/libkern.h are listed completely below. 51*34815acdSphx 52*34815acdSphxThen it should be possible to recompile LoadBSD with gcc6 or newer by 53*34815acdSphxtyping "make" (or "make -f vmakefile" with vbcc). If make fails, fix the 54*34815acdSphxproblem and try again :-P 55272a1c38Sphx 56272a1c38SphxGood luck! 57272a1c38Sphx 58272a1c38Sphx--- Missing files/patches --- 59272a1c38Sphx 60*34815acdSphx include/machine/loadfile_machdep.h modification: 61*34815acdSphx--cut-- 62*34815acdSphx--- include/machine/loadfile_machdep.h~ Sun Mar 26 15:46:55 2023 63*34815acdSphx+++ include/machine/loadfile_machdep.h Sun Mar 26 15:47:17 2023 64*34815acdSphx@@ -38,7 +38,7 @@ 65*34815acdSphx #define LOAD_KERNEL LOAD_ALL 66*34815acdSphx #define COUNT_KERNEL COUNT_ALL 67*34815acdSphx 68*34815acdSphx-#ifdef _STANDALONE 69*34815acdSphx+#if 0 70*34815acdSphx 71*34815acdSphx #define LOADADDR(a) ((a) + offset) 72*34815acdSphx #define ALIGNENTRY(a) 0 73*34815acdSphx--cut-- 74*34815acdSphx 75272a1c38Sphx loadfile_aout.c modification: 76272a1c38Sphx--cut-- 77272a1c38Sphx--- loadfile_aout.c~ Mon Feb 11 21:25:56 2002 78272a1c38Sphx+++ loadfile_aout.c Thu Jan 23 10:43:27 2003 79272a1c38Sphx@@ -217,8 +217,8 @@ loadfile_aout(fd, x, marks, flags) 80272a1c38Sphx BCOPY(&x->a_syms, maxp, sizeof(x->a_syms)); 81272a1c38Sphx 82272a1c38Sphx if (flags & (LOAD_SYM|COUNT_SYM)) { 83272a1c38Sphx- maxp += sizeof(x->a_syms); 84272a1c38Sphx aoutp = maxp; 85272a1c38Sphx+ maxp += sizeof(x->a_syms); 86272a1c38Sphx } 87272a1c38Sphx 88272a1c38Sphx if (x->a_syms > 0) { 89272a1c38Sphx--cut-- 90272a1c38Sphx 91272a1c38Sphx include/inttypes.h: 92272a1c38Sphx--cut-- 93272a1c38Sphx#ifndef _INTTYPES_H 94272a1c38Sphx#define _INTTYPES_H 95272a1c38Sphx 96272a1c38Sphx#include <sys/types.h> 97*34815acdSphx#include <sys/cdefs.h> 98272a1c38Sphx 99*34815acdSphx#ifndef be32toh 100*34815acdSphx#define be32toh(x) (x) 101*34815acdSphx#endif 102*34815acdSphx 103*34815acdSphx#ifndef roundup 104*34815acdSphx#define roundup(x,y) ((((x)+((y)-1))/(y))*(y)) 105*34815acdSphx#endif 106*34815acdSphx 107272a1c38Sphxtypedef unsigned long vaddr_t; 108272a1c38Sphxtypedef unsigned long paddr_t; 109272a1c38Sphx 110272a1c38Sphx#endif /* !_INTTYPES_H */ 111272a1c38Sphx--cut-- 112272a1c38Sphx 113272a1c38Sphx include/namespace.h 114272a1c38Sphx--cut-- 115272a1c38Sphx#define _DIAGASSERT(x) /**/ 116272a1c38Sphx 117272a1c38Sphxextern char *program_name; 118272a1c38Sphx#define getprogname() program_name 119*34815acdSphx 120*34815acdSphx#ifndef __UNCONST 121*34815acdSphx#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) 122*34815acdSphx#endif 123272a1c38Sphx--cut-- 124272a1c38Sphx 125272a1c38Sphx include/lib/libsa/stand.h 126272a1c38Sphx--cut-- 127272a1c38Sphx#include <stdio.h> 128272a1c38Sphx#include <string.h> 129272a1c38Sphx#include <errno.h> 130272a1c38Sphx#include <stdlib.h> 131272a1c38Sphx#include <unistd.h> 132272a1c38Sphx#include <fcntl.h> 133272a1c38Sphx#include "inttypes.h" 134272a1c38Sphx--cut-- 135272a1c38Sphx 136272a1c38Sphx include/lib/libkern/libkern.h 137272a1c38Sphx--cut-- 138272a1c38Sphx/* nothing, must only exist! */ 139272a1c38Sphx--cut-- 140