README
1# $NetBSD: README,v 1.6 2023/05/14 16:13:05 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 a modern AmigaOS gcc, or vbcc
9with PosixLib.
10These instructions do only apply for LoadBSD versions using the loadfile()
11interface. Previous version do only require getopt.c and reboot.h.
12
13Note: It is not possible to build LoadBSD with the native NetBSD compiler!
14 LoadBSD is an *AmigaOS* program and must be built with an AmigaOS
15 compiler. Of course, a properly setup cross-compiler does work.
16
17Required sources from NetBSD (either HEAD or from a release branch)
18
19 From src/sys/lib/libsa: loadfile.h,loadfile.c,loadfile_elf32.c,loadfile_aout.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,aout_mids.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
49The headers inttypes.h, namespace.h, include/lib/libsa/stand.h and
50lib/libkern/libkern.h are listed completely below.
51
52Then it should be possible to recompile LoadBSD with gcc6 or newer by
53typing "make" (or "make -f vmakefile" with vbcc). If make fails, fix the
54problem and try again :-P
55
56Good luck!
57
58--- Missing files/patches ---
59
60 include/machine/loadfile_machdep.h modification:
61--cut--
62--- include/machine/loadfile_machdep.h~ Sun Mar 26 15:46:55 2023
63+++ include/machine/loadfile_machdep.h Sun Mar 26 15:47:17 2023
64@@ -38,7 +38,7 @@
65 #define LOAD_KERNEL LOAD_ALL
66 #define COUNT_KERNEL COUNT_ALL
67
68-#ifdef _STANDALONE
69+#if 0
70
71 #define LOADADDR(a) ((a) + offset)
72 #define ALIGNENTRY(a) 0
73--cut--
74
75 loadfile_aout.c modification:
76--cut--
77--- loadfile_aout.c~ Mon Feb 11 21:25:56 2002
78+++ loadfile_aout.c Thu Jan 23 10:43:27 2003
79@@ -217,8 +217,8 @@ loadfile_aout(fd, x, marks, flags)
80 BCOPY(&x->a_syms, maxp, sizeof(x->a_syms));
81
82 if (flags & (LOAD_SYM|COUNT_SYM)) {
83- maxp += sizeof(x->a_syms);
84 aoutp = maxp;
85+ maxp += sizeof(x->a_syms);
86 }
87
88 if (x->a_syms > 0) {
89--cut--
90
91 include/inttypes.h:
92--cut--
93#ifndef _INTTYPES_H
94#define _INTTYPES_H
95
96#include <sys/types.h>
97#include <sys/cdefs.h>
98
99#ifndef be32toh
100#define be32toh(x) (x)
101#endif
102
103#ifndef roundup
104#define roundup(x,y) ((((x)+((y)-1))/(y))*(y))
105#endif
106
107typedef unsigned long vaddr_t;
108typedef unsigned long paddr_t;
109
110#endif /* !_INTTYPES_H */
111--cut--
112
113 include/namespace.h
114--cut--
115#define _DIAGASSERT(x) /**/
116
117extern char *program_name;
118#define getprogname() program_name
119
120#ifndef __UNCONST
121#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
122#endif
123--cut--
124
125 include/lib/libsa/stand.h
126--cut--
127#include <stdio.h>
128#include <string.h>
129#include <errno.h>
130#include <stdlib.h>
131#include <unistd.h>
132#include <fcntl.h>
133#include "inttypes.h"
134--cut--
135
136 include/lib/libkern/libkern.h
137--cut--
138/* nothing, must only exist! */
139--cut--
140