From: Petar Jovanovic Date: Tue, 19 Jun 2012 18:30:23 +0000 (+0000) Subject: Adding MIPS-specific wrapper for syscall pipe. X-Git-Tag: svn/VALGRIND_3_8_0~213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42924b29d20830be1fdc45e50ef9e5d7f89566c5;p=thirdparty%2Fvalgrind.git Adding MIPS-specific wrapper for syscall pipe. Syscall pipe returns two descriptors in two registers, and thus a generic Linux wrapper is not sufficient. This fixes none/tests/fdleak_pipe. MIPS port is currently tracked as bug #270777. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12655 --- diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c index 804066a962..b5ab7c7718 100644 --- a/coregrind/m_syswrap/syswrap-mips32-linux.c +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c @@ -415,6 +415,7 @@ DECL_TEMPLATE (mips_linux, sys_sigreturn); DECL_TEMPLATE (mips_linux, sys_rt_sigreturn); DECL_TEMPLATE (mips_linux, sys_cacheflush); DECL_TEMPLATE (mips_linux, sys_set_thread_area); +DECL_TEMPLATE (mips_linux, sys_pipe); PRE (sys_socketcall) { @@ -1389,6 +1390,33 @@ PRE (sys_cacheflush) SET_STATUS_Success (0); } +PRE(sys_pipe) +{ + PRINT("sys_pipe ( %#lx )", ARG1); + PRE_REG_READ1(int, "pipe", int *, filedes); + PRE_MEM_WRITE( "pipe(filedes)", ARG1, 2*sizeof(int) ); +} + +POST(sys_pipe) +{ + Int p0, p1; + vg_assert(SUCCESS); + p0 = RES; + p1 = sr_ResEx(status->sres); + + if (!ML_(fd_allowed)(p0, "pipe", tid, True) || + !ML_(fd_allowed)(p1, "pipe", tid, True)) { + VG_(close)(p0); + VG_(close)(p1); + SET_STATUS_Failure( VKI_EMFILE ); + } else { + if (VG_(clo_track_fds)) { + ML_(record_fd_open_nameless)(tid, p0); + ML_(record_fd_open_nameless)(tid, p1); + } + } +} + #undef PRE #undef POST @@ -1448,7 +1476,7 @@ static SyscallTableEntry syscall_main_table[] = { GENX_ (__NR_mkdir, sys_mkdir), // 39 GENX_ (__NR_rmdir, sys_rmdir), // 40 GENXY (__NR_dup, sys_dup), // 41 - LINXY (__NR_pipe, sys_pipe), // 42 + PLAXY (__NR_pipe, sys_pipe), // 42 GENXY (__NR_times, sys_times), // 43 //.. GENX_(__NR_prof, sys_ni_syscall), // 44 //..