Index: .bzrignore
===================================================================
--- .bzrignore	(revision b0e014061cbe1c8f1aa804f8e1a40344f95c6af1)
+++ .bzrignore	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -34,4 +34,5 @@
 uspace/app/date/date
 uspace/app/devctl/devctl
+uspace/app/dltest/dltest
 uspace/app/dnscfg/dnscfg
 uspace/app/dnsres/dnsres
@@ -94,4 +95,5 @@
 uspace/dist/app/date
 uspace/dist/app/devctl
+uspace/dist/app/dltest
 uspace/dist/app/dnscfg
 uspace/dist/app/dnsres
Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision b0e014061cbe1c8f1aa804f8e1a40344f95c6af1)
+++ boot/Makefile.common	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -160,7 +160,6 @@
 		$(USPACE_PATH)/lib/c/libc.so.0 \
 		$(USPACE_PATH)/lib/softint/libsoftint.so.0 \
-		$(USPACE_PATH)/lib/math/libmath.so.0
-	RD_APPS += \
-		$(USPACE_PATH)/app/dltest/dltest
+		$(USPACE_PATH)/lib/math/libmath.so.0 \
+		$(USPACE_PATH)/lib/dltest/libdltest.so.0
 endif
 
@@ -225,4 +224,9 @@
 	$(USPACE_PATH)/app/wifi_supplicant/wifi_supplicant
 
+ifeq ($(CONFIG_BUILD_SHARED_LIBS), y)
+	RD_APPS_NON_ESSENTIAL += \
+		$(USPACE_PATH)/app/dltest/dltest
+endif
+
 RD_TESTS = \
 	$(USPACE_PATH)/lib/c/test-libc \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision b0e014061cbe1c8f1aa804f8e1a40344f95c6af1)
+++ uspace/Makefile	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -41,4 +41,5 @@
 	app/corecfg \
 	app/devctl \
+	app/dltest \
 	app/dnscfg \
 	app/dnsres \
@@ -219,4 +220,5 @@
 	lib/crypto \
 	lib/clui \
+	lib/dltest \
 	lib/fdisk \
 	lib/fmtutil \
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision b0e014061cbe1c8f1aa804f8e1a40344f95c6af1)
+++ uspace/Makefile.common	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -148,4 +148,5 @@
 LIBMINIX_PREFIX = $(LIB_PREFIX)/minix
 LIBCOMPRESS_PREFIX = $(LIB_PREFIX)/compress
+LIBDLTEST_PREFIX = $(LIB_PREFIX)/dltest
 
 LIBSCSI_PREFIX = $(LIB_PREFIX)/scsi
Index: uspace/app/dltest/Makefile
===================================================================
--- uspace/app/dltest/Makefile	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
+++ uspace/app/dltest/Makefile	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2016 Jiri Svoboda
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+#
+
+USPACE_PREFIX = ../..
+EXTRA_CFLAGS = -I$(LIBDLTEST_PREFIX)
+BINARY = dltest
+
+SOURCES = \
+	dltest.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/dltest/dltest.c
===================================================================
--- uspace/app/dltest/dltest.c	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
+++ uspace/app/dltest/dltest.c	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2016 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/** @addtogroup dltest
+ * @{
+ */
+
+/**
+ * @file
+ * @brief	Test dynamic linking
+ */
+
+#include <dlfcn.h>
+#include <libdltest.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/** libdltest library handle */
+void *handle;
+
+/** Test dlsym() function */
+static bool test_dlsym(void)
+{
+	int (*p_dl_get_constant)(void);
+
+	printf("dlsym()... ");
+	p_dl_get_constant = dlsym(handle, "dl_get_constant");
+	if (p_dl_get_constant == NULL) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	printf("Passed\n");
+	return true;
+}
+
+/** Test calling function that returns a constant */
+static bool test_dlfcn_dl_get_constant(void)
+{
+	int (*p_dl_get_constant)(void);
+	int val;
+
+	printf("Call dlsym/dl_get_constant...\n");
+
+	p_dl_get_constant = dlsym(handle, "dl_get_constant");
+	if (p_dl_get_constant == NULL) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	val = p_dl_get_constant();
+
+	printf("Got %d, expected %d... ", val, dl_constant);
+	if (val != dl_constant) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	printf("Passed\n");
+	return true;
+}
+
+/** Test calling a function that returns contents of a private initialized
+ * variable.
+ */
+static bool test_dlfcn_dl_get_private_var(void)
+{
+	int (*p_dl_get_private_var)(void);
+	int val;
+
+	printf("Call dlsym/dl_get_private_var...\n");
+
+	p_dl_get_private_var = dlsym(handle, "dl_get_private_var");
+	if (p_dl_get_private_var == NULL) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	val = p_dl_get_private_var();
+
+	printf("Got %d, expected %d... ", val, dl_private_var_val);
+	if (val != dl_private_var_val) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	printf("Passed\n");
+	return true;
+}
+
+/** Test calling a function that returns contents of a private uninitialized
+ * variable.
+ */
+static bool test_dlfcn_dl_get_private_uvar(void)
+{
+	int (*p_dl_get_private_uvar)(void);
+	int val;
+
+	printf("Call dlsym/dl_get_private_uvar...\n");
+
+	p_dl_get_private_uvar = dlsym(handle, "dl_get_private_uvar");
+	if (p_dl_get_private_uvar == NULL) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	val = p_dl_get_private_uvar();
+
+	printf("Got %d, expected %d... ", val, 0);
+	if (val != 0) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	printf("Passed\n");
+	return true;
+}
+
+/** Test calling a function that returns the contents of a public initialized
+ * variable.
+ */
+static bool test_dlfcn_dl_get_public_var(void)
+{
+	int (*p_dl_get_public_var)(void);
+	int val;
+
+	printf("Call dlsym/dl_get_public_var...\n");
+
+	p_dl_get_public_var = dlsym(handle, "dl_get_public_var");
+	if (p_dl_get_public_var == NULL) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	val = p_dl_get_public_var();
+
+	printf("Got %d, expected %d... ", val, dl_public_var_val);
+	if (val != dl_public_var_val) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	printf("Passed\n");
+	return true;
+}
+
+/** Test calling a function that returns the contents of a public uninitialized
+ * variable.
+ */
+static bool test_dlfcn_dl_get_public_uvar(void)
+{
+	int (*p_dl_get_public_uvar)(void);
+	int val;
+
+	printf("Call dlsym/dl_get_public_uvar...\n");
+
+	p_dl_get_public_uvar = dlsym(handle, "dl_get_public_uvar");
+	if (p_dl_get_public_uvar == NULL) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	val = p_dl_get_public_uvar();
+
+	printf("Got %d, expected %d... ", val, 0);
+	if (val != 0) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	printf("Passed\n");
+	return true;
+}
+
+/** Test directly reading a public initialized variable whose address was
+ * obtained using dlsym.
+ */
+static bool test_dlfcn_read_public_var(void)
+{
+	int *p_dl_public_var;
+	int val;
+
+	printf("Read dlsym/dl_public_var...\n");
+
+	p_dl_public_var = dlsym(handle, "dl_public_var");
+	if (p_dl_public_var == NULL) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	val = *p_dl_public_var;
+
+	printf("Got %d, expected %d... ", val, dl_public_var_val);
+	if (val != dl_public_var_val) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	printf("Passed\n");
+	return true;
+}
+
+/** Test directly reading a public uninitialized variable whose address was
+ * obtained using dlsym.
+ */
+static bool test_dlfcn_read_public_uvar(void)
+{
+	int *p_dl_public_uvar;
+	int val;
+
+	printf("Read dlsym/dl_public_uvar...\n");
+
+	p_dl_public_uvar = dlsym(handle, "dl_public_uvar");
+	if (p_dl_public_uvar == NULL) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	val = *p_dl_public_uvar;
+
+	printf("Got %d, expected %d... ", val, 0);
+	if (val != 0) {
+		printf("FAILED\n");
+		return false;
+	}
+
+	printf("Passed\n");
+	return true;
+}
+
+int main(int argc, char *argv[])
+{
+
+	printf("Dynamic linking test\n");
+
+	printf("dlopen()... ");
+	handle = dlopen("libdltest.so.0", 0);
+	if (handle == NULL) {
+		printf("FAILED\n");
+		return 1;
+	}
+
+	printf("Passed\n");
+
+	if (!test_dlsym())
+		return 1;
+
+	if (!test_dlfcn_dl_get_constant())
+		return 1;
+
+	if (!test_dlfcn_dl_get_private_var())
+		return 1;
+
+	if (!test_dlfcn_dl_get_private_uvar())
+		return 1;
+
+	if (!test_dlfcn_dl_get_public_var())
+		return 1;
+
+	if (!test_dlfcn_dl_get_public_uvar())
+		return 1;
+
+	if (!test_dlfcn_read_public_var())
+		return 1;
+
+	if (!test_dlfcn_read_public_uvar())
+		return 1;
+
+//	printf("dlclose()... ");
+//	dlclose(handle);
+//	printf("Passed\n");
+
+	printf("All passed.\n");
+	return 0;
+}
+
+/**
+ * @}
+ */
Index: uspace/lib/dltest/Makefile
===================================================================
--- uspace/lib/dltest/Makefile	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
+++ uspace/lib/dltest/Makefile	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2016 Jiri Svoboda
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+#
+
+USPACE_PREFIX = ../..
+LIBRARY = libdltest
+SLIBRARY = libdltest.so.0.0
+LSONAME = libdltest.so.0
+
+SOURCES = \
+	dltest.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/dltest/dltest.c
===================================================================
--- uspace/lib/dltest/dltest.c	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
+++ uspace/lib/dltest/dltest.c	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/** @addtogroup libdltest
+ * @brief Dynamic linking test library
+ * @{
+ */
+/** @file
+ */
+
+#include "libdltest.h"
+
+/** Private initialized variable */
+static int private_var = dl_private_var_val;
+/** Private uninitialized variable */
+static int private_uvar;
+
+/** Public initialized variable */
+int dl_public_var = dl_public_var_val;
+/** Public uninitialized variable */
+int dl_public_uvar;
+
+/** Return constant value. */
+int dl_get_constant(void)
+{
+	return dl_constant;
+}
+
+/** Return value of private initialized variable */
+int dl_get_private_var(void)
+{
+	return private_var;
+}
+
+/** Return value of private uninitialized variable */
+int dl_get_private_uvar(void)
+{
+	return private_uvar;
+}
+
+/** Return value of public initialized variable */
+int dl_get_public_var(void)
+{
+	return dl_public_var;
+}
+
+/** Return value of public uninitialized variable */
+int dl_get_public_uvar(void)
+{
+	return dl_public_uvar;
+}
+
+/**
+ * @}
+ */
Index: uspace/lib/dltest/libdltest.h
===================================================================
--- uspace/lib/dltest/libdltest.h	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
+++ uspace/lib/dltest/libdltest.h	(revision 9182e86f8fac41203c8da4e3158cbf2b160dc738)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/** @addtogroup libdltest
+ * @brief Dynamic linking test library
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBDLTEST_H
+#define LIBDLTEST_H
+
+enum {
+	dl_constant = 110011,
+	dl_private_var_val = 220022,
+	dl_public_var_val = 330033
+};
+
+extern int dl_get_constant(void);
+extern int dl_get_private_var(void);
+extern int dl_get_private_uvar(void);
+extern int dl_get_public_var(void);
+extern int dl_get_public_uvar(void);
+
+extern int dl_public_var;
+extern int dl_public_uvar;
+
+#endif
+
+/**
+ * @}
+ */
