Module Name:    src
Committed By:   phx
Date:           Wed Nov 11 16:08:52 UTC 2015

Modified Files:
        src/sys/arch/amiga/stand/loadbsd: Makefile README

Log Message:
Build instructions and Makefile for loadbsd 3.0.
Submitted by Gunther Nikl.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/stand/loadbsd/Makefile \
    src/sys/arch/amiga/stand/loadbsd/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/stand/loadbsd/Makefile
diff -u src/sys/arch/amiga/stand/loadbsd/Makefile:1.2 src/sys/arch/amiga/stand/loadbsd/Makefile:1.3
--- src/sys/arch/amiga/stand/loadbsd/Makefile:1.2	Mon Jan  5 20:51:30 1998
+++ src/sys/arch/amiga/stand/loadbsd/Makefile	Wed Nov 11 16:08:52 2015
@@ -1,13 +1,13 @@
-#	$NetBSD: Makefile,v 1.2 1998/01/05 20:51:30 perry Exp $
+#	$NetBSD: Makefile,v 1.3 2015/11/11 16:08:52 phx Exp $
 #
-CC = gcc
-CFLAGS = -m68030 -O2 -D__progname=program_name -noixemul
+TARGET	= loadbsd
 
-OBJS = loadbsd.o getopt.o
-LIBS = -lamiga
+CC	= gcc
+CFLAGS	= -D_STANDALONE -I./include -O -fomit-frame-pointer -msmall-code
+LDFLAGS	= -noixemul
+LDLIBS	=
 
-loadbsd: $(OBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o loadbsd $(OBJS) $(LIBS)
+OBJS	= loadbsd.o loadfile.o loadfile_aout.o loadfile_elf32.o getopt.o
 
-clean:
-	delete $(OBJS) loadbsd
+$(TARGET): $(OBJS)
+	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
Index: src/sys/arch/amiga/stand/loadbsd/README
diff -u src/sys/arch/amiga/stand/loadbsd/README:1.2 src/sys/arch/amiga/stand/loadbsd/README:1.3
--- src/sys/arch/amiga/stand/loadbsd/README:1.2	Mon Jan  5 20:51:31 1998
+++ src/sys/arch/amiga/stand/loadbsd/README	Wed Nov 11 16:08:52 2015
@@ -1,22 +1,167 @@
-#	$NetBSD: README,v 1.2 1998/01/05 20:51:31 perry Exp $
+#	$NetBSD: README,v 1.3 2015/11/11 16:08:52 phx Exp $
 
-This was prepared to compile with gcc 2.7.0 for AmigaOS and 
-libnix 1.0. You don't need ixemul or special directories to run the
-binary, if compiled that way.
+BUILD INSTRUCTIONS
 
-With very old versions of gcc, you might need to add +2-. to relative
-offsets in the assembler part, but honestly, I suggest you upgrade your
-assembler (and compiler) instead, even if you know what I'm talking about 
-and how to identify the lines.
-
-You'll need the (unchanged) getopt.c from src/lib/libc/stdlib, too.
-
-With newer libnix or the ADE version of gcc, or when removing the
--noixemul option from CFLAGS, you might need (or want) to delete the 
-sleep() function at the bottom of loadbsd, or getopt.o from the 
-"OBJS =" line of Makefile.
-
-[Sorry, but I didn't dare to risk my gcc installation a few weeks 
- before the release by trying to install ADE]
-
-	Ignatios Souvatzis
+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--

Reply via email to