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 via email to