Redo the crafted libc.so.6 symbol table for valgrind (#1965374)

This commit is contained in:
Florian Weimer 2021-06-17 14:34:16 +02:00
parent 654f636b32
commit 14d5c92a57
2 changed files with 92 additions and 7 deletions

View File

@ -97,7 +97,7 @@
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 20%{?dist}
Release: 21%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -150,6 +150,11 @@ rpm.define("__debug_install_post bash " .. wrapper
.. " " .. sysroot .. " " .. original)
}
# The wrapper script relies on the fact that debugedit does not change
# build IDs.
%define _no_recompute_build_ids 1
%undefine _unique_build_ids
##############################################################################
# Patches:
# - See each individual patch file for origin and upstream status.
@ -2184,6 +2189,9 @@ fi
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
%changelog
* Thu Jun 17 2021 Florian Weimer <fweimer@redhat.com> - 2.33.9000-21
- Redo the crafted libc.so.6 symbol table for valgrind (#1965374)
* Thu Jun 17 2021 Florian Weimer <fweimer@redhat.com> - 2.33.9000-20
- Remove .symtab from libc.so.6 again (#1965374)

View File

@ -9,10 +9,14 @@
# LDSO-PATH file, followed by note merging and DWZ compression.
# 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.
set -ex
ldso_tmp="$(mktemp)"
libc_tmp="$(mktemp)"
# Prefer a separately installed debugedit over the RPM-integrated one.
if command -v debugedit >/dev/null ; then
@ -22,7 +26,7 @@ else
fi
cleanup () {
rm -f "$ldso_tmp"
rm -f "$ldso_tmp" "$libc_tmp"
}
trap cleanup 0
@ -43,21 +47,94 @@ for ldso_candidate in `find "$sysroot_path" -regextype posix-extended \
fi
done
# Preserve the original file.
# libc.so.6 always uses this name, so it is simpler to locate.
libc_path=
for libc_candidate in `find "$sysroot_path" -name libc.so.6`; do
if test -z "$libc_path" ; then
libc_path="$libc_candidate"
else
echo "error: multiple libc.so.6 candidates: $libc_path, $libc_candidate"
exit 1
fi
done
# Preserve the original files.
cp "$ldso_path" "$ldso_tmp"
cp "$libc_path" "$libc_tmp"
# Run the debuginfo extraction.
"$script_path" "$@"
# Restore the original file.
# Restore the original files.
cp "$ldso_tmp" "$ldso_path"
cp "$libc_tmp" "$libc_path"
# Reduce the size of notes. Primarily for annobin.
objcopy --merge-notes "$ldso_path"
objcopy --merge-notes "$libc_path"
# Rewrite the source file paths to match the extracted locations.
# First compute the arguments for invoking debugedit. See
# find-debuginfo.sh.
# 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"
# ld.so: Rewrite the source file paths to match the extracted
# locations. First compute the arguments for invoking debugedit.
# See find-debuginfo.sh.
debug_dest_name="/usr/src/debug"
last_arg=
while true ; do