Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/alpha/stand Compile with -Os (optimize for size).



details:   https://anonhg.NetBSD.org/src/rev/2a323c38b7e3
branches:  trunk
changeset: 467918:2a323c38b7e3
user:      cgd <cgd%NetBSD.org@localhost>
date:      Wed Mar 31 02:52:11 1999 +0000

description:
Compile with -Os (optimize for size).
Clean up the "Region 1" related definitions, and define load addresses,
  max load size, and max total size for as many boot block types as we can.
  (types = unified, primary, secondary).  We can't always define all
  values for all boot blocks, though.
Make CPP flags selection less gross.
Use objcopy rather than headersize (yay, evil gets a stake to the heart!).
Use a little shell script to verify that the sizes of the boot blocks are OK.
Do not compile too much more of libsa than we actually have to.

diffstat:

 sys/arch/alpha/stand/Makefile.bootprogs  |  63 +++++++++++++++++++---
 sys/arch/alpha/stand/boot/Makefile       |  22 ++++----
 sys/arch/alpha/stand/bootxx/Makefile     |  25 ++++----
 sys/arch/alpha/stand/common/checksize.sh |  75 +++++++++++++++++++++++++++
 sys/arch/alpha/stand/common/headersize.c |  86 --------------------------------
 sys/arch/alpha/stand/netboot/Makefile    |  24 ++++----
 6 files changed, 164 insertions(+), 131 deletions(-)

diffs (truncated from 397 to 300 lines):

diff -r 8a6b4671254a -r 2a323c38b7e3 sys/arch/alpha/stand/Makefile.bootprogs
--- a/sys/arch/alpha/stand/Makefile.bootprogs   Wed Mar 31 02:47:38 1999 +0000
+++ b/sys/arch/alpha/stand/Makefile.bootprogs   Wed Mar 31 02:52:11 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.bootprogs,v 1.4 1999/02/13 02:54:37 lukem Exp $
+# $NetBSD: Makefile.bootprogs,v 1.5 1999/03/31 02:52:11 cgd Exp $
 
 S=     ${.CURDIR}/../../../..
 
@@ -10,6 +10,8 @@
 
 STRIP?=        strip
 
+CHECKSIZE_CMD= SIZE=${SIZE} sh ${.CURDIR}/../common/checksize.sh
+
 .PHONY: machine-links
 beforedepend: machine-links
 # ${MACHINE} then ${MACHINE_ARCH}
@@ -26,23 +28,65 @@
 #CPPFLAGS+= -nostdinc -I${.OBJDIR}
 CPPFLAGS+= -I${.OBJDIR}
 CPPFLAGS += -D_STANDALONE -I${.CURDIR}/../.. -I${S}
-CFLAGS = ${CWARNFLAGS} -mno-fp-regs -g
+CFLAGS = ${CWARNFLAGS} -Os -mno-fp-regs -g
 
 # For descriptions of regions available to bootstrap programs, see
 # section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
 # the Alpha AXP Architecture Reference Manual.
 
-PRIMARY_LOAD_ADDRESS=  20000000        # "Region 1 start"
-SECONDARY_LOAD_ADDRESS=        20004000        # "Region 1 start" + 32k
-HEAP_LIMIT=            20040000        # "Region 1 start" + 256k
+REGION1_START=         0x20000000              # "Region 1 start"
+REGION1_SIZE!=         expr 256 \* 1024        # 256k
+
+# our memory lauout:
+
+#      'unified' boot loaders (e.g. netboot) can consume all of region
+#      1 for their text+data, or text+data+bss.
+
+UNIFIED_LOAD_ADDRESS=  ${REGION1_START}
+UNIFIED_MAX_LOAD!=     expr ${REGION1_SIZE}
+UNIFIED_MAX_TOTAL!=    expr ${REGION1_SIZE}
+
+#UNIFIED_HEAP_START=   right after secondary bss
+UNIFIED_HEAP_LIMIT=    (${REGION1_START} + ${REGION1_SIZE})
+
+#      two-stage boot loaders must share region 1.  The first stage
+#      loads into the lowest portion, and uses the higest portion
+#      for its heap.  The second stage loads in between the primary image
+#      and the heap, and can reuse the memory after it (i.e. the primary's
+#      heap) for its own heap.
+
+PRIMARY_LOAD_ADDRESS=  ${REGION1_START}
+#PRIMARY_MAX_LOAD=     booter dependent, no more than ${PRIMARY_MAX_TOTAL}
+PRIMARY_MAX_TOTAL!=    expr 16 \* 1024
 
-CPPFLAGS+=             -DPRIMARY_LOAD_ADDRESS="0x${PRIMARY_LOAD_ADDRESS}"
-CPPFLAGS+=             -DSECONDARY_LOAD_ADDRESS="0x${SECONDARY_LOAD_ADDRESS}"
-CPPFLAGS+=             -DHEAP_LIMIT="0x${HEAP_LIMIT}"
+# XXX SECONDARY_LOAD_ADDRESS should be
+# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
+# XXX way to do that calculation and 'ld' wants a single number.
+SECONDARY_LOAD_ADDRESS=        0x20004000      # XXX
+SECONDARY_MAX_LOAD!=   expr 112 \* 1024
+SECONDARY_MAX_TOTAL!=  expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
+
+PRIMARY_HEAP_START=    (${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
+PRIMARY_HEAP_LIMIT=    (${REGION1_START} + ${REGION1_SIZE})
+
+#SECONDARY_HEAP_START= right after secondary bss
+SECONDARY_HEAP_LIMIT=  (${REGION1_START} + ${REGION1_SIZE})
 
-PRIMARY_CPPFLAGS=      -DPRIMARY_BOOTBLOCK
 FILE_FORMAT_CPPFLAGS=  -DALPHA_BOOT_ECOFF -DALPHA_BOOT_ELF
 
+UNIFIED_CPPFLAGS=      -DPRIMARY_BOOTBLOCK \
+                       -DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
+                       ${FILE_FORMAT_CPP_FLAGS}
+
+PRIMARY_CPPFLAGS=      -DPRIMARY_BOOTBLOCK \
+                       -DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
+                       -DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
+                       -DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
+                       -DHEAP_START="${PRIMARY_HEAP_START}"
+
+SECONDARY_CPPFLAGS=    -DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
+                       ${FILE_FORMAT_CPP_FLAGS}
+
 .include <bsd.prog.mk>
 
 ### find out what to use for libkern
@@ -57,6 +101,5 @@
 
 ### find out what to use for libsa
 SA_AS=         library
-SAMISCMAKEFLAGS= SA_USE_CREAD=yes
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=         ${SALIB}
diff -r 8a6b4671254a -r 2a323c38b7e3 sys/arch/alpha/stand/boot/Makefile
--- a/sys/arch/alpha/stand/boot/Makefile        Wed Mar 31 02:47:38 1999 +0000
+++ b/sys/arch/alpha/stand/boot/Makefile        Wed Mar 31 02:52:11 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.20 1998/03/28 00:21:35 thorpej Exp $
+# $NetBSD: Makefile,v 1.21 1999/03/31 02:52:11 cgd Exp $
 
 PROG = boot
 
@@ -6,20 +6,20 @@
 SRCS+= devopen.c filesystem.c prom_swpal.S
 
 BOOT_RELOC = ${SECONDARY_LOAD_ADDRESS}
-HEADERSIZE_PROG = headersize
 
-CPPFLAGS += ${FILE_FORMAT_CPPFLAGS}
+CPPFLAGS += ${SECONDARY_CPPFLAGS}
 
-CLEANFILES+= vers.c vers.o ${PROG}.sym ${PROG}.nosym ${HEADERSIZE_PROG}
+CLEANFILES+= vers.c vers.o ${PROG}.sym
 
-${PROG}.nosym: ${PROG}.sym
-       cp ${PROG}.sym ${PROG}.nosym
-       ${STRIP} ${PROG}.nosym
+${PROG}: ${PROG}.sym
+       @echo creating ${PROG} from ${PROG}.sym...
+       @objcopy --output-target=binary ${PROG}.sym ${PROG}
+       @chmod 644 ${PROG}
+       @ls -l ${PROG}
+       @${CHECKSIZE_CMD} ${PROG}.sym ${PROG} ${SECONDARY_MAX_LOAD} \
+           ${SECONDARY_MAX_TOTAL} || (rm -f ${PROG} ; false)
 
-${PROG}: ${PROG}.nosym ${HEADERSIZE_PROG}
-       dd if=${PROG}.nosym of=${PROG} \
-           bs=`./${HEADERSIZE_PROG} ${BOOT_RELOC} ${PROG}.nosym` skip=1
-
+SAMISCMAKEFLAGS= SA_INCLUDE_NET=no SA_USE_CREAD=yes
 .include "../Makefile.bootprogs"
 
 ${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
diff -r 8a6b4671254a -r 2a323c38b7e3 sys/arch/alpha/stand/bootxx/Makefile
--- a/sys/arch/alpha/stand/bootxx/Makefile      Wed Mar 31 02:47:38 1999 +0000
+++ b/sys/arch/alpha/stand/bootxx/Makefile      Wed Mar 31 02:52:11 1999 +0000
@@ -1,25 +1,25 @@
-# $NetBSD: Makefile,v 1.16 1998/10/15 00:52:38 ross Exp $
+# $NetBSD: Makefile,v 1.17 1999/03/31 02:52:11 cgd Exp $
 
 PROG = bootxx
 
 SRCS = start.S bootxx.c prom.c prom_disp.S puts.c
 
 BOOT_RELOC = ${PRIMARY_LOAD_ADDRESS}
-HEADERSIZE_PROG = headersize
+PRIMARY_MAX_LOAD!=     expr 8192 - 512
 
 CPPFLAGS += ${PRIMARY_CPPFLAGS}
 
-CLEANFILES+= ${PROG}.sym ${PROG}.nosym ${HEADERSIZE_PROG}
-
-${PROG}.nosym: ${PROG}.sym
-       cp ${PROG}.sym ${PROG}.nosym
-       ${STRIP} ${PROG}.nosym
+CLEANFILES+= ${PROG}.sym
 
-${PROG}: ${PROG}.nosym ${HEADERSIZE_PROG}
-       dd if=${PROG}.nosym of=${PROG} \
-           ibs=`./${HEADERSIZE_PROG} ${BOOT_RELOC} ${PROG}.nosym` skip=1 \
-           obs=`expr 15 \* 512` conv=osync
+${PROG}: ${PROG}.sym
+       @echo creating ${PROG} from ${PROG}.sym...
+       @objcopy --output-target=binary ${PROG}.sym ${PROG}
+       @chmod 644 ${PROG}
+       @ls -l ${PROG}
+       @${CHECKSIZE_CMD} ${PROG}.sym ${PROG} ${PRIMARY_MAX_LOAD} \
+           ${PRIMARY_MAX_TOTAL} || (rm -f ${PROG} ; false)
 
+SAMISCMAKEFLAGS= SA_INCLUDE_NET=no SA_USE_CREAD=no
 .include "../Makefile.bootprogs"
 
 NETBSD_VERS!=sh ${.CURDIR}/../../../../conf/osrelease.sh
@@ -28,4 +28,5 @@
 ${PROG}.sym: ${OBJS} ${LIBKERN}
        ${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${PROG}.sym ${OBJS} \
            ${LIBKERN}
-       ${SIZE} ${PROG}.sym
+       @chmod 644 ${PROG}.sym
+       @${SIZE} ${PROG}.sym
diff -r 8a6b4671254a -r 2a323c38b7e3 sys/arch/alpha/stand/common/checksize.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/alpha/stand/common/checksize.sh  Wed Mar 31 02:52:11 1999 +0000
@@ -0,0 +1,75 @@
+#!/bin/sh
+# $NetBSD: checksize.sh,v 1.1 1999/03/31 02:52:11 cgd Exp $
+#
+# Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Christopher G. Demetriou
+#      for the NetBSD Project.
+# 4. The name of the author may not be used to endorse or promote products
+#    derived from this software without specific prior written permission
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# four arguments:
+#      boot object with headers, to check bss size
+#      boot file (just text+data), to check load and total sizes
+#      maximum load size
+#      maximum total (load + bss) size
+
+progname=$0
+if [ $# != 4 ] || [ ! -f $1 ] || [ ! -f $2 ]; then
+       echo "$progname bootobj bootfile maxload maxtotal" 1>&2
+       exit 1
+fi
+
+bootobj=$1
+bootfile=$2
+maxloadsize=$3
+maxtotalsize=$4
+
+if [ "$SIZE" = "" ]; then
+       SIZE=size
+fi
+
+size_data=`$SIZE $bootobj`
+if [ $? != 0 ]; then
+       echo "$progname: couldn't get size of $bootobj" 2>&1
+       exit 1
+fi
+bss_size=`echo "$size_data" | awk ' NR == 2 { print $3 } '`
+
+load_size=`ls -l $bootfile | awk ' { print $5 }'`
+
+echo -n "checking sizes for $bootfile/$bootobj... "
+
+if expr $load_size \> $maxloadsize >/dev/null 2>&1; then
+       echo "MAXIMUM LOAD SIZE EXCEEDED ($load_size > $maxloadsize)"
+       exit 1
+fi
+
+if expr $load_size + $bss_size \> $maxtotalsize >/dev/null 2>&1; then
+       echo "MAXIMUM TOTAL SIZE EXCEEDED ($load_size + $bss_size > $maxtotalsize)"
+       exit 1
+fi
+
+echo "OK"
+exit 0
diff -r 8a6b4671254a -r 2a323c38b7e3 sys/arch/alpha/stand/common/headersize.c
--- a/sys/arch/alpha/stand/common/headersize.c  Wed Mar 31 02:47:38 1999 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/* $NetBSD: headersize.c,v 1.3 1997/09/06 14:03:57 drochner Exp $ */
-
-/*
- * Copyright (c) 1995, 1996 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- * 
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- * 
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
- * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- * 
- * Carnegie Mellon requests users of this software to return to
- *
- *  Software Distribution Coordinator  or  Software.Distribution%CS.CMU.EDU@localhost
- *  School of Computer Science
- *  Carnegie Mellon University
- *  Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#define        ELFSIZE         64
-



Home | Main Index | Thread Index | Old Index