Preserve .symtab in libc.so.6 and the main shared objects (#1975859)

(cherry picked from commit b5165edc42d665c7770bea0e4378a526b0b24793)
This commit is contained in:
Florian Weimer 2021-07-13 13:18:37 +02:00
parent 2fb6ee14f2
commit e7c0b54e48
2 changed files with 66 additions and 61 deletions

View File

@ -90,7 +90,7 @@
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 9%{?dist}
Release: 10%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -1854,6 +1854,9 @@ fi
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
%changelog
* Tue Jul 13 2021 Florian Weimer <fweimer@redhat.com> - 2.32-10
- Preserve .symtab in libc.so.6 and the main shared objects (#1975859)
* Wed Jul 07 2021 Patsy Griffin <patsy@redhat.com> - 2.32-9
- Auto-sync with upstream branch release/2.32/master,
commit 27e892f6608e9d0da71884bb1422a735f6062850.

View File

@ -10,13 +10,17 @@
# As a result, ld.so has (mostly) unchanged debuginfo even
# after debuginfo extraction.
#
# For libc.so.6, a set of strategic symbols is preserved in .symtab
# that are frequently used in valgrind suppressions.
# For libc.so.6 and other shared objects, a set of strategic symbols
# is preserved in .symtab that are frequently used in valgrind
# suppressions and elsewhere.
set -ex
ldso_tmp="$(mktemp)"
libc_tmp="$(mktemp)"
libdl_tmp="$(mktemp)"
libpthread_tmp="$(mktemp)"
librt_tmp="$(mktemp)"
# Prefer a separately installed debugedit over the RPM-integrated one.
if command -v debugedit >/dev/null ; then
@ -26,7 +30,7 @@ else
fi
cleanup () {
rm -f "$ldso_tmp" "$libc_tmp"
rm -f "$ldso_tmp" "$libc_tmp" "$libdl_tmp" "$libpthread_tmp" "$librt_tmp"
}
trap cleanup 0
@ -56,10 +60,42 @@ for libc_candidate in `find "$sysroot_path" -name 'libc-*.so' -type f` ; do
fi
done
libdl_path=
for libdl_candidate in `find "$sysroot_path" -name 'libdl-*.so' -type f` ; do
if test -z "$libdl_path" ; then
libdl_path="$libdl_candidate"
else
echo "error: multiple libdl.so.6 candidates: $libdl_path, $libdl_candidate"
exit 1
fi
done
libpthread_path=
for libpthread_candidate in `find "$sysroot_path" -name 'libpthread-*.so' -type f` ; do
if test -z "$libpthread_path" ; then
libpthread_path="$libpthread_candidate"
else
echo "error: multiple libpthread.so.6 candidates: $libpthread_path, $libpthread_candidate"
exit 1
fi
done
librt_path=
for librt_candidate in `find "$sysroot_path" -name 'librt-*.so' -type f` ; do
if test -z "$librt_path" ; then
librt_path="$librt_candidate"
else
echo "error: multiple librt.so.6 candidates: $librt_path, $librt_candidate"
exit 1
fi
done
# Preserve the original files.
cp "$ldso_path" "$ldso_tmp"
cp "$libc_path" "$libc_tmp"
cp "$libdl_path" "$libdl_tmp"
cp "$libpthread_path" "$libpthread_tmp"
cp "$librt_path" "$librt_tmp"
# Run the debuginfo extraction.
"$script_path" "$@"
@ -67,68 +103,34 @@ cp "$libc_path" "$libc_tmp"
# Restore the original files.
cp "$ldso_tmp" "$ldso_path"
cp "$libc_tmp" "$libc_path"
cp "$libdl_tmp" "$libdl_path"
cp "$libpthread_tmp" "$libpthread_path"
cp "$librt_tmp" "$librt_path"
# Reduce the size of notes. Primarily for annobin.
objcopy --merge-notes "$ldso_path"
objcopy --merge-notes "$libc_path"
objcopy --merge-notes "$libdl_path"
objcopy --merge-notes "$libpthread_path"
objcopy --merge-notes "$librt_path"
# libc.so.6: Reduce to strategic symbols needed by valgrind.
# pthread_create is needed to trigger loading of libthread_db in GDB.
# (Debuginfo is gone after this, so no need to optimize it.)
strip \
-K __GI___rawmemchr \
-K __GI___strcasecmp_l \
-K __GI___strncasecmp_l \
-K __GI_memchr \
-K __GI_memcmp \
-K __GI_memcpy \
-K __GI_memmove \
-K __GI_mempcpy \
-K __GI_stpcpy \
-K __GI_strcasecmp \
-K __GI_strcasecmp_l \
-K __GI_strcat \
-K __GI_strchr \
-K __GI_strcmp \
-K __GI_strcpy \
-K __GI_strcspn \
-K __GI_strlen \
-K __GI_strncasecmp \
-K __GI_strncasecmp_l \
-K __GI_strncmp \
-K __GI_strncpy \
-K __GI_strnlen \
-K __GI_strrchr \
-K __GI_wcsnlen \
-K __GI_wmemchr \
-K __memcmp_sse2 \
-K __memcmp_sse4_1 \
-K __memcpy_avx_unaligned_erms \
-K __memcpy_chk \
-K __memcpy_sse2 \
-K __memmove_chk \
-K __stpcpy_chk \
-K __stpcpy_sse2 \
-K __stpcpy_sse2_unaligned \
-K __strchr_sse2 \
-K __strchr_sse2_no_bsf \
-K __strcmp_sse2 \
-K __strcmp_sse42 \
-K __strcpy_chk \
-K __strlen_sse2 \
-K __strlen_sse2_no_bsf \
-K __strlen_sse42 \
-K __strncmp_sse2 \
-K __strncmp_sse42 \
-K __strncpy_sse2 \
-K __strncpy_sse2_unaligned \
-K __strrchr_sse2 \
-K __strrchr_sse2_no_bsf \
-K __strrchr_sse42 \
-K __strstr_sse2 \
-K __strstr_sse42 \
-K pthread_create \
"$libc_path"
# libc.so.6 and other shared objects: Reduce to valuable symbols.
# Eliminate file symbols, annobin symbols, and symbols used by the
# glibc build to implement hidden aliases (__EI_*). We would also
# like to remove __GI_* symbols, but even listing them explicitly (as
# in -K __GI_strlen) still causes strip to remove them, so there is no
# filtering of __GI_* here. (Debuginfo is gone after this, so no need
# to optimize it.)
for p in "$libc_path" "$libdl_path" "$libpthread_path" "$librt_path"; do
strip -w \
-K '*' \
-K '!*.c' \
-K '!*.os' \
-K '!.annobin_*' \
-K '!__EI_*' \
-K '!__PRETTY_FUNCTION__*' \
"$p"
done
# ld.so: Rewrite the source file paths to match the extracted
# locations. First compute the arguments for invoking debugedit.