Monday, September 30, 2019

Re: valgrind diff to fix run memcheck on amd64

From: Masato Asou <asou@soum.co.jp>
Date: Fri, 27 Sep 2019 13:18:50 +0900 (JST)

> Hi ports,
>
> This is a patch for running valgrind memcheck on amd64. I corrected
> the following two problems.
>
> - FS register can be used.
> - Fixed a problem that strip command rewrites offset and align of
> memcheck ELF file.

Additional information:

- Abort trap was occurred when lounched valgrind.

$ cd /usr/ports/devel/valgrind
$ make && doas make install
$ valgrind /bin/ls
Abort trap
$

Sorry, I lost --strip-all option into
coregrind/link_tool_exe_openbsd.in.

New patch is below:

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/valgrind/Makefile,v
retrieving revision 1.19
diff -u -p -r1.19 Makefile
--- Makefile 12 Jul 2019 20:46:03 -0000 1.19
+++ Makefile 27 Sep 2019 03:08:46 -0000
@@ -38,4 +38,10 @@ AUTORECONF = /bin/sh ./autogen.sh
.if ${PROPERTIES:Mclang}
# replace -lgcc
MAKE_FLAGS = TOOL_LDADD_COMMON=-lcompiler_rt
+# XXX The '-s' option was not specified when executing the install command.
+# Instead '--strip-all' is now executed at link time.
+# strip command rewrite offset and align in ELF file. Therefor, when valgrind
+# launch memcheck-amd64-openbsd, an Abort trap occurs in the execvp() system
+# call.
+INSTALL_STRIP =
.endif
Index: patches/patch-VEX_priv_guest_amd64_helpers_c
===================================================================
RCS file: patches/patch-VEX_priv_guest_amd64_helpers_c
diff -N patches/patch-VEX_priv_guest_amd64_helpers_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-VEX_priv_guest_amd64_helpers_c 27 Sep 2019 03:08:46 -0000
@@ -0,0 +1,16 @@
+--- VEX/priv/guest_amd64_helpers.c.orig
++++ VEX/priv/guest_amd64_helpers.c
+@@ -3744,6 +3744,13 @@ void LibVEX_GuestAMD64_initialise ( /*OUT*/VexGuestAMD64State* vex_state )
+ /* HACK: represent the offset associated with %fs==0. This
+ assumes that %fs is only ever zero. */
+ vex_state->guest_FS_ZERO = 0;
++#if defined(__OpenBSD__)
++{
++ int fs;
++ __asm__("mov %%fs,%0" : "=r" (fs));
++ vex_state->guest_FS_ZERO = fs;
++}
++

No comments:

Post a Comment