Skip to content

Commit

Permalink
Add .sbat support to certmule.efi
Browse files Browse the repository at this point in the history
For details, see https://github.com/rhboot/shim/blob/main/SBAT.md

Signed-off-by: Peter Jones <[email protected]>
  • Loading branch information
vathpela committed May 25, 2022
1 parent c9554d0 commit d50e6c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ define VENDOR_DB =
--change-section-address .db=$(call DB_ADDRESS, $(1), 1),)
endef

define add-vendor-sbat
$(OBJCOPY) --add-section ".$(patsubst %.csv,%,$(1))=$(1)" $(2)

endef

SBATPATH = $(TOPDIR)/data/sbat.csv
VENDOR_SBATS := $(sort $(foreach x,$(wildcard $(TOPDIR)/data/sbat.*.csv data/sbat.*.csv),$(notdir $(x))))

OBJFLAGS =
SOLIBS =

Expand Down Expand Up @@ -78,11 +86,12 @@ endif

all : certmule.efi

certmule.so : sbat_data.o certmule.o
certmule.so : SOLIBS=
certmule.so : SOFLAGS=
certmule.so : BUILDFLAGS+=-DVENDOR_DB
certmule.efi : OBJFLAGS = --strip-unneeded $(call VENDOR_DB, $<)
certmule.efi : SECTIONS=.text .reloc .db
certmule.efi : SECTIONS=.text .reloc .db .sbat
certmule.efi : VENDOR_DB_FILE?=db.esl

%.efi : %.so
Expand All @@ -94,6 +103,14 @@ endif
$(OBJFLAGS) \
$(FORMAT) $^ $@

sbat_data.o : | $(SBATPATH) $(VENDOR_SBATS)
sbat_data.o : /dev/null
$(CC) $(BUILDFLAGS) -x c -c -o $@ $<
$(OBJCOPY) --add-section .sbat=$(SBATPATH) \
--set-section-flags .sbat=contents,alloc,load,readonly,data \
$@
$(foreach vs,$(VENDOR_SBATS),$(call add-vendor-sbat,$(vs),$@))

%.so : %.o
$(CC) $(CCLDFLAGS) $(SOFLAGS) -o $@ $^ $(SOLIBS) \
$(shell $(CC) -print-libgcc-file-name) \
Expand Down
2 changes: 2 additions & 0 deletions data/sbat.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
certmule,1,UEFI certmule,certmule,1,https://github.com/rhboot/certmule

0 comments on commit d50e6c5

Please sign in to comment.