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").

Signed-off-by: Frediano Ziglio <frediano.zig...@cloud.com>
---
 livepatch-build | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/livepatch-build b/livepatch-build
index f3ca939..11cbeec 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -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
-- 
2.50.1


Reply via email to