diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca5440e7b4faa70f162146202051171d3b211626..312cfd177e5794a65401245029b0318d1cb8b977 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,6 +86,8 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H)
 
 check_symbol_exists(O_DSYNC fcntl.h HAVE_O_DSYNC)
 check_function_exists(fdatasync HAVE_FDATASYNC)
+check_function_exists(memmem HAVE_MEMMEM)
+check_function_exists(memrchr HAVE_MEMRCHR)
 
 test_big_endian(HAVE_BYTE_ORDER_BIG_ENDIAN)
 
diff --git a/connector/c/tntnet/CMakeLists.txt b/connector/c/tntnet/CMakeLists.txt
index 4f70588962ec1e153b88032a6803327173448a8c..4a2bfe6e573bf1befab779faf3f4531d1ca79937 100644
--- a/connector/c/tntnet/CMakeLists.txt
+++ b/connector/c/tntnet/CMakeLists.txt
@@ -51,6 +51,7 @@ set_target_properties(tntnet PROPERTIES COMPILE_FLAGS "${tntnet_cflags}")
 
 project(tntnet_shared)
 add_library(tntnet_shared SHARED ${tntnet_sources})
+target_link_libraries(tntnet_shared tnt_shared)
 set_target_properties(tntnet_shared PROPERTIES OUTPUT_NAME tntnet)
 set_target_properties(tntnet_shared PROPERTIES COMPILE_FLAGS "${tntnet_cflags}")
 
diff --git a/connector/c/tntsql/CMakeLists.txt b/connector/c/tntsql/CMakeLists.txt
index fa73140448202582f90d8aac07ef35c1c7fbead1..9f8336527e07f0b7b592b5700e66c6cea9e74ed5 100644
--- a/connector/c/tntsql/CMakeLists.txt
+++ b/connector/c/tntsql/CMakeLists.txt
@@ -50,6 +50,7 @@ set_target_properties(tntsql PROPERTIES COMPILE_FLAGS "${tntsql_cflags}")
 
 project(tntsql_shared)
 add_library(tntsql_shared SHARED ${tntsql_sources})
+target_link_libraries(tntsql_shared tnt_shared)
 set_target_properties(tntsql_shared PROPERTIES OUTPUT_NAME tntsql)
 set_target_properties(tntsql_shared PROPERTIES COMPILE_FLAGS "${tntsql_cflags}")
 
diff --git a/include/config.h.cmake b/include/config.h.cmake
index ce481e85af67a530f1635bac52dea119c593faf0..2db3b8115c96309b13a12e09f7bb8d06d9a3ff1e 100644
--- a/include/config.h.cmake
+++ b/include/config.h.cmake
@@ -43,7 +43,6 @@
  */
 #define MAP_ANONYMOUS MAP_ANON
 #endif
-
 /*
  * Defined if O_DSYNC mode exists for open(2).
  */
@@ -57,6 +56,14 @@
  * Defined if fdatasync(2) call is present.
  */
 #cmakedefine HAVE_FDATASYNC 1
+/*
+ * Defined if this platform has GNU specific memmem().
+ */
+#cmakedefine HAVE_MEMMEM 1
+/*
+ * Defined if this platform has GNU specific memrchr().
+ */
+#cmakedefine HAVE_MEMRCHR 1
 /*
  * Set if this is a GNU system and libc has __libc_stack_end.
  */
diff --git a/include/util.h b/include/util.h
index 91e710fcb7e0d9bfae0793aa7916ff193609d773..c6f2ad5765d5b478746750215be7e7af9e393c66 100644
--- a/include/util.h
+++ b/include/util.h
@@ -140,4 +140,16 @@ void assert_fail(const char *assertion, const char *file,
 		 unsigned int line, const char *function) __attribute__ ((noreturn));
 #endif
 
+#ifndef HAVE_MEMMEM
+/* Declare memmem(). */
+void *
+memmem(const void *block, size_t blen, const void *pat, size_t plen);
+#endif /* HAVE_MEMMEM */
+
+#ifndef HAVE_MEMRCHR
+/* Declare memrchr(). */
+void *
+memrchr(const void *s, int c, size_t n);
+#endif /* HAVE_MEMRCHR */
+
 #endif /* TARANTOOL_UTIL_H_INCLUDED */
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index ff332b4f62bf64ab22ca9a02e3dc7f900805bfb3..f114ede006f85ffda339a6116f505fb29eb3f5ed 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -1,5 +1,13 @@
-add_library (misc STATIC crc32.c proctitle.c qsort_arg.c)
 
+if (NOT HAVE_MEMMEM)
+    set (misc_opt_sources ${misc_opt_sources} memmem.c)
+endif()
+
+if (NOT HAVE_MEMRCHR)
+    set (misc_opt_sources ${misc_opt_sources} memrchr.c)
+endif()
+
+add_library (misc STATIC crc32.c proctitle.c qsort_arg.c ${misc_opt_sources})
 if (NOT TARGET_OS_DEBIAN_FREEBSD) 
 	if (TARGET_OS_FREEBSD)
 	  set_source_files_properties(proctitle.c PROPERTIES
diff --git a/third_party/memmem.c b/third_party/memmem.c
new file mode 100644
index 0000000000000000000000000000000000000000..dfdd10641558d04e695be910c51d82adc14d074e
--- /dev/null
+++ b/third_party/memmem.c
@@ -0,0 +1,69 @@
+/*	$NetBSD: memmem.c,v 1.2 2008/04/28 20:23:00 martin Exp $	*/
+
+/*-
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Perry E. Metzger of Metzger, Dowdeswell & Co. LLC.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <string.h>
+
+void *
+memmem(const void *block, size_t blen, const void *pat, size_t plen)
+{
+	const unsigned char *bp, *pp, *endp;
+
+	assert(block != NULL);
+	assert(pat != NULL);
+
+	/*
+	 * Following the precedent in ststr(3) and glibc, a zero
+	 * length pattern matches the start of block.
+	 */
+	if (plen == 0)
+		return (void*) block;
+
+	if (blen < plen)
+		return NULL;
+
+	bp = block;
+	pp = pat;
+	endp = bp + (blen - plen) + 1;
+
+	/*
+	 * As a cheezy optimization, check that the first chars are
+	 * the same before calling memcmp. Really we should use bm(3)
+	 * to speed this up if blen is large enough.
+	 */
+	while (bp < endp) {
+		if ((*bp == *pp) && (memcmp(bp, pp, plen) == 0))
+			return (void *) bp;
+		bp++;
+	}
+
+	return NULL;
+}
diff --git a/third_party/memrchr.c b/third_party/memrchr.c
new file mode 100644
index 0000000000000000000000000000000000000000..ef6d89b947e5bfe78b7416ac6848b7c1379d73fc
--- /dev/null
+++ b/third_party/memrchr.c
@@ -0,0 +1,49 @@
+/*	$NetBSD: memrchr.c,v 1.2 2009/04/11 21:42:16 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <assert.h>
+#include <string.h>
+
+void *
+memrchr(const void *s, int c, size_t n)
+{
+	assert(s != NULL);
+
+	if (n != 0) {
+		const unsigned char *p = (const unsigned char *)s + n;
+		const unsigned char cmp = c;
+
+		do {
+			if (*--p == cmp)
+				return (void *) p;
+		} while (--n != 0);
+	}
+	return NULL;
+}