From: Masato Asou <a...@soum.co.jp> Date: Fri, 03 Apr 2020 15:24:44 +0900 (JST)
> Sorry, this patch is not correct. I'm canceling this patch. I'll > consder it again. > > From: Masato Asou <a...@soum.co.jp> > Date: Fri, 03 Apr 2020 12:24:32 +0900 (JST) > >> Hello, >> >> I made patch for print symbold of ld.so, if error was occured as >> below: </snip> I was corrected previous patch. ok? Index: Makefile =================================================================== RCS file: /cvs/ports/devel/valgrind/Makefile,v retrieving revision 1.23 diff -u -p -r1.23 Makefile --- Makefile 23 Dec 2019 23:26:32 -0000 1.23 +++ Makefile 7 Apr 2020 00:21:47 -0000 @@ -7,7 +7,7 @@ CATEGORIES = devel V = 3.10.1 PV = 20160331 -REVISION = 16 +REVISION = 17 DISTNAME = valgrind-${V} EXTRACT_SUFX = .tar.bz2 Index: patches/patch-coregrind_m_libcfile_c =================================================================== RCS file: patches/patch-coregrind_m_libcfile_c diff -N patches/patch-coregrind_m_libcfile_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-coregrind_m_libcfile_c 7 Apr 2020 00:21:47 -0000 @@ -0,0 +1,39 @@ +$OpenBSD$ + +--- coregrind/m_libcfile.c.orig ++++ coregrind/m_libcfile.c +@@ -40,6 +40,9 @@ + #include "pub_core_xarray.h" + #include "pub_core_clientstate.h" // VG_(fd_hard_limit) + #include "pub_core_syscall.h" ++#if defined(VGO_openbsd) ++#include "pub_core_syswrap.h" ++#endif + + /* IMPORTANT: on Darwin it is essential to use the _nocancel versions + of syscalls rather than the vanilla version, if a _nocancel version +@@ -174,6 +177,14 @@ + # elif defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_openbsd) + SysRes res = VG_(do_syscall3)(__NR_open, + (UWord)pathname, flags, mode); ++# if defined(VGO_openbsd) ++ // Track opened files by Valgrind so that we can look up filenames for ++ // mapped vnodes via the recorded table, instead of relying on procfs or ++ // kvm. This is possible as all executables and related files (dynamic ++ // linkder etc.) are all opened by host (Valgrind). ++ VG_(record_fd_open_with_given_name)(-1, sr_Res(res), (char *)pathname); ++ VG_(mark_fd_as_internal)(-1, sr_Res(res)); ++# endif + # elif defined(VGO_darwin) + SysRes res = VG_(do_syscall3)(__NR_open_nocancel, + (UWord)pathname, flags, mode); +@@ -198,6 +209,9 @@ + /* Hmm. Return value is not checked. That's uncool. */ + # if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_openbsd) + (void)VG_(do_syscall1)(__NR_close, fd); ++# if defined(VGO_openbsd) ++ VG_(record_fd_close)(fd); ++# endif + # elif defined(VGO_darwin) + (void)VG_(do_syscall1)(__NR_close_nocancel, fd); + # else Index: patches/patch-coregrind_m_main_c =================================================================== RCS file: /cvs/ports/devel/valgrind/patches/patch-coregrind_m_main_c,v retrieving revision 1.3 diff -u -p -r1.3 patch-coregrind_m_main_c --- patches/patch-coregrind_m_main_c 2 Oct 2019 17:19:29 -0000 1.3 +++ patches/patch-coregrind_m_main_c 7 Apr 2020 00:21:47 -0000 @@ -71,7 +71,24 @@ Index: coregrind/m_main.c // Get the current process stack rlimit. VG_(getrlimit)(VKI_RLIMIT_STACK, &VG_(client_rlimit_stack)); -@@ -2433,6 +2468,10 @@ +@@ -1834,7 +1869,16 @@ + // Set default vex control params + LibVEX_default_VexControl(& VG_(clo_vex_control)); + ++#if defined(VGO_openbsd) + //-------------------------------------------------------------- ++ // setup file descriptors ++ // p: n/a ++ //-------------------------------------------------------------- ++ VG_(debugLog)(1, "main", "Setup file descriptors\n"); ++ setup_file_descriptors(); ++#endif ++ ++ //-------------------------------------------------------------- + // Load client executable, finding in $PATH if necessary + // p: early_process_cmd_line_options() [for 'exec', 'need_help', + // clo_max_stackframe, +@@ -2433,6 +2477,10 @@ VG_(address_of_m_main_shutdown_actions_NORETURN) = & shutdown_actions_NORETURN; @@ -82,7 +99,7 @@ Index: coregrind/m_main.c /* Run the first thread, eventually ending up at the continuation address. */ VG_(main_thread_wrapper_NORETURN)(1); -@@ -3159,6 +3198,8 @@ +@@ -3159,6 +3207,8 @@ "__start:\n" /* pass args (long argc, char **argv, ...) on stack */ "\tmovq %rsp, %rdi\n" @@ -91,7 +108,7 @@ Index: coregrind/m_main.c /* set up the new stack in %rsi */ "\tmovq $vgPlain_interim_stack, %rsi\n" "\taddq $"VG_STRINGIFY(VG_STACK_GUARD_SZB)", %rsi\n" -@@ -3166,6 +3207,9 @@ +@@ -3166,6 +3216,9 @@ "\tandq $~15, %rsi\n" /* install it, and collect the original one */ "\txchgq %rsi, %rsp\n" @@ -101,7 +118,7 @@ Index: coregrind/m_main.c /* call _start_in_C_amd64_freebsd, passing it the startup %rsp */ "\tcall _start_in_C_amd64_openbsd\n" "\thlt\n" -@@ -3233,7 +3235,7 @@ __asm(" .section \".note.openbsd.ident\", \"a\"\n" +@@ -3233,7 +3286,7 @@ #if !defined(VGO_openbsd) #include <elf.h> #else Index: patches/patch-coregrind_m_syswrap_syswrap_generic_c =================================================================== RCS file: /cvs/ports/devel/valgrind/patches/patch-coregrind_m_syswrap_syswrap_generic_c,v retrieving revision 1.1 diff -u -p -r1.1 patch-coregrind_m_syswrap_syswrap_generic_c --- patches/patch-coregrind_m_syswrap_syswrap_generic_c 23 Dec 2019 23:26:32 -0000 1.1 +++ patches/patch-coregrind_m_syswrap_syswrap_generic_c 7 Apr 2020 00:21:47 -0000 @@ -1,6 +1,50 @@ +$OpenBSD$ + --- coregrind/m_syswrap/syswrap-generic.c.orig +++ coregrind/m_syswrap/syswrap-generic.c -@@ -2240,7 +2240,13 @@ +@@ -580,6 +580,13 @@ + } + } + ++#if defined(VGO_openbsd) ++void VG_(record_fd_close)(Int fd) ++{ ++ record_fd_close(fd); ++} ++#endif ++ + /* Note the fact that a file descriptor was just opened. If the + tid is -1, this indicates an inherited fd. If the pathname is NULL, + this either indicates a non-standard file (i.e. a pipe or socket or +@@ -620,6 +627,13 @@ + i->internal = 0; + } + ++#if defined(VGO_openbsd) ++void VG_(record_fd_open_with_given_name)(ThreadId tid, Int fd, char *pathname) ++{ ++ ML_(record_fd_open_with_given_name)(tid, fd, pathname); ++} ++#endif ++ + void ML_(mark_fd_as_internal)(ThreadId tid, Int fd) + { + OpenFd *i = allocated_fds; +@@ -636,6 +650,13 @@ + } + } + ++#if defined(VGO_openbsd) ++void VG_(mark_fd_as_internal)(ThreadId tid, Int fd) ++{ ++ ML_(mark_fd_as_internal)(tid, fd); ++} ++#endif ++ + // Record opening of an fd, and find its name. + void ML_(record_fd_open_named)(ThreadId tid, Int fd) + { +@@ -2240,7 +2261,13 @@ /* Otherwise we're OK (so far). Install aspacem's choice of address, and let the mmap go through. */ sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3, Index: patches/patch-coregrind_m_ume_main_c =================================================================== RCS file: patches/patch-coregrind_m_ume_main_c diff -N patches/patch-coregrind_m_ume_main_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-coregrind_m_ume_main_c 7 Apr 2020 00:21:47 -0000 @@ -0,0 +1,25 @@ +$OpenBSD$ + +--- coregrind/m_ume/main.c.orig ++++ coregrind/m_ume/main.c +@@ -80,20 +80,6 @@ + } + fd = sr_Res(res); + +-#if defined(VGO_openbsd) +- extern Int VG_(fd_hard_limit); +- void ML_(record_fd_open_with_given_name)(ThreadId tid, Int fd, char *pathname); +- +- // Track opened files by Valgrind so that we can look up filenames for mapped +- // vnodes via the recorded table, instead of relying on procfs or kvm. This is +- // possible as all executables and related files (dynamic linkder etc.) are all +- // opened by host (Valgrind). +- VG_(fd_hard_limit) = 10; +- ML_(record_fd_open_with_given_name)(-1, fd, exe_name); +- ML_(mark_fd_as_internal)(-1, fd); +- VG_(fd_hard_limit) = -1; +-#endif +- + // Check we have execute permissions + ret = VG_(check_executable)(&is_setuid, exe_name, allow_setuid); + if (0 != ret) { Index: patches/patch-coregrind_pub_core_syswrap_h =================================================================== RCS file: patches/patch-coregrind_pub_core_syswrap_h diff -N patches/patch-coregrind_pub_core_syswrap_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-coregrind_pub_core_syswrap_h 7 Apr 2020 00:21:47 -0000 @@ -0,0 +1,19 @@ +$OpenBSD$ + +--- coregrind/pub_core_syswrap.h.orig ++++ coregrind/pub_core_syswrap.h +@@ -64,6 +64,14 @@ + // Release resources held by this thread + extern void VG_(cleanup_thread) ( ThreadArchState* ); + ++#if defined(VGO_openbsd) ++// File-descriptor tracking ++extern void VG_(record_fd_close)(Int fd); ++extern void VG_(record_fd_open_with_given_name)(ThreadId tid, Int fd, ++ char *pathname); ++extern void VG_(mark_fd_as_internal)(ThreadId tid, Int fd); ++#endif ++ + /* fd leakage calls. */ + extern void VG_(init_preopened_fds) ( void ); + extern void VG_(show_open_fds) ( const HChar* when ); -- ASOU Masato