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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-01-24 08:14:48 +01:00
parent e9d5c37bb3
commit 41c9a3140e

9
generate-rpm-note.sh Normal file → Executable file
View File

@ -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"