Skip to content

Commit d50e6c5

Browse files
committed
Add .sbat support to certmule.efi
For details, see https://github.com/rhboot/shim/blob/main/SBAT.md Signed-off-by: Peter Jones <pjones@redhat.com>
1 parent c9554d0 commit d50e6c5

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ define VENDOR_DB =
4949
--change-section-address .db=$(call DB_ADDRESS, $(1), 1),)
5050
endef
5151

52+
define add-vendor-sbat
53+
$(OBJCOPY) --add-section ".$(patsubst %.csv,%,$(1))=$(1)" $(2)
54+
55+
endef
56+
57+
SBATPATH = $(TOPDIR)/data/sbat.csv
58+
VENDOR_SBATS := $(sort $(foreach x,$(wildcard $(TOPDIR)/data/sbat.*.csv data/sbat.*.csv),$(notdir $(x))))
59+
5260
OBJFLAGS =
5361
SOLIBS =
5462

@@ -78,11 +86,12 @@ endif
7886

7987
all : certmule.efi
8088

89+
certmule.so : sbat_data.o certmule.o
8190
certmule.so : SOLIBS=
8291
certmule.so : SOFLAGS=
8392
certmule.so : BUILDFLAGS+=-DVENDOR_DB
8493
certmule.efi : OBJFLAGS = --strip-unneeded $(call VENDOR_DB, $<)
85-
certmule.efi : SECTIONS=.text .reloc .db
94+
certmule.efi : SECTIONS=.text .reloc .db .sbat
8695
certmule.efi : VENDOR_DB_FILE?=db.esl
8796

8897
%.efi : %.so
@@ -94,6 +103,14 @@ endif
94103
$(OBJFLAGS) \
95104
$(FORMAT) $^ $@
96105

106+
sbat_data.o : | $(SBATPATH) $(VENDOR_SBATS)
107+
sbat_data.o : /dev/null
108+
$(CC) $(BUILDFLAGS) -x c -c -o $@ $<
109+
$(OBJCOPY) --add-section .sbat=$(SBATPATH) \
110+
--set-section-flags .sbat=contents,alloc,load,readonly,data \
111+
$@
112+
$(foreach vs,$(VENDOR_SBATS),$(call add-vendor-sbat,$(vs),$@))
113+
97114
%.so : %.o
98115
$(CC) $(CCLDFLAGS) $(SOFLAGS) -o $@ $^ $(SOLIBS) \
99116
$(shell $(CC) -print-libgcc-file-name) \

data/sbat.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
2+
certmule,1,UEFI certmule,certmule,1,https://github.com/rhboot/certmule

0 commit comments

Comments
 (0)