diff options
author | christos <christos@pkgsrc.org> | 1999-12-18 22:10:02 +0000 |
---|---|---|
committer | christos <christos@pkgsrc.org> | 1999-12-18 22:10:02 +0000 |
commit | 45bf2691a26ad2dc86a6b0ff10a65f10da841944 (patch) | |
tree | 795c4d9d8380c8df8738b1e2e53a63f1f725091b /emulators | |
parent | 0f993271a535cb108e90a3a4fdfa0233d54e823b (diff) | |
download | pkgsrc-45bf2691a26ad2dc86a6b0ff10a65f10da841944.tar.gz |
Use objcopy to make the binary file and load it directly,
instead of using loadfile which is less portable. [suggested by Tron]
Diffstat (limited to 'emulators')
-rw-r--r-- | emulators/doscmd/patches/patch-ab | 147 | ||||
-rw-r--r-- | emulators/doscmd/patches/patch-ah | 44 |
2 files changed, 80 insertions, 111 deletions
diff --git a/emulators/doscmd/patches/patch-ab b/emulators/doscmd/patches/patch-ab index faa645e8ec9..2bc70622146 100644 --- a/emulators/doscmd/patches/patch-ab +++ b/emulators/doscmd/patches/patch-ab @@ -1,90 +1,59 @@ -$NetBSD: patch-ab,v 1.5 1999/12/18 01:48:56 christos Exp $ +$NetBSD: patch-ab,v 1.6 1999/12/18 22:10:02 christos Exp $ -*** Makefile.orig Thu May 2 13:55:19 1996 ---- Makefile Fri Dec 17 20:27:36 1999 -*************** -*** 8,37 **** - int1a.c int2f.c intff.c \ - mem.c mouse.c net.c null.c port.c setver.c signal.c timer.c trace.c trap.c tty.c xms.c - - BINGRP= kmem - EXEGRP= bin - BINMODE=2555 - EXEMODE=444 -! CFLAGS+=-I/usr/X11/include -DDISASSEMBLER -g -! LDFLAGS+=-L/usr/X11/lib - LDADD+= -lX11 -li386 -lgcc -lc -lgcc -! DPADD+= /usr/X11/lib/libX11.a ${LIBC} ${LIBGCC} - - afterinstall: - install ${COPY} -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \ -! doscmd.kernel ${DESTDIR}/usr/libexec/doscmd.kernel - install -c -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \ -! ${.CURDIR}/instbsdi.exe ${DESTDIR}/usr/dos/ - -! doscmd: doscmd.kernel ${LIBCRT0} doscmd_loader.o -! ld -N -Bstatic -o doscmd ${LDFLAGS} ${LIBCRT0} doscmd_loader.o ${LDADD} - -! .include <bsd.prog.mk> - - .depend: doscmd_loader.c - - doscmd.kernel: crt0.o ${OBJS} -! ld -N -Bstatic -T 110000 -o doscmd.kernel ${LDFLAGS} crt0.o ${OBJS} ${LDADD} - - doscmd.0: doscmd.1 - tbl ${.IMPSRC} | nroff -mandoc > ${.TARGET} ---- 8,60 ---- - int1a.c int2f.c intff.c \ - mem.c mouse.c net.c null.c port.c setver.c signal.c timer.c trace.c trap.c tty.c xms.c - -+ BINDIR= ${PREFIX}/bin -+ MANDIR= ${PREFIX}/man -+ - BINGRP= kmem - EXEGRP= bin - BINMODE=2555 - EXEMODE=444 -! CFLAGS+=-I${X11BASE}/include -DDISASSEMBLER -g -! LDFLAGS+=-L${X11BASE}/lib -R${X11BASE}/lib - LDADD+= -lX11 -li386 -lgcc -lc -lgcc -! DPADD+= ${X11BASE}/lib/libX11.a ${LIBC} ${LIBGCC} -! # XXX: For loadfile -! LIBSA= /usr/src/sys/lib/libsa -! CLEANFILES+= loadfile.c loadfile.h -! -! .include <bsd.prog.mk> -! .if ${OBJECT_FMT} == "ELF" -! TEXT=-e start -Ttext -! CRTBEGIN=/usr/lib/crtbegin.o -! .else -! TEXT=-e _start -T -! CRTBEGIN= -! .endif -! - - afterinstall: - install ${COPY} -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \ -! doscmd.kernel ${PREFIX}/libexec/doscmd.kernel - install -c -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \ -! ${.CURDIR}/instbsdi.exe ${PREFIX}/libexec/ - -! doscmd: doscmd.kernel ${LIBCRT0} ${CRTBEGIN} doscmd_loader.o loadfile.o -! ld -N -Bstatic -o doscmd ${LDFLAGS:S/^-Wl,//g} ${LIBCRT0} ${CRTBEGIN} doscmd_loader.o loadfile.o ${LDADD} - -! -! loadfile.c: ${LIBSA}/loadfile.c -! @cp $> $@ -! -! loadfile.h: ${LIBSA}/loadfile.h -! @cp $> $@ -! -! doscmd_loader.o: loadfile.h - - .depend: doscmd_loader.c - - doscmd.kernel: crt0.o ${OBJS} -! ld -N -Bstatic ${TEXT} 0x110000 -o doscmd.kernel ${LDFLAGS:S/^-Wl,//g} crt0.o ${OBJS} ${LDADD} - - doscmd.0: doscmd.1 - tbl ${.IMPSRC} | nroff -mandoc > ${.TARGET} +--- Makefile.orig Thu May 2 13:55:19 1996 ++++ Makefile Sat Dec 18 17:02:32 1999 +@@ -8,30 +8,45 @@ + int1a.c int2f.c intff.c \ + mem.c mouse.c net.c null.c port.c setver.c signal.c timer.c trace.c trap.c tty.c xms.c + ++BINDIR= ${PREFIX}/bin ++MANDIR= ${PREFIX}/man ++ + BINGRP= kmem + EXEGRP= bin + BINMODE=2555 + EXEMODE=444 +-CFLAGS+=-I/usr/X11/include -DDISASSEMBLER -g +-LDFLAGS+=-L/usr/X11/lib ++START_ADDRESS=0x110000 ++CFLAGS+=-I${X11BASE}/include -DDISASSEMBLER -g -DSTART_ADDRESS=${START_ADDRESS} ++LDFLAGS+=-L${X11BASE}/lib -R${X11BASE}/lib + LDADD+= -lX11 -li386 -lgcc -lc -lgcc +-DPADD+= /usr/X11/lib/libX11.a ${LIBC} ${LIBGCC} ++DPADD+= ${X11BASE}/lib/libX11.a ${LIBC} ${LIBGCC} ++ ++.include <bsd.prog.mk> ++.if ${OBJECT_FMT} == "ELF" ++TEXT=-e start -Ttext ${START_ADDRESS} ++CRTBEGIN=/usr/lib/crtbegin.o ++.else ++TEXT=-e _start -T ${START_ADDRESS} ++CRTBEGIN= ++.endif ++ + + afterinstall: + install ${COPY} -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \ +- doscmd.kernel ${DESTDIR}/usr/libexec/doscmd.kernel ++ doscmd.kernel ${PREFIX}/libexec/doscmd.kernel + install -c -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \ +- ${.CURDIR}/instbsdi.exe ${DESTDIR}/usr/dos/ ++ ${.CURDIR}/instbsdi.exe ${PREFIX}/libexec/ + +-doscmd: doscmd.kernel ${LIBCRT0} doscmd_loader.o +- ld -N -Bstatic -o doscmd ${LDFLAGS} ${LIBCRT0} doscmd_loader.o ${LDADD} ++doscmd: doscmd.kernel ${LIBCRT0} ${CRTBEGIN} doscmd_loader.o ++ ld -N -Bstatic -o doscmd ${LDFLAGS:S/^-Wl,//g} ${LIBCRT0} ${CRTBEGIN} doscmd_loader.o ${LDADD} + +-.include <bsd.prog.mk> + + .depend: doscmd_loader.c + + doscmd.kernel: crt0.o ${OBJS} +- ld -N -Bstatic -T 110000 -o doscmd.kernel ${LDFLAGS} crt0.o ${OBJS} ${LDADD} ++ ld -N -Bstatic ${TEXT} -o doscmd.bin ${LDFLAGS:S/^-Wl,//g} crt0.o ${OBJS} ${LDADD} ++ objcopy -O binary doscmd.bin $@ ++ @rm -f doscmd.bin + + doscmd.0: doscmd.1 + tbl ${.IMPSRC} | nroff -mandoc > ${.TARGET} diff --git a/emulators/doscmd/patches/patch-ah b/emulators/doscmd/patches/patch-ah index b317a583dbf..f677f25e2de 100644 --- a/emulators/doscmd/patches/patch-ah +++ b/emulators/doscmd/patches/patch-ah @@ -1,14 +1,16 @@ -$NetBSD: patch-ah,v 1.1 1999/12/18 01:46:29 christos Exp $ +$NetBSD: patch-ah,v 1.2 1999/12/18 22:10:02 christos Exp $ ---- doscmd_loader.c.orig Fri Dec 17 20:40:25 1999 -+++ doscmd_loader.c Sun Dec 5 18:11:38 1999 -@@ -31,38 +31,52 @@ +--- doscmd_loader.c.orig Fri Dec 17 22:48:20 1999 ++++ doscmd_loader.c Sat Dec 18 17:01:53 1999 +@@ -31,38 +31,50 @@ */ #include <stdio.h> -#include <a.out.h> +#include <unistd.h> -+#include "loadfile.h" ++#include <fcntl.h> ++#include <sys/stat.h> ++#include <sys/mman.h> /* * reserve space in "low" memory for the interrupt vector table @@ -27,23 +29,22 @@ $NetBSD: patch-ah,v 1.1 1999/12/18 01:46:29 christos Exp $ + NULL +}; + -+#define COUNT (COUNT_TEXT|COUNT_DATA|COUNT_BSS) -+#define LOAD (LOAD_TEXT|LOAD_DATA|LOAD_BSS) -+ +u_long load_kernel(void) { - FILE *fp; - struct exec exec; - int start_address; -+ int i; -+ u_long marks[MARK_MAX]; - +- int start_address; +- - if ((fp = fopen(_PATH_DOS_KERNEL, "r")) == NULL && - (fp = fopen("obj/" _PATH_DOS_KERNEL, "r")) == NULL && - (fp = fopen(_PATH_DOS_KERNEL_DIR _PATH_DOS_KERNEL, "r")) == NULL) ++ int i, fd; ++ size_t size; ++ struct stat st; ++ + for (i = 0; locations[i] != NULL; i++) { -+ if (access(locations[i], R_OK) != -1) ++ if ((fd = open(locations[i], O_RDONLY)) != -1) + break; + } + if (locations[i] == NULL) @@ -51,9 +52,8 @@ $NetBSD: patch-ah,v 1.1 1999/12/18 01:46:29 christos Exp $ - if (fread(&exec, sizeof(exec), 1, fp) != 1 || N_GETMAGIC(exec) != OMAGIC) - errx(1, "bad kernel file format"); -+ memset(marks, 0, sizeof(marks)); -+ if (loadfile(locations[i], marks, COUNT) == -1) -+ err(1, "loadfile(COUNT)"); ++ if (fstat(fd, &st) == -1) ++ err(1, "fstat"); - start_address = exec.a_entry & (~(getpagesize() - 1)); - if (brk(start_address + exec.a_text + exec.a_data + exec.a_bss) < 0) @@ -62,13 +62,13 @@ $NetBSD: patch-ah,v 1.1 1999/12/18 01:46:29 christos Exp $ - bzero((char *)(start_address + exec.a_text + exec.a_data), exec.a_bss); - fclose(fp); - return(exec.a_entry); -+ if (brk((void *)marks[MARK_END]) == -1) -+ err(1, "brk"); -+ -+ if (loadfile(locations[i], marks, LOAD) == -1) -+ err(1, "loadfile(LOAD)"); ++ size = st.st_size + START_ADDRESS; + -+ return(marks[MARK_ENTRY]); ++ if (mmap((void *)START_ADDRESS, st.st_size, ++ PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0) == MAP_FAILED) ++ err(1, "mmap"); ++ ++ return(START_ADDRESS); } void |