From 41c9a3140e8aab4beb195bf2e36b0398117a12a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 24 Jan 2022 08:14:48 +0100 Subject: [PATCH] Add --insert-after param to the note generation script I thought this would allow insertion with ld.gold, but it turns out that the resulting binary has something wrong with sections. So only the change to the script is committed, because it makes it much easier to experiment with various linkers. --- generate-rpm-note.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 generate-rpm-note.sh diff --git a/generate-rpm-note.sh b/generate-rpm-note.sh old mode 100644 new mode 100755 index b80b6ca..08e9a25 --- a/generate-rpm-note.sh +++ b/generate-rpm-note.sh @@ -1,6 +1,7 @@ #!/bin/bash readonly=1 +insert_after=1 pad_string() { for _ in $(seq "$1"); do @@ -44,7 +45,8 @@ write_script() { write_string "$1" ' ' 'Value' "$value_len" printf ' }\n}\n' - printf 'INSERT AFTER .note.gnu.build-id;\n' + [ -n "$insert_after" ] && printf 'INSERT AFTER .note.gnu.build-id;\n' + : } if [ "$1" == "--readonly=no" ]; then @@ -52,6 +54,11 @@ if [ "$1" == "--readonly=no" ]; then readonly= fi +if [ "$1" == "--insert-after=no" ]; then + shift + insert_after= +fi + cpe="$(cat /usr/lib/system-release-cpe)" json="$(printf '{"type":"rpm","name":"%s","version":"%s","architecture":"%s","osCpe":"%s"}' "$1" "$2" "$3" "$cpe")" write_script "$json"