Preserve some symbols in libc.so.6's symtab (#1965374)

This commit is contained in:
Florian Weimer 2021-06-15 17:08:55 +02:00
parent fd5c07ba69
commit 027b24e17f
2 changed files with 43 additions and 7 deletions

View File

@ -97,7 +97,7 @@
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 15%{?dist}
Release: 16%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -2186,6 +2186,9 @@ fi
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
%changelog
* Tue Jun 15 2021 Florian Weimer <fweimer@redhat.com> - 2.33.9000-16
- Preserve some symbols in libc.so.6's symtab (#1965374)
* Tue Jun 15 2021 Florian Weimer <fweimer@redhat.com> - 2.33.9000-15
- Install shared objects under their ABI names, avoiding symlinks (#1652867)

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,50 @@ 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.
# (Debuginfo is gone after this, so no need to optimize it.)
strip -w \
-K '*vfprintf*' \
-K '__bzero*' \
-K '__mem*' \
-K '__rawmemchr*' \
-K '__stp*' \
-K '__str*' \
-K '__wcs*' \
-K '__wmem*' \
-K '_nl_make_l10nflist' \
"$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