1 # $NetBSD: Makefile.bootprogs,v 1.6 2022/05/28 22:16:43 andvar Exp $ 2 3 NOSSP=yes 4 NOPIE=yes 5 6 .include <bsd.own.mk> 7 .include <bsd.klinks.mk> 8 9 S= ${.CURDIR}/../../../../.. 10 COMMON= ${.CURDIR}/../common 11 12 .PATH: ${COMMON} 13 14 .if ${MACHINE_ARCH:M*64*} 15 . if ${MACHINE_ARCH:M*eb} 16 LDABI= -melf32btsmipn32 17 . else 18 LDABI= -melf32ltsmipn32 19 . endif 20 CPUFLAGS+= -mabi=n32 21 .endif 22 23 STRIPFLAG= 24 BINMODE= 444 25 26 # XXX SHOULD NOT NEED TO DEFINE THESE! 27 LIBCRT0= 28 LIBCRTI= 29 LIBC= 30 LIBCRTBEGIN= 31 LIBCRTEND= 32 33 STRIP?= strip 34 35 CHECKSIZE_CMD= SIZE=${SIZE} ${HOST_SH} ${COMMON}/checksize.sh 36 37 AFLAGS+= -DASSEMBLER -D_LOCORE -mno-abicalls -mips64 -msoft-float 38 # -I${.CURDIR}/../.. done by Makefile.inc 39 CPPFLAGS+= -nostdinc -I${.OBJDIR} -D_STANDALONE -I${S} 40 CFLAGS= -Os -g -ffreestanding -mno-abicalls -msoft-float -G 0 41 CFLAGS+= -mips64 42 CFLAGS+= -Werror ${CWARNFLAGS} 43 44 NETBSD_VERS!=${HOST_SH} ${S}/conf/osrelease.sh 45 CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"' 46 47 CWARNFLAGS+= -Wno-main 48 CWARNFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith 49 CWARNFLAGS+= -Wno-pointer-sign 50 51 VERSIONFLAGS+=-n 52 .include "${S}/conf/newvers_stand.mk" 53 54 # 55 # Refer to CFE documentation for a description of these regions. 56 # 57 58 REGION1_START= 0x20000000 # "Region 1 start" 59 REGION1_SIZE!= expr 256 \* 1024 # 256k 60 61 LDSCRIPT= ${COMMON}/boot.ldscript 62 63 # our memory lauout: 64 65 # 'unified' boot loaders (e.g. netboot) can consume all of region 66 # 1 for their text+data, or text+data+bss. 67 68 UNIFIED_LOAD_ADDRESS= ${REGION1_START} 69 UNIFIED_MAX_LOAD!= expr ${REGION1_SIZE} 70 UNIFIED_MAX_TOTAL!= expr ${REGION1_SIZE} 71 72 #UNIFIED_HEAP_START= right after secondary bss 73 UNIFIED_HEAP_LIMIT= (${REGION1_START} + ${REGION1_SIZE}) 74 75 # two-stage boot loaders must share region 1. The first stage 76 # loads into the lowest portion, and uses the highest portion 77 # for its heap. The second stage loads in between the primary image 78 # and the heap, and can reuse the memory after it (i.e. the primary's 79 # heap) for its own heap. 80 81 PRIMARY_LOAD_ADDRESS= ${REGION1_START} 82 #PRIMARY_MAX_LOAD= booter dependent, no more than ${PRIMARY_MAX_TOTAL} 83 PRIMARY_MAX_TOTAL!= expr 16 \* 1024 84 85 # XXX SECONDARY_LOAD_ADDRESS should be 86 # XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy 87 # XXX way to do that calculation and 'ld' wants a single number. 88 SECONDARY_LOAD_ADDRESS= 0x20004000 # XXX 89 SECONDARY_MAX_LOAD!= expr 112 \* 1024 90 SECONDARY_MAX_TOTAL!= expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL} 91 92 PRIMARY_HEAP_START= (${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD}) 93 PRIMARY_HEAP_LIMIT= (${REGION1_START} + ${REGION1_SIZE}) 94 95 #SECONDARY_HEAP_START= right after secondary bss 96 SECONDARY_HEAP_LIMIT= (${REGION1_START} + ${REGION1_SIZE}) 97 98 # standalone programs are like kernels. They load at 99 # 0xfffffc0000300000 and can use the rest of memory. 100 101 STANDPROG_LOAD_ADDRESS= 0xfffffc0000300000 102 103 104 FILE_FORMAT_CPPFLAGS= -DBOOT_ELF 105 106 UNIFIED_CPPFLAGS= -DUNIFIED_BOOTBLOCK \ 107 -DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \ 108 ${FILE_FORMAT_CPPFLAGS} 109 110 PRIMARY_CPPFLAGS= -DPRIMARY_BOOTBLOCK \ 111 -DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \ 112 -DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \ 113 -DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \ 114 -DHEAP_START="${PRIMARY_HEAP_START}" 115 116 SECONDARY_CPPFLAGS= -DSECONDARY_BOOTBLOCK \ 117 -DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \ 118 ${FILE_FORMAT_CPPFLAGS} 119 120 STANDPROG_CPPFLAGS= -DSTANDALONE_PROGRAM 121 122 .include <bsd.prog.mk> 123 124 ### find out what to use for libkern 125 KERN_AS= library 126 .include "${S}/lib/libkern/Makefile.inc" 127 LIBKERN= ${KERNLIB} 128 129 ### find out what to use for libz 130 Z_AS= library 131 .include "${S}/lib/libz/Makefile.inc" 132 LIBZ= ${ZLIB} 133 134 ### find out what to use for libsa 135 SA_AS= library 136 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 137 .include "${S}/lib/libsa/Makefile.inc" 138 LIBSA= ${SALIB} 139 140 /usr/lib/crt0.o: 141 true 142 143 /usr/lib/crtbegin.o: 144 true 145 146 /usr/lib/crtend.o: 147 true 148 149 cleandir: .WAIT cleandirlocal 150 cleandirlocal: 151 -rm -rf lib 152