Skip to contentSkip to conversation

livepatch-build: allow different build ID length

PATCH In review Frediano Ziglio 2 participants 2 messages Jul 24, 2025 – Jul 28, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 livepatch-build: allow different build ID length

The size of the build ID for a PE file can be different from ELF one, specifically 16 bytes instead of 20. Allows to embed arbitrary build ID lengths.
The Xen ABI for retrieving the build ID allows arbitrary lengths too (for instance see "xl info").

---
 livepatch-build | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
livepatch-build +7 -2
index f3ca939..11cbeec 100755
@@ -192,6 +192,11 @@ strip_metadata_symbols ()
     strip "${STRIP_CMD_OPTS[@]}" "$FILE"
 }
 
+function gnu_section()
+{
+    perl -e '$d = pack("H*", $ARGV[0]); print pack("VVVZ*", 4, length($d), 3, "GNU").$d' "$1"
+}
+
 function create_patch()
 {
     echo "Extracting new and modified ELF sections..."
@@ -245,10 +250,10 @@ function create_patch()
     fi
 
     # Create a dependency section
-    perl -e "print pack 'VVVZ*H*', 4, 20, 3, 'GNU', '${DEPENDS}'" > depends.bin
+    gnu_section "$DEPENDS" > depends.bin
 
     # Create a Xen dependency section
-    perl -e "print pack 'VVVZ*H*', 4, 20, 3, 'GNU', '${XEN_DEPENDS}'" > xen_depends.bin
+    gnu_section "$XEN_DEPENDS" > xen_depends.bin
 
     echo "Creating patch module..."
     if [ -z "$PRELINK" ]; then
Signature · 1 line
2.50.1