From 226946afd0440d73f9f8dcf4d800cd02a8a31093 Mon Sep 17 00:00:00 2001 From: zrj Date: Tue, 4 Oct 2016 10:37:35 +0300 Subject: [PATCH 08/20] libc: Rip out pthread_cancel stub symbol. After looking through use cases i couldn't find any signs of libc needing to provide stub for pthread_cancel() function. It doesn't make much sense for any program to use this symbol but not use the pthread_create(). With this assumption it should be safe to move out pthread_cancel() from libc to libpthread.so dummy to be together with weak symbol of pthread_create(). Doing just that fixes how gcc libs check for pthread presence when playing weak symbol chasing games. I don't judge but configure.ac? --- lib/libc/gen/Symbol.map | 1 - lib/libc/gen/_pthread_stubs.c | 4 +++- lib/libpthread/dummy.c | 11 +++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 8e94912..253222e 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -53,7 +53,6 @@ DF404.0 { pthread_barrierattr_getpshared; pthread_barrierattr_init; pthread_barrierattr_setpshared; - pthread_cancel; pthread_cleanup_pop; pthread_cleanup_push; pthread_cond_broadcast; diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c index 31cf5b6..9cbb1ab 100644 --- a/lib/libc/gen/_pthread_stubs.c +++ b/lib/libc/gen/_pthread_stubs.c @@ -39,6 +39,8 @@ * latter can't be allowed to exit/terminate). */ +#define WRlc(f, n) \ + __weak_reference(f, _ ## n); #define WR(f, n) \ __weak_reference(f, _ ## n); \ __weak_reference(f, n) @@ -73,7 +75,7 @@ WR(stub_zero, pthread_barrierattr_destroy); WR(stub_zero, pthread_barrierattr_getpshared); WR(stub_zero, pthread_barrierattr_init); WR(stub_zero, pthread_barrierattr_setpshared); -WR(stub_zero, pthread_cancel); +WRlc(stub_zero, pthread_cancel); WR(stub_zero, pthread_cleanup_pop); WR(stub_zero, pthread_cleanup_push); WR(stub_zero, pthread_cond_broadcast); diff --git a/lib/libpthread/dummy.c b/lib/libpthread/dummy.c index 9f9d8bd..54c7076 100644 --- a/lib/libpthread/dummy.c +++ b/lib/libpthread/dummy.c @@ -1,5 +1,3 @@ -/* $DragonFly: src/lib/libpthread/dummy.c,v 1.1 2007/04/17 12:34:07 corecode Exp $ */ - #include #include @@ -11,3 +9,12 @@ dummy_pthread_create(void) } __weak_reference(dummy_pthread_create, pthread_create); + +static void __attribute__((__used__)) +dummy_pthread_cancel(void) +{ + fprintf(stderr, "libpthread.so: dummy weak symbol executed\n"); + abort(); +} + +__weak_reference(dummy_pthread_cancel, pthread_cancel); -- 2.9.2