From 6904f9b37bcea0c2ae299155843f173848408097 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 14 Sep 2022 12:25:33 +0200 Subject: [PATCH] Use a temporary directory in wrap-find-debuginfo.sh This avoids the need for separate variables for all files. Rawhide commit: 6c1768439264ddc8b2900cba1a71e0f06bbd2cd9 --- wrap-find-debuginfo.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wrap-find-debuginfo.sh b/wrap-find-debuginfo.sh index 3157d69..6b9a835 100644 --- a/wrap-find-debuginfo.sh +++ b/wrap-find-debuginfo.sh @@ -15,9 +15,10 @@ set -ex -ldso_tmp="$(mktemp)" -libc_tmp="$(mktemp)" -libc_dlink_tmp="$(mktemp)" +workdir="$(mktemp -d -t find_debuginfo.XXXXXX)" + +ldso_tmp="$workdir/ld.so" +libc_tmp="$workdir/libc.so" # Prefer a separately installed debugedit over the RPM-integrated one. if command -v debugedit >/dev/null ; then @@ -27,7 +28,7 @@ else fi cleanup () { - rm -f "$ldso_tmp" "$libc_tmp" "$libc_dlink_tmp" + rm -rf "$workdir" } trap cleanup 0 @@ -69,7 +70,7 @@ cp "$libc_path" "$libc_tmp" # libc.so.6: Extract the .gnu_debuglink section objcopy -j.gnu_debuglink --set-section-flags .gnu_debuglink=alloc \ - -O binary "$libc_path" "$libc_dlink_tmp" + -O binary "$libc_path" "$libc_tmp.debuglink" # Restore the original files. cp "$ldso_tmp" "$ldso_path" @@ -80,7 +81,7 @@ objcopy --merge-notes "$ldso_path" objcopy --merge-notes "$libc_path" # libc.so.6: Restore the .gnu_debuglink section -objcopy --add-section .gnu_debuglink="$libc_dlink_tmp" "$libc_path" +objcopy --add-section .gnu_debuglink="$libc_tmp.debuglink" "$libc_path" # ld.so does not have separated debuginfo and so the debuginfo file # generated by find-debuginfo is redundant. Therefore, remove it.