Skip to content

Commit

Permalink
devel/valgrind: patch for ifuncs
Browse files Browse the repository at this point in the history
The work for simd support uses @gnu_indirect_function. When Valgrind sees
binaries using such function it expects to have its own ifunc_handler. Until now
there wasn't one for FreeBSD so Valgrind terminates with an abort.

This patch merges the fix maintainer and creator made upstream.

PR:		273955
Reported by:	pjfloyd@wanadoo.fr (maintainer)
  • Loading branch information
paulfloyd authored and fernape committed Sep 20, 2023
1 parent babca63 commit 3d864ab
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
28 changes: 16 additions & 12 deletions devel/valgrind/Makefile
@@ -1,6 +1,6 @@
PORTNAME= valgrind
PORTVERSION= 3.21.0
PORTREVISION= 1
PORTREVISION= 2
PORTEPOCH= 1
CATEGORIES= devel
MASTER_SITES= SOURCEWARE/valgrind
Expand All @@ -14,17 +14,29 @@ LICENSE_FILE= ${WRKSRC}/COPYING

ONLY_FOR_ARCHS= amd64 i386

USES= autoreconf cpe gmake pathfix perl5 pkgconfig shebangfix python:3.9+,run tar:bz2
USES= autoreconf cpe gmake pathfix perl5 pkgconfig shebangfix \
python:3.9+,run tar:bz2
USE_PERL5= build
SHEBANG_FILES= callgrind/callgrind_annotate.in callgrind/callgrind_control.in cachegrind/cg_merge.in cachegrind/cg_diff.in cachegrind/cg_annotate.in
SHEBANG_FILES= callgrind/callgrind_annotate.in callgrind/callgrind_control.in \
cachegrind/cg_merge.in cachegrind/cg_diff.in \
cachegrind/cg_annotate.in
GNU_CONFIGURE= yes
CONFIGURE_ENV+= ac_cv_path_PERL=${PERL}

SSP_UNSAFE= yes
LIB32_PATH?= /usr/lib32/libc.so

CONFLICTS= valgrind-devel
PORTDOCS= html

# Valgrind needs to read debuginfo from its own preload shared libraries
# (quote from README_PACKAGERS
#-- Don't strip the debug info off lib/valgrind/$platform/vgpreload*.so
# in the installation tree. Either Valgrind won't work at all, or it
# will still work if you do, but will generate less helpful error
# messages.)
STRIP= # empty

PORTDOCS= html

OPTIONS_DEFINE= DOCS MANPAGES MPI
OPTIONS_DEFINE_amd64= 32BIT
Expand All @@ -34,14 +46,6 @@ OPTIONS_DEFAULT_amd64= 32BIT
.endif
OPTIONS_SUB= yes

# Valgrind needs to read debuginfo from its own preload shared libraries
# (quote from README_PACKAGERS
#-- Don't strip the debug info off lib/valgrind/$platform/vgpreload*.so
# in the installation tree. Either Valgrind won't work at all, or it
# will still work if you do, but will generate less helpful error
# messages.)
STRIP= # empty

32BIT_DESC= Enable debugging of 32-bit programs (requires lib32)
MPI_DESC= Enable build of MPI wrappers

Expand Down
31 changes: 31 additions & 0 deletions devel/valgrind/files/patch-coregrind-vg_preloaded.c
@@ -0,0 +1,31 @@
--- coregrind/vg_preloaded.c.orig 2023-09-19 20:30:09.413386000 +0200
+++ coregrind/vg_preloaded.c 2023-09-19 20:32:14.366333000 +0200
@@ -228,7 +228,27 @@

#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)

0 comments on commit 3d864ab

Please sign in to comment.