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