commit:     b724e677e39eaa790380a2a13ab264a9b23e2572
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu May  8 10:35:09 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun  3 21:02:14 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b724e677

estrip: salt build IDs even with FEATURES=-installsources

We've historically only needed debugedit for FEATURES=installsources
but if we're going to enable build IDs, we need to salt them in general
for splitdebug.

This is done in a followup commit to the original salting as the
implementation could be cleaner and I think it's easier to rework then
if required.

Bug: https://bugs.gentoo.org/549672
Bug: https://bugs.gentoo.org/953869
Signed-off-by: Sam James <sam <AT> gentoo.org>
Part-of: https://github.com/gentoo/portage/pull/1436
Closes: https://github.com/gentoo/portage/pull/1436
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/estrip | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/bin/estrip b/bin/estrip
index e587c08994..b8647e5a25 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -338,9 +338,26 @@ save_elf_debug() {
                        # Symlink so we can read the name back.
                        __try_symlink "${dst}" "${inode_debug}"
 
-                       # If we don't already have build-id from debugedit, 
look it up
+                       # If we don't already have build-id from debugedit, 
look it up.
+                       # This should only happen with 
FEATURES=-installsources, as
+                       # it's done in save_elf_sources.
                        if [[ -z ${buildid} ]] ; then
-                               # convert the readelf output to something useful
+                               if [[ ${path_of[debugedit]} ]]; then
+                                       # Salt the build ID to avoid collisions 
on
+                                       # bundled libraries.
+                                       buildid=$("${path_of[debugedit]}" -i \
+                                               -s "${CATEGORY}/${PF}:${SLOT}" \
+                                               "${x}")
+                               elif ! contains_word buildid 
"${warned_for[debugedit]}"; then
+                                       warned_for[debugedit]+=" buildid"
+                                       ewarn "FEATURES=splitdebug is enabled 
but the debugedit binary could not be found"
+                                       ewarn "This feature will not work 
correctly with build IDs unless debugedit is installed!"
+                               fi
+                       fi
+
+                       # If we (still) don't already have build-id from 
debugedit, look it up.
+                       if [[ -z ${buildid} ]] ; then
+                               # Convert the readelf output to something useful
                                buildid=$("${path_of[readelf]}" -n "${src}" 
2>/dev/null | awk '/Build ID:/{ print $NF; exit }')
                        fi
 

Reply via email to