commit:     f3872a506edc7da0d987bcf0a90d4709945328a7
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 17 23:19:20 2019 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Thu Oct 17 23:22:21 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f3872a50

sys-libs/glibc: restore strip quirk for 'libpthread.so.0'

This change effectively reverts commit e14229b10b513a
("sys-libs/glibc: drop prepallstrip, bug #587296")

gdb still relies on libpthread being unstripped.
See https://bugs.gentoo.org/697910 for details and reproducer.

Also see ebuild note that explains indirect mechanics
of how glibc relies on gdb's ability to traverse local symbols.

In EAPI=7 ebuilds (glibc-9999) we do selective stripping.

Reported-by: Minux
Closes: https://bugs.gentoo.org/697910
Bug: https://bugs.gentoo.org/587296
Bug: https://bugs.gentoo.org/46186
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
Package-Manager: Portage-2.3.76, Repoman-2.3.17
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 sys-libs/glibc/glibc-2.19-r2.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.24-r4.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.25-r11.ebuild | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.26-r7.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.27-r6.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.28-r6.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.29-r2.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.29-r4.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.29-r5.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.30-r1.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.30.ebuild     | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-9999.ebuild     | 31 ++++++++++++++++++++++++++++---
 12 files changed, 270 insertions(+), 36 deletions(-)

diff --git a/sys-libs/glibc/glibc-2.19-r2.ebuild 
b/sys-libs/glibc/glibc-2.19-r2.ebuild
index 20b236f9037..de97f115887 100644
--- a/sys-libs/glibc/glibc-2.19-r2.ebuild
+++ b/sys-libs/glibc/glibc-2.19-r2.ebuild
@@ -56,12 +56,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS.
 COMMON_DEPEND="

diff --git a/sys-libs/glibc/glibc-2.24-r4.ebuild 
b/sys-libs/glibc/glibc-2.24-r4.ebuild
index 4c862498855..6e4b70cd46d 100644
--- a/sys-libs/glibc/glibc-2.24-r4.ebuild
+++ b/sys-libs/glibc/glibc-2.24-r4.ebuild
@@ -49,12 +49,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 is_crosscompile() {
        [[ ${CHOST} != ${CTARGET} ]]
 }

diff --git a/sys-libs/glibc/glibc-2.25-r11.ebuild 
b/sys-libs/glibc/glibc-2.25-r11.ebuild
index 4b3ac83a890..0f544aa3101 100644
--- a/sys-libs/glibc/glibc-2.25-r11.ebuild
+++ b/sys-libs/glibc/glibc-2.25-r11.ebuild
@@ -51,12 +51,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 is_crosscompile() {
        [[ ${CHOST} != ${CTARGET} ]]
 }

diff --git a/sys-libs/glibc/glibc-2.26-r7.ebuild 
b/sys-libs/glibc/glibc-2.26-r7.ebuild
index 80530db6e45..ebe70b6e3ea 100644
--- a/sys-libs/glibc/glibc-2.26-r7.ebuild
+++ b/sys-libs/glibc/glibc-2.26-r7.ebuild
@@ -55,12 +55,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 is_crosscompile() {
        [[ ${CHOST} != ${CTARGET} ]]
 }

diff --git a/sys-libs/glibc/glibc-2.27-r6.ebuild 
b/sys-libs/glibc/glibc-2.27-r6.ebuild
index 2b333181bf7..8815d7bc623 100644
--- a/sys-libs/glibc/glibc-2.27-r6.ebuild
+++ b/sys-libs/glibc/glibc-2.27-r6.ebuild
@@ -55,12 +55,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS.
 COMMON_DEPEND="

diff --git a/sys-libs/glibc/glibc-2.28-r6.ebuild 
b/sys-libs/glibc/glibc-2.28-r6.ebuild
index 2a512a62aec..7412d5dfc5c 100644
--- a/sys-libs/glibc/glibc-2.28-r6.ebuild
+++ b/sys-libs/glibc/glibc-2.28-r6.ebuild
@@ -55,12 +55,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS,
 # and that gcc already contains the hardened patches.

diff --git a/sys-libs/glibc/glibc-2.29-r2.ebuild 
b/sys-libs/glibc/glibc-2.29-r2.ebuild
index bd08c9a208a..a09890ee70a 100644
--- a/sys-libs/glibc/glibc-2.29-r2.ebuild
+++ b/sys-libs/glibc/glibc-2.29-r2.ebuild
@@ -57,12 +57,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS,
 # and that gcc already contains the hardened patches.

diff --git a/sys-libs/glibc/glibc-2.29-r4.ebuild 
b/sys-libs/glibc/glibc-2.29-r4.ebuild
index 0f388a106c6..f25792a193d 100644
--- a/sys-libs/glibc/glibc-2.29-r4.ebuild
+++ b/sys-libs/glibc/glibc-2.29-r4.ebuild
@@ -57,12 +57,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS,
 # and that gcc already contains the hardened patches.

diff --git a/sys-libs/glibc/glibc-2.29-r5.ebuild 
b/sys-libs/glibc/glibc-2.29-r5.ebuild
index 6ac0497d07c..5ef228c3688 100644
--- a/sys-libs/glibc/glibc-2.29-r5.ebuild
+++ b/sys-libs/glibc/glibc-2.29-r5.ebuild
@@ -57,12 +57,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS,
 # and that gcc already contains the hardened patches.

diff --git a/sys-libs/glibc/glibc-2.30-r1.ebuild 
b/sys-libs/glibc/glibc-2.30-r1.ebuild
index 51bf1cbd9f3..958a2c87cde 100644
--- a/sys-libs/glibc/glibc-2.30-r1.ebuild
+++ b/sys-libs/glibc/glibc-2.30-r1.ebuild
@@ -58,12 +58,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS,
 # and that gcc already contains the hardened patches.

diff --git a/sys-libs/glibc/glibc-2.30.ebuild b/sys-libs/glibc/glibc-2.30.ebuild
index 544eec7b687..452fcda36fd 100644
--- a/sys-libs/glibc/glibc-2.30.ebuild
+++ b/sys-libs/glibc/glibc-2.30.ebuild
@@ -58,12 +58,31 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we disable stripping
+# entirely.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS,
 # and that gcc already contains the hardened patches.

diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index 6894e04b796..d1ad8e513fb 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -58,12 +58,30 @@ export CTARGET=${CTARGET:-${CHOST}}
 if [[ ${CTARGET} == ${CHOST} ]] ; then
        if [[ ${CATEGORY} == cross-* ]] ; then
                export CTARGET=${CATEGORY#cross-}
-               # portage's attempt to strip breaks non-native bianries
-               # at least on arm: bug #697428
-               RESTRICT=strip
        fi
 fi
 
+# Note [Disable automatic stripping]
+# Disabling automatic stripping for a few reasons:
+# - portage's attempt to strip breaks non-native binaries at least on
+#   arm: bug #697428
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread
+#   enumeration: bug #697910. This is quite subtle:
+#   * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
+#   * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
+#     via 'ps_pglobal_lookup' symbol defined in gdb.
+#   * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
+#     known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
+#     (unexported) is used to sanity check compatibility before enabling
+#     debugging.
+#     Also see 
https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
+#   * normal 'strip' command trims '.symtab'
+#   Thus our main goal here is to prevent 'libpthread.so.0' from
+#   losing it's '.symtab' entries.
+# As Gentoo's strip does not allow us to pass less aggressive stripping
+# options and does not check the machine target we strip selectively.
+RESTRICT=strip
+
 # We need a new-enough binutils/gcc to match upstream baseline.
 # Also we need to make sure our binutils/gcc supports TLS,
 # and that gcc already contains the hardened patches.
@@ -1184,6 +1202,13 @@ glibc_do_src_install() {
        # '#define VERSION "2.26.90"' -> '2.26.90'
        local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' 
"${S}"/version.h)
 
+       # Avoid stripping binaries not targeted by ${CHOST}. Or else
+       # ${CHOST}-strip would break binaries build for ${CTARGET}.
+       is_crosscompile || dostrip /
+       # gdb thread introspection relies on local libpthreas symbols. 
stripping breaks it
+       # See Note [Disable automatic stripping]
+       dostrip -x $(alt_libdir)/libpthread-${upstream_pv}.so
+
        if [[ -e ${ED}/$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
                # Move versioned .a file out of libdir to evade portage QA 
checks
                # instead of using gen_usr_ldscript(). We fix ldscript as:

Reply via email to