From 58ec8a67f528171c843e700d547b337728cba808 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 26 Mar 2022 17:47:31 +0000 Subject: [PATCH] Fix wrong binary fields on big endian Sync with https://github.com/systemd/package-notes/pull/31 On big endian machines we need to swap the first three fields, which are binary and thus need to match endianess. Just use LONG() instead of BYTE sequences. --- generate-rpm-note.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/generate-rpm-note.sh b/generate-rpm-note.sh index 08e9a25..edf5cb1 100755 --- a/generate-rpm-note.sh +++ b/generate-rpm-note.sh @@ -35,11 +35,13 @@ write_script() { printf 'SECTIONS\n{\n' printf ' .note.package %s: ALIGN(4) {\n' "$readonly_attr" - printf ' BYTE(0x04) BYTE(0x00) BYTE(0x00) BYTE(0x00) /* Length of Owner including NUL */\n' - printf ' BYTE(0x%02x) BYTE(0x%02x) BYTE(0x00) BYTE(0x00) /* Length of Value including NUL */\n' \ - $((value_len % 256)) $((value_len / 256)) + # Note that for the binary fields we use the native 4 bytes type, to avoid + # endianness issues. + printf ' LONG(0x0004) /* Length of Owner including NUL */\n' + printf ' LONG(0x%04x) /* Length of Value including NUL */\n' \ + ${value_len} + printf ' LONG(0xcafe1a7e) /* Note ID */\n' - printf ' BYTE(0x7e) BYTE(0x1a) BYTE(0xfe) BYTE(0xca) /* Note ID */\n' printf " BYTE(0x46) BYTE(0x44) BYTE(0x4f) BYTE(0x00) /* Owner: 'FDO' */\n" write_string "$1" ' ' 'Value' "$value_len"