Hi ports,
The Valgrind specifies 'READ | WRITE | EXEC' when allocating memory
for target program as follows:
int fd = open("a.out", O_RDONLY);
void *addr = mmap(..., prot = PROT_READ | PROT_WRITE | PROT_EXEC, ...);
read(fd, addr, LENGTH);
/* Execute target program */
I modified to specify 'READ | EXEC' after readind the target
program as folloes:
int fd = open("a.out", O_RDONLY);
void *addr = mmap(..., prot = PROT_READ | PROT_WRITE, ...);
read(fd, addr, LENGTH);
mmap(addr, LENGTH, prot = PROT_READ | PROT_EXEC, ...);
/* Execute target program */
Therefor, the target program area can not be rewritten.
How about it?
--
ASOU Masato
Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/valgrind/Makefile,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile
--- Makefile 23 Oct 2019 02:35:05 -0000 1.21
+++ Makefile 25 Oct 2019 04:23:10 -0000
@@ -1,7 +1,5 @@
# $OpenBSD: Makefile,v 1.21 2019/10/23 02:35:05 asou Exp $
-USE_WXNEEDED = Yes
-
ONLY_FOR_ARCHS = amd64
COMMENT = instrumentation framework for dynamic analysis tools
Index: patches/patch-coregrind_link_tool_exe_openbsd_in
===================================================================
RCS file: /cvs/ports/devel/valgrind/patches/patch-coregrind_link_tool_exe_openbsd_in,v
retrieving revision 1.3
diff -u -p -r1.3 patch-coregrind_link_tool_exe_openbsd_in
--- patches/patch-coregrind_link_tool_exe_openbsd_in 2 Oct 2019 17:19:29 -0000 1.3
+++ patches/patch-coregrind_link_tool_exe_openbsd_in 25 Oct 2019 04:23:10 -0000
@@ -5,12 +5,12 @@
system(sprintf "sed -e 's|%x|%x|g' < $ldscript > $temp", $origbase, $notebase);
-my $cmd = sprintf "$cc -static -nopie -Wl,-Ttext=0x%x -Wl,-T,$temp", $textbase;
-+my $cmd = sprintf "$cc -static -nopie -Wl,--strip-all -Wl,-zwxneeded -Wl,-Ttext=0x%x -Wl,-T,$temp", $textbase;
+# 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.
++my $cmd = sprintf "$cc -static -nopie -Wl,--strip-all -Wl,-Ttext=0x%x -Wl,-T,$temp", $textbase;
# Add the rest of the parameters
foreach my $n (2 .. $#ARGV) {
Index: patches/patch-coregrind_m_aspacemgr_aspacemgr-linux_c
===================================================================
RCS file: /cvs/ports/devel/valgrind/patches/patch-coregrind_m_aspacemgr_aspacemgr-linux_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-coregrind_m_aspacemgr_aspacemgr-linux_c
--- patches/patch-coregrind_m_aspacemgr_aspacemgr-linux_c 2 Oct 2019 17:19:29 -0000 1.1
+++ patches/patch-coregrind_m_aspacemgr_aspacemgr-linux_c 25 Oct 2019 04:23:10 -0000
@@ -1,5 +1,17 @@
--- coregrind/m_aspacemgr/aspacemgr-linux.c.orig
+++ coregrind/m_aspacemgr/aspacemgr-linux.c
+@@ -2498,7 +2498,11 @@
+ a client request to call the outer VG_(am_get_advisory). */
+ sres = VG_(am_do_mmap_NO_NOTIFY)(
+ advised, length,
++#if defined(__OpenBSD__)
++ VKI_PROT_READ|VKI_PROT_WRITE,
++#else
+ VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC,
++
No comments:
Post a Comment