Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:vlefebvre:unified
systemd
2007-boot-pe-introduce-.binrel-as-PE-metadata.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2007-boot-pe-introduce-.binrel-as-PE-metadata.patch of Package systemd
From 879d1efa58e31dabe8b9ecd538ecd6b0ac632e30 Mon Sep 17 00:00:00 2001 From: Raito Bezarius <masterancpp@gmail.com> Date: Sat, 22 Jul 2023 18:03:11 +0200 Subject: [PATCH 7/7] boot(pe): introduce `.binrel` as PE metadata Following https://github.com/systemd/systemd/pull/28057/files#r1233760527, we realized the need for EFI metadata, as EFI device paths will not always carry the filename information. Here is an attempt to materialize it as a PE section `.sdmeta` to avoid piling up many sections which will be all aligned to full pages in memory and 512 bytes on disk. This is a structured data section for any PE metadata, it starts with a `filename` field. In a future PR, stubs, addons and systemd-boot will make use of that section. --- src/boot/efi/addon-util.h | 2 ++ src/boot/efi/addon.c | 4 ++++ src/boot/efi/pe.h | 6 ++++++ src/boot/efi/stub.c | 6 +++++- src/boot/efi/stub.h | 4 ++++ 5 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/boot/efi/stub.h diff --git a/src/boot/efi/addon-util.h b/src/boot/efi/addon-util.h index f1883fdcdb..a52312e596 100644 --- a/src/boot/efi/addon-util.h +++ b/src/boot/efi/addon-util.h @@ -8,5 +8,7 @@ #define SYSTEMD_ADDON_MEDIA_GUID \ GUID_DEF(0x97ac68bf, 0xc741, 0x4bbb, 0xb7, 0xbf, 0x7f, 0x6c, 0xcc, 0x00, 0x8a, 0x7e) +#define ADDON_FILENAME "sd-addon" + EFI_STATUS addons_install_proto(EFI_LOADED_IMAGE_PROTOCOL *loaded_image, char16_t * const *addons); EFI_STATUS addons_unload_proto(EFI_HANDLE *addons); diff --git a/src/boot/efi/addon.c b/src/boot/efi/addon.c index 95b29daf55..691862aff5 100644 --- a/src/boot/efi/addon.c +++ b/src/boot/efi/addon.c @@ -5,6 +5,10 @@ /* Magic string for recognizing our own binaries */ DECLARE_NOALLOC_SECTION(".sdmagic", "#### LoaderInfo: systemd-addon " GIT_VERSION " ####"); +_used_ _section_(".binrel") static const struct pe_metadata metadata = { + .fname = ADDON_FILENAME +}; + /* This is intended to carry data, not to be executed */ diff --git a/src/boot/efi/pe.h b/src/boot/efi/pe.h index 7e2258fceb..261aa9eb7e 100644 --- a/src/boot/efi/pe.h +++ b/src/boot/efi/pe.h @@ -3,6 +3,12 @@ #include "efi.h" +/* This is used to hold PE-specific metadata + * under the section `.sdmeta` */ +struct pe_metadata { + const char *fname; +}; + EFI_STATUS pe_memory_locate_sections( const void *base, const char * const sections[], diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index 94a34e953c..53c04668a8 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "addon-util.h" +#include "stub.h" #include "cpio.h" #include "device-path-util.h" #include "devicetree.h" @@ -23,8 +25,10 @@ /* magic string to find in the binary image */ DECLARE_NOALLOC_SECTION(".sdmagic", "#### LoaderInfo: systemd-stub " GIT_VERSION " ####"); - DECLARE_SBAT(SBAT_STUB_SECTION_TEXT); +_used_ _section_(".binrel") static const struct pe_metadata metadata = { + .fname = STUB_FILENAME +}; struct addon_entry { char16_t *source_path; diff --git a/src/boot/efi/stub.h b/src/boot/efi/stub.h new file mode 100644 index 0000000000..aae6b03ec4 --- /dev/null +++ b/src/boot/efi/stub.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#define STUB_FILENAME "sd-stub" -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor