Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 1 | From cdec010444df5a4328e90d07a2024fdeefcc74b5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Paul Floyd <paulf@free.fr> |
| 3 | Date: Wed, 18 Nov 2020 12:49:20 -0400 |
| 4 | Subject: [PATCH] helgrind: Intercept libc functions |
| 5 | |
| 6 | PTH_FUNC definition needs to be modified in order to |
| 7 | intercept posix thread functions in both libc and |
| 8 | libpthread. In order to handle this in helgrind, weak alias |
| 9 | the pthread functions in glibc. |
| 10 | |
| 11 | Upstream-Status: Submitted |
| 12 | |
| 13 | Signed-off-by: Paul Floyd <paulf@free.fr> |
| 14 | Signed-off-by: Stacy Gaikovaia <stacy.gaikovaia@windriver.com> |
| 15 | --- |
| 16 | helgrind/hg_intercepts.c | 12 ++++++++++++ |
| 17 | 1 file changed, 12 insertions(+) |
| 18 | |
| 19 | diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c |
| 20 | index a10c3a4a3..316140ca6 100644 |
| 21 | --- a/helgrind/hg_intercepts.c |
| 22 | +++ b/helgrind/hg_intercepts.c |
| 23 | @@ -77,6 +77,11 @@ |
| 24 | /*--- ---*/ |
| 25 | /*----------------------------------------------------------------*/ |
| 26 | |
| 27 | +#define hg_expand(tok) #tok |
| 28 | +#define hg_str(tok) hg_expand(tok) |
| 29 | +# define hg_weak_alias(name, aliasname) \ |
| 30 | + extern __typeof (name) aliasname __attribute__ ((weak, alias(hg_str(name)))) |
| 31 | + |
| 32 | #if defined(VGO_solaris) |
| 33 | /* On Solaris, libpthread is just a filter library on top of libc. |
| 34 | * Threading and synchronization functions in runtime linker are not |
| 35 | @@ -91,9 +96,16 @@ |
| 36 | #define CREQ_PTHREAD_T Word |
| 37 | #define SEM_ERROR ret |
| 38 | #else |
| 39 | +#ifdef MUSL_LIBC |
| 40 | +#define PTH_FUNC(ret_ty, f, args...) \ |
| 41 | + ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args); \ |
| 42 | + ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args) |
| 43 | +#else |
| 44 | #define PTH_FUNC(ret_ty, f, args...) \ |
| 45 | ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args); \ |
| 46 | + hg_weak_alias(I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f), I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBC_SONAME,f)); \ |
| 47 | ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args) |
| 48 | +#endif |
| 49 | #define CREQ_PTHREAD_T pthread_t |
| 50 | #define SEM_ERROR errno |
| 51 | #endif /* VGO_solaris */ |
| 52 | -- |
| 53 | 2.17.1 |
| 54 | |