Skip to content

Commit 4a0180f

Browse files
nixos/xen: dehardcode the .pad section from the UKI builder
Upstream, intentionally or not, no longer appends the EFI image with a .pad section for us to hook the rest of the UKI to. This simply dehardcodes .pad from the awk script, instead using the very last section in the binary. (Currently .reloc) Co-authored-by: Yaroslav Bolyukin <[email protected]> Signed-off-by: Fernando Rodrigues <[email protected]>
1 parent e3c735c commit 4a0180f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nixos/modules/virtualisation/xen-boot-builder.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# This script is called by ./xen-dom0.nix to create the Xen boot entries.
22
# shellcheck shell=bash
33

4+
export LC_ALL=C
5+
46
# Handle input argument and exit if the flag is invalid. See virtualisation.xen.efi.bootBuilderVerbosity below.
57
[[ $# -ne 1 ]] && echo -e "\e[1;31merror:\e[0m xenBootBuilder must be called with exactly one verbosity argument. See the \e[1;34mvirtualisation.xen.efi.bootBuilderVerbosity\e[0m option." && exit 1
68
case "$1" in
@@ -89,7 +91,8 @@ EOF
8991
# https://xenbits.xenproject.org/docs/unstable/misc/efi.html.
9092
[ "$1" = "debug" ] && echo -e "\e[1;34mxenBootBuilder:\e[0m making Xen UKI..."
9193
xenEfi=$(jq -re '."org.xenproject.bootspec.v1".xen' "$bootspecFile")
92-
padding=$(objdump --header --section=".pad" "$xenEfi" | awk '/\.pad/ { printf("0x%016x\n", strtonum("0x"$3) + strtonum("0x"$4))};')
94+
finalSection=$(objdump --header --wide "$xenEfi" | tail -n +6 | sort --key="4,4" | tail -n 1 | grep -Eo '\.[a-z]*')
95+
padding=$(objdump --header --section="$finalSection" "$xenEfi" | awk -v section="$finalSection" '$0 ~ section { printf("0x%016x\n", and(strtonum("0x"$3) + strtonum("0x"$4) + 0xfff, compl(0xfff)))};')
9396
[ "$1" = "debug" ] && echo " - padding: $padding"
9497
objcopy \
9598
--add-section .config="$tmpCfg" \

0 commit comments

Comments
 (0)