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