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