From: Paul Floyd Date: Thu, 31 Aug 2023 13:32:21 +0000 (+0200) Subject: Bug 473870 - FreeBSD 14 applications fail early at startup X-Git-Tag: VALGRIND_3_22_0~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c934430d56c2add25002ea8e321bd8bdab80fc99;p=thirdparty%2Fvalgrind.git Bug 473870 - FreeBSD 14 applications fail early at startup FreeBSD recently started adding some functions using @gnu_indirect_function, specifically strpcmp which was causing this crash. When running and encountering this ifunc Valgrind looked for the ifunc_handler. But there wasn't one for FreeBSD so Valgrind asserted. --- diff --git a/NEWS b/NEWS index 96eb06af8a..519ed664c1 100644 --- a/NEWS +++ b/NEWS @@ -52,6 +52,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 472963 Broken regular expression in configure.ac 473604 Fix bug472219.c compile failure with Clang 16 473677 make check compile failure with Clang 16 based on GCC 13.x +473870 FreeBSD 14 applications fail early at startup n-i-bz Allow arguments with spaces in .valgrindrc files To see details of a given bug, visit diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c index a792081b11..1c727966f3 100644 --- a/coregrind/vg_preloaded.c +++ b/coregrind/vg_preloaded.c @@ -238,7 +238,27 @@ void VG_REPLACE_FUNCTION_ZU(libSystemZdZaZddylib, arc4random_addrandom)(unsigned #elif defined(VGO_freebsd) -// nothing specific currently +#if (FREEBSD_VERS >= FREEBSD_14) + +void * VG_NOTIFY_ON_LOAD(ifunc_wrapper) (void); +void * VG_NOTIFY_ON_LOAD(ifunc_wrapper) (void) +{ + OrigFn fn; + Addr result = 0; + Addr fnentry; + + /* Call the original indirect function and get it's result */ + VALGRIND_GET_ORIG_FN(fn); + CALL_FN_W_v(result, fn); + + fnentry = result; + + VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__ADD_IFUNC_TARGET, + fn.nraddr, fnentry, 0, 0, 0); + return (void*)result; +} + +#endif #elif defined(VGO_solaris)