From a8f7d98ad9d9ac7b2622850d3eacc04485102ac9 Mon Sep 17 00:00:00 2001 From: minoura Date: Sat, 24 Nov 2001 16:18:44 +0000 Subject: [PATCH] Emit the binaries directly from the loader. --- sys/arch/x68k/stand/boot_ufs/Makefile | 47 ++++++++------- .../x68k/stand/boot_ufs/boot_ufs.ldscript | 3 +- sys/arch/x68k/stand/boot_ustar/Makefile | 59 +++++++++++++------ .../x68k/stand/boot_ustar/boot_ustar.ldscript | 3 +- 4 files changed, 70 insertions(+), 42 deletions(-) diff --git a/sys/arch/x68k/stand/boot_ufs/Makefile b/sys/arch/x68k/stand/boot_ufs/Makefile index f2ef4af6bf2d..cca50ad58035 100644 --- a/sys/arch/x68k/stand/boot_ufs/Makefile +++ b/sys/arch/x68k/stand/boot_ufs/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 2001/10/15 16:23:01 minoura Exp $ +# $NetBSD: Makefile,v 1.7 2001/11/24 16:18:44 minoura Exp $ .include @@ -19,8 +19,6 @@ STRIPFLAG= BINMODE= 444 MKMAN= no -OBJCOPY?= objcopy - S= ${.CURDIR}/../../../.. M= $S/arch/${MACHINE} LIBKERN= $S/lib/libkern/arch/${MACHINE_ARCH} @@ -45,29 +43,38 @@ CPPFLAGS+= -DUSE_FFS #-DUSE_LFS CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} AFLAGS= ${CFLAGS:M-[ID]*} .if ${OBJECT_FMT} == "ELF" -LDFLAGS= -N -Bstatic -T ${.CURDIR}/${BOOT}.ldscript +LDFLAGS= -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M LDFLAGS+= -noinhibit-exec # XXX .else -LDFLAGS= -n -Bstatic -Ttext ${TEXT} +LDFLAGS= -n -Bstatic -Ttext ${TEXT} -M +OBJCOPY?= objcopy .endif -CLEANFILES= $(PROG).x s.x x.s x.o +CLEANFILES+= $(PROG).x $(PROG).map $(PROG): $(OBJS) - $(LD) $(LDFLAGS) -o $(PROG).x $(OBJS) $(LDADD) - @$(NM) --target=a.out-m68k-netbsd $(PROG).x | sed -n '/T first_kbyte/p' - @if [ `(echo ibase=16; \ - $(NM) --target=a.out-m68k-netbsd $(PROG).x | sed -n 's/T first_kbyte/-$(TEXT)-400/p' | \ - tr a-f A-F) | bc` -gt 0 ];\ - then echo '$(PROG): first_kbyte exceeds the first killobyte'; exit 1; fi - @$(SIZE) --target=a.out-m68k-netbsd $(PROG).x - @if [ `(echo ibase=16; \ - $(NM) --target=a.out-m68k-netbsd $(PROG).x | sed -n 's/D _edata/-$(TEXT)-2000/p' | tr a-f A-F) |\ - bc` -gt 0 ];\ - then echo '$(PROG): text+data is too large'; exit 1; fi - @cp $(PROG).x s.x - @$(OBJCOPY) -I a.out-m68k-netbsd -O binary s.x $(PROG) - @rm s.x + $(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDADD) > $(PROG).map + @grep first_kbyte $(PROG).map +.if ${OBJECT_FMT} == "ELF" + @if [ `(echo ibase=16; \ + sed -n 's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p' \ + $(PROG).map | \ + tr a-f A-F) | bc` -gt 0 ]; \ + then echo '$(BOOT): first_kbyte exceeds the first killobyte'; \ + rm $(PROG) ; exit 1; \ + fi +.else + mv $(PROG) $(PROG).x + $(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG) + @rm -f $(PROG).x + @if [ `(echo ibase=16; \ + sed -n 's/ first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p' \ + $(PROG).map | \ + tr a-f A-F) | bc` -gt 0 ]; \ + then echo '$(BOOT): first_kbyte exceeds the first killobyte'; \ + rm $(PROG) ; exit 1; \ + fi +.endif .include diff --git a/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript b/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript index 6470c9505bf3..22574b750e92 100644 --- a/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript +++ b/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript @@ -1,5 +1,4 @@ -OUTPUT_FORMAT("a.out-m68k-netbsd", "a.out-m68k-netbsd", - "a.out-m68k-netbsd") +OUTPUT_FORMAT("binary", "binary", "binary") OUTPUT_ARCH(m68k) ENTRY(start) SEARCH_DIR(/usr/lib); diff --git a/sys/arch/x68k/stand/boot_ustar/Makefile b/sys/arch/x68k/stand/boot_ustar/Makefile index 6d7b83df2cfe..b95fe502bd73 100644 --- a/sys/arch/x68k/stand/boot_ustar/Makefile +++ b/sys/arch/x68k/stand/boot_ustar/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 2001/10/15 16:23:01 minoura Exp $ +# $NetBSD: Makefile,v 1.5 2001/11/24 16:18:45 minoura Exp $ .include @@ -17,8 +17,6 @@ STRIPFLAG= BINMODE= 444 MKMAN= no -OBJCOPY?= objcopy - S= ${.CURDIR}/../../../.. M= $S/arch/x68k COMMONDIR= $M/stand/common @@ -36,27 +34,52 @@ CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} AFLAGS= ${CFLAGS:M-[ID]*} AFLAGS+= -Wa,-mc68000 .if ${OBJECT_FMT} == "ELF" -LDFLAGS= -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript +LDFLAGS= -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M LDFLAGS+= -noinhibit-exec # XXX .else -LDFLAGS= -n -Bstatic -Ttext ${TEXT} +LDFLAGS= -n -Bstatic -Ttext ${TEXT} -M +OBJCOPY?= objcopy .endif -CLEANFILES= ${PROG}.x s.x x.s x.o +CLEANFILES= ${PROG}.x $(PROG).map ${PROG}: $(OBJS) - $(LD) $(LDFLAGS) -o ${PROG}.x $(OBJS) $(LDADD) - @$(NM) --target=a.out-m68k-netbsd ${PROG}.x | sed -n '/T first_kbyte/p' - @if [ `(echo ibase=16; \ - $(NM) --target=a.out-m68k-netbsd ${PROG}.x | sed -n 's/T first_kbyte/-$(TEXT)-400/p' | \ - tr a-f A-F) | bc` -gt 0 ];\ - then echo '${PROG}: first_kbyte exceeds the first killobyte'; exit 1; fi - @$(SIZE) --target=a.out-m68k-netbsd ${PROG}.x - @if [ `(echo ibase=16; \ - $(NM) --target=a.out-m68k-netbsd ${PROG}.x | sed -n 's/D _edata/-$(TEXT)-2000/p' | tr a-f A-F) |\ - bc` -gt 0 ];\ - then echo '${PROG}: text+data is too large'; exit 1; fi - @$(OBJCOPY) -I a.out-m68k-netbsd -O binary ${PROG}.x ${PROG} + $(LD) $(LDFLAGS) -o ${PROG} $(OBJS) $(LDADD) > $(PROG).map + @grep first_kbyte $(PROG).map +.if ${OBJECT_FMT} == "ELF" + @if [ `(echo ibase=16; \ + sed -n 's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p' \ + $(PROG).map | \ + tr a-f A-F) | bc` -gt 0 ]; \ + then echo '$(BOOT): first_kbyte exceeds the first killobyte'; \ + rm $(PROG) ; exit 1; \ + fi + @if [ `(echo ibase=16; \ + sed -n 's/^.*0x\([0-9a-f]*\).* _edata=\.$$/\1-$(TEXT)-2000/p' \ + $(PROG).map | \ + tr a-f A-F) | bc` -gt 0 ]; \ + then echo '$(BOOT): text+data is too large'; \ + rm $(PROG) ; exit 1; \ + fi +.else + mv $(PROG) $(PROG).x + $(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG) + @rm -f $(PROG).x + @if [ `(echo ibase=16; \ + sed -n 's/ first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p' \ + $(PROG).map | \ + tr a-f A-F) | bc` -gt 0 ]; \ + then echo '$(BOOT): first_kbyte exceeds the first killobyte'; \ + rm $(PROG) ; exit 1; \ + fi + @if [ `(echo ibase=16; \ + sed -n 's/ _edata:.*0x\(.*\),.*$$/\1-$(TEXT)-2000/p' \ + $(PROG).map | \ + tr a-f A-F) | bc` -gt 0 ]; \ + then echo '$(BOOT): text+data is too large'; \ + rm $(PROG) ; exit 1; \ + fi +.endif .include diff --git a/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript b/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript index 640a24172415..63e606206d00 100644 --- a/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript +++ b/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript @@ -1,5 +1,4 @@ -OUTPUT_FORMAT("a.out-m68k-netbsd", "a.out-m68k-netbsd", - "a.out-m68k-netbsd") +OUTPUT_FORMAT("binary", "binary", "binary") OUTPUT_ARCH(m68k) ENTRY(start) SEARCH_DIR(/usr/lib);