Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x68k/stand Use ASSERT() in ldscript to check first_...



details:   https://anonhg.NetBSD.org/src/rev/17a2eae57a81
branches:  trunk
changeset: 467241:17a2eae57a81
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sat Jan 18 06:44:23 2020 +0000

description:
Use ASSERT() in ldscript to check first_kbyte (etc) restrictions,
rather than complicated shell expressions in Makefile.

diffstat:

 sys/arch/x68k/stand/boot_ufs/Makefile              |  20 ++----------------
 sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript     |   2 +
 sys/arch/x68k/stand/boot_ustar/Makefile            |  21 ++-----------------
 sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript |   3 ++
 sys/arch/x68k/stand/xxboot/Makefile.xxboot         |  23 ++-------------------
 sys/arch/x68k/stand/xxboot/xxboot.ldscript         |   2 +
 6 files changed, 16 insertions(+), 55 deletions(-)

diffs (158 lines):

diff -r 58c58d9c5084 -r 17a2eae57a81 sys/arch/x68k/stand/boot_ufs/Makefile
--- a/sys/arch/x68k/stand/boot_ufs/Makefile     Sat Jan 18 06:34:29 2020 +0000
+++ b/sys/arch/x68k/stand/boot_ufs/Makefile     Sat Jan 18 06:44:23 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.34 2020/01/18 06:34:29 isaki Exp $
+#      $NetBSD: Makefile,v 1.35 2020/01/18 06:44:23 isaki Exp $
 
 NOMAN=         # defined
 
@@ -42,29 +42,15 @@
 CPPFLAGS+= -DUSE_FFS -DUSE_LFS -DUSE_UFS1 -DUSE_UFS2
 CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} -I${S} -I. -D_STANDALONE
 AFLAGS=           ${CFLAGS:M-[ID]*}
-LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M
+LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
 
 .include "${.CURDIR}/../Makefile.booters"
 .include "${S}/../common/lib/libc/Makefile.inc"
 
-CLEANFILES+=   $(PROG).x $(PROG).map
-
 
 $(PROG): $(OBJS)
        ${_MKTARGET_LINK}
-       :
-       : Note: "relocation truncated to fit: R_68K_16" messages are expected.
-       :       Other errors are fatal.
-       :
-       $(LD) $(LINKFLAGS) -o $(PROG).x $(OBJS) $(LDADD) >$(PROG).map
-       @grep first_kbyte $(PROG).map
-       @if [ `${TOOL_AWK}                                                 \
-           '/first_kbyte/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'    \
-           $(PROG).map | ${TOOL_M4} -` -gt 1024 ];                        \
-       then echo '$(BOOT): first_kbyte exceeds the first killobyte';      \
-           exit 1;                                                        \
-       fi
-       mv -f $(PROG).x $(PROG)
+       $(LD) $(LINKFLAGS) -o $(PROG) $(OBJS) $(LDADD)
 
 .include <bsd.prog.mk>
diff -r 58c58d9c5084 -r 17a2eae57a81 sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
--- a/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript    Sat Jan 18 06:34:29 2020 +0000
+++ b/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript    Sat Jan 18 06:44:23 2020 +0000
@@ -46,3 +46,5 @@
   }
   /DISCARD/ : { *(.ident) *(.stab) *(.stabstr) }
 }
+
+ASSERT(first_kbyte - TEXTADDR <= 1024, "Error: first_kbyte exceeds 1KB");
diff -r 58c58d9c5084 -r 17a2eae57a81 sys/arch/x68k/stand/boot_ustar/Makefile
--- a/sys/arch/x68k/stand/boot_ustar/Makefile   Sat Jan 18 06:34:29 2020 +0000
+++ b/sys/arch/x68k/stand/boot_ustar/Makefile   Sat Jan 18 06:44:23 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.28 2020/01/18 06:34:30 isaki Exp $
+#      $NetBSD: Makefile,v 1.29 2020/01/18 06:44:23 isaki Exp $
 
 NOMAN=         # defined
 
@@ -37,30 +37,15 @@
 CFLAGS+=   -m68000
 AFLAGS=           ${CFLAGS:M-[ID]*}
 AFLAGS+=   -Wa,-march=m68000 -Wa,-mcpu=m68000
-LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M
+LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
 
 .include "${.CURDIR}/../Makefile.booters"
 .include "${S}/../common/lib/libc/Makefile.inc"
 
-CLEANFILES+=   ${PROG}.x $(PROG).map
-
 
 ${PROG}: $(OBJS)
        ${_MKTARGET_LINK}
-       $(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDADD) > $(PROG).map
-       @grep first_kbyte $(PROG).map
-       @if [ `${TOOL_AWK}                                                 \
-           '/first_kbyte/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'    \
-           $(PROG).map | ${TOOL_M4} -` -gt 1024 ];                        \
-       then echo '$(BOOT): first_kbyte exceeds the first killobyte';      \
-           rm $(PROG) ; exit 1;                                           \
-       fi
-       @if [ `${TOOL_AWK}                                                 \
-           '/_edata/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'         \
-           $(PROG).map | ${TOOL_M4} -` -gt 8192 ];                        \
-       then echo '$(BOOT): text+data is too large';                       \
-           rm $(PROG) ; exit 1;                                           \
-       fi
+       $(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDADD)
 
 .include <bsd.prog.mk>
diff -r 58c58d9c5084 -r 17a2eae57a81 sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
--- a/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript        Sat Jan 18 06:34:29 2020 +0000
+++ b/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript        Sat Jan 18 06:44:23 2020 +0000
@@ -45,3 +45,6 @@
   }
   /DISCARD/ : { *(.ident) *(.stab) *(.stabstr) }
 }
+
+ASSERT(first_kbyte - TEXTADDR <= 1024, "Error: first_kbyte exceeds 1KB");
+ASSERT(_edata - TEXTADDR <= 8192, "Error: text+data is too large to bootarea");
diff -r 58c58d9c5084 -r 17a2eae57a81 sys/arch/x68k/stand/xxboot/Makefile.xxboot
--- a/sys/arch/x68k/stand/xxboot/Makefile.xxboot        Sat Jan 18 06:34:29 2020 +0000
+++ b/sys/arch/x68k/stand/xxboot/Makefile.xxboot        Sat Jan 18 06:44:23 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.xxboot,v 1.9 2020/01/18 06:34:30 isaki Exp $
+#      $NetBSD: Makefile.xxboot,v 1.10 2020/01/18 06:44:23 isaki Exp $
 
 NOMAN=         # defined
 
@@ -39,7 +39,7 @@
 CPPFLAGS+= -nostdinc -I${.OBJDIR} -I${S}
 CPPFLAGS+= -I$M/stand/libiocs -I$M/stand/libsa -I$M/stand/common
 AFLAGS=           ${CFLAGS:M-[ID]*}
-LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript -M
+LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
 LINKFLAGS+=  --defsym=TEXTDATASIZE=$(TEXTDATASIZE)
 LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
@@ -59,27 +59,10 @@
 
 .include "${.CURDIR}/../../Makefile.booters"
 
-CLEANFILES+=   ${PROG}.x $(PROG).map ${PROG}
-
 
 ${PROG}: $(OBJS)
        ${_MKTARGET_LINK}
-       $(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
-       @grep first_kbyte $(PROG).map
-       @if [ `${TOOL_AWK}                                                 \
-           '/first_kbyte/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'    \
-           $(PROG).map | ${TOOL_M4} -` -gt 1024 ];                        \
-       then echo '$(BOOT): first_kbyte exceeds the first killobyte';      \
-           rm $(PROG) ; exit 1;                                           \
-       fi
-       @if [ `${TOOL_AWK}                                                 \
-           '/_edata/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'         \
-           $(PROG).map | ${TOOL_M4} -`                                    \
-           -gt                                                            \
-           `echo 'eval($(TEXTDATASIZE))' | ${TOOL_M4} -` ];               \
-       then echo '$(BOOT): text+data is too large';                       \
-           rm $(PROG) ; exit 1;                                           \
-       fi
+       $(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS)
        ${TOUCHPROG}
 
 .include <bsd.prog.mk>
diff -r 58c58d9c5084 -r 17a2eae57a81 sys/arch/x68k/stand/xxboot/xxboot.ldscript
--- a/sys/arch/x68k/stand/xxboot/xxboot.ldscript        Sat Jan 18 06:34:29 2020 +0000
+++ b/sys/arch/x68k/stand/xxboot/xxboot.ldscript        Sat Jan 18 06:44:23 2020 +0000
@@ -46,3 +46,5 @@
   }
   /DISCARD/ : { *(.ident) *(.stab) *(.stabstr) }
 }
+
+ASSERT(first_kbyte - TEXTADDR <= 1024, "Error: first_kbyte exceeds 1KB");



Home | Main Index | Thread Index | Old Index