pseudo: Fix to work with glibc 2.34 systems

The merge of libdl into libc in glibc 2.34 causes problems for pseudo. Add a fix
that works around this issue.

(From OE-Core rev: dd3e46a043c81cd4d81731a0f691868d3c059742)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2021-08-17 15:21:26 +01:00
parent c3e72164e7
commit 4cc61c81f7
3 changed files with 73 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#!/bin/sh
#
# Script to re-generate pseudo-prebuilt-2.33.tar.xz
#
# Copyright (C) 2021 Richard Purdie
#
# SPDX-License-Identifier: GPL-2.0-only
#
for i in x86_64 aarch64 i686; do
if [ ! -e $i-nativesdk-libc.tar.xz ]; then
wget http://downloads.yoctoproject.org/releases/uninative/3.2/$i-nativesdk-libc.tar.xz
fi
tar -xf $i-nativesdk-libc.tar.xz --wildcards \*/lib/libpthread\* \*/lib/libdl\*
cd $i-linux/lib
ln -s libdl.so.2 libdl.so
ln -s libpthread.so.0 libpthread.so
cd ../..
done
tar -cJf pseudo-prebuilt-2.33.tar.xz *-linux

View File

@@ -0,0 +1,49 @@
If we link against a newer glibc 2.34 and then try and our LD_PRELOAD is run against a
binary on a host with an older libc, we see symbol errors since in glibc 2.34, pthread
and dl are merged into libc itself.
We need to use the older form of linking so use glibc binaries from an older release
to force this. We only use minimal symbols from these anyway.
pthread_atfork is problematic, particularly on arm so use the internal glibc routine
it maps too. This was always present in the main libc from 2.3.2 onwards.
Yes this is horrible. Better solutions welcome.
There is more info in the bug: [YOCTO #14521]
Upstream-Status: Inappropriate [this patch is native only]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Index: git/Makefile.in
===================================================================
--- git.orig/Makefile.in
+++ git/Makefile.in
@@ -122,7 +122,7 @@ libpseudo: $(LIBPSEUDO)
$(LIBPSEUDO): $(WRAPOBJS) pseudo_client.o pseudo_ipc.o $(SHOBJS) | $(LIB)
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -shared -o $(LIBPSEUDO) \
pseudo_client.o pseudo_ipc.o \
- $(WRAPOBJS) $(SHOBJS) $(LDFLAGS) $(CLIENT_LDFLAGS)
+ $(WRAPOBJS) $(SHOBJS) $(LDFLAGS) -Lprebuilt/$(shell uname -m)-linux/lib/ $(CLIENT_LDFLAGS)
# *everything* now relies on stuff that's generated in the
# wrapper process.
Index: git/pseudo_wrappers.c
===================================================================
--- git.orig/pseudo_wrappers.c
+++ git/pseudo_wrappers.c
@@ -100,10 +100,13 @@ static void libpseudo_atfork_child(void)
pseudo_mutex_holder = 0;
}
+extern void *__dso_handle;
+extern int __register_atfork (void (*) (void), void (*) (void), void (*) (void), void *);
+
static void
_libpseudo_init(void) {
if (!_libpseudo_initted)
- pthread_atfork(NULL, NULL, libpseudo_atfork_child);
+ __register_atfork (NULL, NULL, libpseudo_atfork_child, &__dso_handle == NULL ? NULL : __dso_handle);
pseudo_getlock();
pseudo_antimagic();

View File

@@ -5,6 +5,10 @@ SRC_URI = "git://git.yoctoproject.org/pseudo;branch=oe-core \
file://fallback-passwd \
file://fallback-group \
"
SRC_URI:append:class-native = " \
http://downloads.yoctoproject.org/mirror/sources/pseudo-prebuilt-2.33.tar.xz;subdir=git/prebuilt;name=prebuilt \
file://older-glibc-symbols.patch"
SRC_URI[prebuilt.sha256sum] = "ed9f456856e9d86359f169f46a70ad7be4190d6040282b84c8d97b99072485aa"
SRCREV = "b988b0a6b8afd8d459bc9a2528e834f63a3d59b2"
S = "${WORKDIR}/git"