]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 473870 - FreeBSD 14 applications fail early at startup
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 31 Aug 2023 13:32:21 +0000 (15:32 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 31 Aug 2023 13:44:16 +0000 (15:44 +0200)
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.

NEWS
coregrind/vg_preloaded.c

diff --git a/NEWS b/NEWS
index 96eb06af8a7c04dbf0161e39419aaf7904c8d5c6..519ed664c1ff059f0a30bd3f05af1f7c7ec1d316 100644 (file)
--- 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
index a792081b112bc5885e358057d18c35d1507e87db..1c727966f3a2c8085e61f9475086dc16b4b1a9dd 100644 (file)
@@ -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)