Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

#	$NetBSD: README,v 1.3 2015/11/11 16:08:52 phx Exp $

BUILD INSTRUCTIONS

Building LoadBSD isn't easy since several sources from the NetBSD repository
are required. Compiling these sources under AmigaOS without clashes with the
native GCC headers requires some knowledge. This document tries to describe
the steps necessary to rebuild LoadBSD with an AmigaOS gcc. These instructions
do only apply for LoadBSD versions using the loadfile() interface. Previous
version do only require getopt.c and reboot.h.

Note: Its not possible to build LoadBSD with the native NetBSD compiler!
      LoadBSD is an *AmigaOS* program and must be built with an AmigaOS
      compiler. Of course, a properly setup cross-compiler does work.

Required sources from NetBSD (either HEAD or from a release branch)

   From src/sys/lib/libsa: loadfile.h,loadfile.c,loadfile_elf32.c,loadfile_aout.c
   From src/lib/libc/stdlib: getopt.c

      place these files in the directory where you have loadbsd.c

   From src/sys/arch/m68k/include: aout_machdep.h,elf_machdep.h

      place these files in: <loadbsd directory>/include/m68k

   From src/sys/arch/amiga/include: aout_machdep.h,elf_machdep.h,loadfile_machdep.h

      place these files in: <loadbsd directory>/include/machine

   From src/sys/sys: exec.h,exec_elf.h,exec_aout.h,reboot.h

      place these files in: <loadbsd directory>/include/sys

   Additional headers (see below): inttypes.h,namespace.h,lib/libsa/stand.h,lib/libkern/libkern.h

      place these files in: <loadbsd directory>/include

If all the mentioned files are placed at the correct place, loadfile_machdep.h
must be modfied. The patch is included below. Another small patch to
loadfile_aout.c must be applied to fix an incompatibility for LoadBSD.
However, that patch breaks loadfile() for other architectures using a.out!
Note: This patch is required to be able to suppress loaded symbols when
      booting ancient a.out kernels that don't support them. Without the
      patch symbol suppressing doesn't work! That also means ELF isn't
      affected and LoadBSD could handle it differently but then it could
      probably break in other unpredictable ways...

Then it should be possible to recompile LoadBSD by typing "make". If make
fails, fix the problem and try again :-P

Good luck!

--- Missing files/patches ---

      loadfile_aout.c modification:
--cut--
--- loadfile_aout.c~	Mon Feb 11 21:25:56 2002
+++ loadfile_aout.c	Thu Jan 23 10:43:27 2003
@@ -217,8 +217,8 @@ loadfile_aout(fd, x, marks, flags)
 		BCOPY(&x->a_syms, maxp, sizeof(x->a_syms));
 
 	if (flags & (LOAD_SYM|COUNT_SYM)) {
-		maxp += sizeof(x->a_syms);
 		aoutp = maxp;
+		maxp += sizeof(x->a_syms);
 	}
 
 	if (x->a_syms > 0) {
--cut--

      loadfile_machdep.h modification:
--cut--
--- loadfile_machdep.h~	Wed Oct 31 18:20:45 2001
+++ loadfile_machdep.h	Thu Jan 16 14:02:39 2003
@@ -42,6 +42,21 @@
 #define	BOOT_AOUT
 #define	BOOT_ELF32
 
+#if 1
+
+#define LOADADDR(a)		(((u_long)(a)) + offset)
+#define ALIGNENTRY(a)		0
+#define READ(f, b, c)		read((f), (void *)LOADADDR(b), (c))
+#define BCOPY(s, d, c)		memcpy((void *)LOADADDR(d), (void *)(s), (c))
+#define BZERO(d, c)		memset((void *)LOADADDR(d), 0, (c))
+#define WARN(a)			warn a
+#define PROGRESS(a)		/* nothing */
+#define ALLOC(a)		malloc(a)
+#define FREE(a, b)		free(a)
+#define OKMAGIC(a)		((a) == NMAGIC)
+
+#else /* ! true, false */
+
 #define	LOAD_KERNEL		LOAD_ALL
 #define	COUNT_KERNEL		COUNT_ALL
 
@@ -83,4 +98,7 @@ void vcopy __P((u_long, u_long, u_long *
 void vzero __P((u_long, u_long *, size_t));
 
 #endif
+
+#endif /* ! false */
+
 #endif /* ! _AMIGA_LOADFILE_MACHDEP_H_ */
--cut--

      Makefile:
--cut--
TARGET	= loadbsd

CC	= gcc -m68020 -Wa,-m68030 -fbaserel
CFLAGS	= -D_STANDALONE -I./include -O -fomit-frame-pointer -msmall-code
LDFLAGS	= -noixemul
LDLIBS	=

OBJS	= loadbsd.o loadfile.o loadfile_aout.o loadfile_elf32.o getopt.o

$(TARGET): $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
--cut--

      include/inttypes.h:
--cut--
#ifndef _INTTYPES_H
#define _INTTYPES_H

#include <sys/types.h>

typedef	unsigned char      uint8_t;
typedef	unsigned short     uint16_t;
typedef	unsigned int       uint32_t;
typedef	unsigned long long uint64_t;
/*
typedef	         int       int32_t;
typedef	         long long int64_t;
*/
typedef unsigned long vaddr_t;
typedef unsigned long paddr_t;

#endif /* !_INTTYPES_H */
--cut--

    include/namespace.h
--cut--
#define _DIAGASSERT(x) /**/

extern char *program_name;
#define getprogname() program_name
--cut--

      include/lib/libsa/stand.h
--cut--
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <err.h>
#include "inttypes.h"
--cut--

      include/lib/libkern/libkern.h
--cut--
/* nothing, must only exist! */
--cut--