public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH cygport 1/2] postinst: Never remove an existing .gnu_debuglink
Date: Tue,  1 Feb 2022 17:25:18 +0000	[thread overview]
Message-ID: <20220201172519.14881-2-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20220201172519.14881-1-jon.turney@dronecode.org.uk>

Be more careful not to remove an existing .gnu_debuglink, even if we
think this package has no useful debug symbols.

(Some versions of 'llvm-objdump -l' fail to find line number info even
though it's there.  Don't break a package which manages it's own debug
symbols (e.g. cygwin) when that happens.)
---
 lib/src_postinst.cygpart | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/lib/src_postinst.cygpart b/lib/src_postinst.cygpart
index d8bb226..e29b2cb 100644
--- a/lib/src_postinst.cygpart
+++ b/lib/src_postinst.cygpart
@@ -1051,23 +1051,31 @@ __prepstrip() {
 
 			lines=$(${objdump} -d -l "${exe}" 2>/dev/null | sed -ne "s|.*\(/usr/src/debug/${PF}/.*\):[0-9]*$|\1|gp" | sort -u | tee -a ${T}/.dbgsrc.out | wc -l);
 
-			if (( lines == 0 ))
+			# we expect --add-gnu-debuglink to fail if a
+			# .gnu_debuglink section already exists (e.g. binutils,
+			# which uses hardlinks, or cygwin which creates a custom
+			# .dbg file), but leave it alone to make sure we don't
+			# mess it up.
+			if ${objdump} -h "${exe}" | grep -q '\.gnu_deb'
 			then
-				${objcopy} --strip-all "${exe}";
 				continue;
 			fi
 
-			# --add-gnu-debuglink will fail if .gnu_debuglink section
-			# already exists, e.g. binutils, which uses hardlinks,
-			# or cygwin which creates a custom .dbg file
-			if ! ${objdump} -h "${exe}" | grep -q '\.gnu_deb'
+			# only create split debuginfo if it's going to contain
+			# some symbols for which this package has the
+			# corresponding source files
+			if (( lines == 0 ))
 			then
-				dodir "${dbg%/*}";
-				${objcopy} --long-section-names enable --add-gnu-debuglink=/dev/null --only-keep-debug "${exe}" "${D}${dbg}";
-				chmod 0644 "${D}${dbg}";
 				${objcopy} --strip-all "${exe}";
-				${objcopy} --long-section-names enable --add-gnu-debuglink="${D}${dbg}" "${exe}" 2>/dev/null;
+				continue;
 			fi
+
+			dodir "${dbg%/*}";
+			${objcopy} --long-section-names enable --add-gnu-debuglink=/dev/null --only-keep-debug "${exe}" "${D}${dbg}";
+			chmod 0644 "${D}${dbg}";
+			${objcopy} --strip-all "${exe}";
+			${objcopy} --long-section-names enable --add-gnu-debuglink="${D}${dbg}" "${exe}" 2>/dev/null;
+
 		fi
 	done
 }
-- 
2.34.1


  reply	other threads:[~2022-02-01 17:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 17:25 [PATCH cygport 0/2] Avoid misbehaviour with llvm-objdump Jon Turney
2022-02-01 17:25 ` Jon Turney [this message]
2022-02-01 19:22   ` [PATCH cygport 1/2] postinst: Never remove an existing .gnu_debuglink Corinna Vinschen
     [not found]     ` <eef4ada5-0ace-d828-c163-988390aa35e0@dronecode.org.uk>
2022-02-02  9:31       ` Corinna Vinschen
2022-02-01 17:25 ` [PATCH cygport 2/2] Don't use llvm-objdump Jon Turney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220201172519.14881-2-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).