Skip to content

Commit 3e8166c

Browse files
committed
csu: Define a "csu" compartment policy
This policy file is installed to /usr/lib alongside the relevant crt* object files. bsd.(lib|prog).mk add this policy to LDFLAGS when linking an output that already has at least one other policy file.
1 parent 6f550c5 commit 3e8166c

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

lib/csu/Makefile.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CFLAGS+= -I${.CURDIR:H}/common-cheri
3636

3737
CFLAGS_CRTS+= -DSHARED ${PICFLAG}
3838

39-
FILES= ${OBJS}
39+
FILES= ${OBJS} crt.json
4040
FILESMODE= ${LIBMODE}
4141
FILESOWN= ${LIBOWN}
4242
FILESGRP= ${LIBGRP}

lib/csu/common/crt.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compartments": {
3+
"csu": {
4+
"files": [
5+
"crt1.o",
6+
"crtbegin.o",
7+
"crtbeginS.o",
8+
"crtbeginT.o",
9+
"crtend.o",
10+
"crtendS.o",
11+
"crti.o",
12+
"crtn.o"
13+
]
14+
}
15+
}
16+
}

share/mk/bsd.lib.mk

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ LDFLAGS+= -Wl,--undefined-version
299299

300300
.if ${MK_COMPARTMENT_POLICY} != "no" && ${MACHINE_ABI:Mpurecap}
301301
.if !empty(COMPARTMENT_POLICY)
302+
COMPARTMENT_POLICY+= ${SYSROOT}/usr/lib/crt.json
302303
${SHLIB_NAME_FULL}: ${COMPARTMENT_POLICY}
303304
LDFLAGS+= ${COMPARTMENT_POLICY:S/^/-Wl,--compartment-policy=/}
304305
.endif

share/mk/bsd.prog.mk

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ PROG_FULL= ${PROG}
177177

178178
.if ${MK_COMPARTMENT_POLICY} != "no" && ${MACHINE_ABI:Mpurecap}
179179
.if !empty(COMPARTMENT_POLICY)
180+
COMPARTMENT_POLICY+= ${SYSROOT}/usr/lib/crt.json
180181
${PROG_FULL}: ${COMPARTMENT_POLICY}
181182
LDFLAGS+= ${COMPARTMENT_POLICY:S/^/-Wl,--compartment-policy=/}
182183
.endif

0 commit comments

Comments
 (0)