:: commit 60e1b43f6665e5cf3890c0b964bfdfffc87699b9

mintsuki <mintsuki@protonmail.com> — 2021-06-24 23:23

parents: ece3e9c099

secureboot: Add .sbat section

diff --git a/stage23/Makefile b/stage23/Makefile
index 6d7aac9a..a96b9718 100644
--- a/stage23/Makefile
+++ b/stage23/Makefile
@@ -195,7 +195,7 @@ $(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf
 	"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 64
 
 $(BUILDDIR)/BOOTX64.EFI: $(BUILDDIR)/limine_efi.elf
-	$(TOOLCHAIN_OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc --target efi-app-x86_64 --subsystem=10 $< $@
+	$(TOOLCHAIN_OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc -j .sbat --target efi-app-x86_64 --subsystem=10 $< $@
 
 $(BUILDDIR)/limine_efi_nomap.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
 	$(TOOLCHAIN_LD) \
diff --git a/stage23/linker_uefi.ld b/stage23/linker_uefi.ld
index 7a607ce2..4e2d0036 100644
--- a/stage23/linker_uefi.ld
+++ b/stage23/linker_uefi.ld
@@ -54,6 +54,17 @@ SECTIONS
 
   _edata = .;
   _data_size = . - _etext;
+
+  . = ALIGN(4096);
+  .sbat :
+  {
+    _sbat = .;
+    *(.sbat)
+    *(.sbat.*)
+  }
+  _esbat = .;
+  _sbat_size = . - _sbat;
+
   . = ALIGN(4096);
   .dynamic  : { *(.dynamic) }
   . = ALIGN(4096);
diff --git a/stage23/linker_uefi_nomap.ld b/stage23/linker_uefi_nomap.ld
index c340c5ac..3e67b4aa 100644
--- a/stage23/linker_uefi_nomap.ld
+++ b/stage23/linker_uefi_nomap.ld
@@ -54,6 +54,17 @@ SECTIONS
 
   _edata = .;
   _data_size = . - _etext;
+
+  . = ALIGN(4096);
+  .sbat :
+  {
+    _sbat = .;
+    *(.sbat)
+    *(.sbat.*)
+  }
+  _esbat = .;
+  _sbat_size = . - _sbat;
+
   . = ALIGN(4096);
   .dynamic  : { *(.dynamic) }
   . = ALIGN(4096);
diff --git a/stage23/sbat.c b/stage23/sbat.c
new file mode 100644
index 00000000..fa3dca13
--- /dev/null
+++ b/stage23/sbat.c
@@ -0,0 +1,9 @@
+#if defined (uefi)
+
+asm (
+    ".section .sbat\n\t"
+    ".ascii \"sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md\\n\"\n\t"
+    ".ascii \"limine,1,Limine,limine," LIMINE_VERSION ",https://limine-bootloader.org\\n\"\n\t"
+);
+
+#endif
tab: 248 wrap: offon