1If we link against a newer glibc 2.34 and then try and our LD_PRELOAD is run against a 2binary on a host with an older libc, we see symbol errors since in glibc 2.34, pthread 3and dl are merged into libc itself. 4 5We need to use the older form of linking so use glibc binaries from an older release 6to force this. We only use minimal symbols from these anyway. 7 8pthread_atfork is problematic, particularly on arm so use the internal glibc routine 9it maps too. This was always present in the main libc from 2.3.2 onwards. 10 11Yes this is horrible. Better solutions welcome. 12 13There is more info in the bug: [YOCTO #14521] 14 15Upstream-Status: Inappropriate [this patch is native and nativesdk] 16Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> 17 18Tweak library search order, make prebuilt lib ahead of recipe lib 19Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> 20--- 21 Makefile.in | 2 +- 22 pseudo_wrappers.c | 5 ++++- 23 2 files changed, 5 insertions(+), 2 deletions(-) 24 25diff --git a/Makefile.in b/Makefile.in 26--- a/Makefile.in 27+++ b/Makefile.in 28@@ -120,7 +120,7 @@ $(PSEUDODB): pseudodb.o $(SHOBJS) $(DBOBJS) pseudo_ipc.o | $(BIN) 29 libpseudo: $(LIBPSEUDO) 30 31 $(LIBPSEUDO): $(WRAPOBJS) pseudo_client.o pseudo_ipc.o $(SHOBJS) | $(LIB) 32- $(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -shared -o $(LIBPSEUDO) \ 33+ $(CC) $(CFLAGS) -Lprebuilt/$(shell uname -m)-linux/lib/ $(CFLAGS_PSEUDO) -shared -o $(LIBPSEUDO) \ 34 pseudo_client.o pseudo_ipc.o \ 35 $(WRAPOBJS) $(SHOBJS) $(LDFLAGS) $(CLIENT_LDFLAGS) 36 37diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c 38--- a/pseudo_wrappers.c 39+++ b/pseudo_wrappers.c 40@@ -100,10 +100,13 @@ static void libpseudo_atfork_child(void) 41 pseudo_mutex_holder = 0; 42 } 43 44+extern void *__dso_handle; 45+extern int __register_atfork (void (*) (void), void (*) (void), void (*) (void), void *); 46+ 47 static void 48 _libpseudo_init(void) { 49 if (!_libpseudo_initted) 50- pthread_atfork(NULL, NULL, libpseudo_atfork_child); 51+ __register_atfork (NULL, NULL, libpseudo_atfork_child, &__dso_handle == NULL ? NULL : __dso_handle); 52 53 pseudo_getlock(); 54 pseudo_antimagic(); 55-- 562.27.0 57 58