Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wim Lewis
nettle
Commits
7123800a
Commit
7123800a
authored
Sep 02, 2015
by
Niels Möller
Browse files
New testcase using dlopen, and needed configure tests.
parent
7b1bb329
Changes
4
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
7123800a
2015-09-02 Niels Möller <nisse@lysator.liu.se>
* testsuite/dlopen-test.c: New test program, exposing the problem
with ifunc and RTLD_NOW.
* testsuite/Makefile.in (TS_ALL): Conditionally add dlopen-test.
(SOURCES): Added dlopen-test.c.
(dlopen-test): New target, unlike other test programs, *not*
linked with -lnettle.
* configure.ac: Check for dlfcn.h and the dlopen function.
(IF_DLOPEN_TEST): New substituted variable, true if dlopen is
available and we are building a shared library.
* fat-setup.h: Disable use of ifunc, since it breaks dlopen with
RTLD_NOW.
...
...
configure.ac
View file @
7123800a
...
...
@@ -189,7 +189,12 @@ AC_CHECK_HEADERS([openssl/blowfish.h openssl/des.h openssl/cast.h openssl/aes.h
[enable_openssl=no
break])
# For use by the testsuite
AC_CHECK_HEADERS([valgrind/memcheck.h])
AC_CHECK_HEADERS([dlfcn.h])
AC_CHECK_LIB([dl], [dlopen],
[AC_DEFINE([HAVE_LIBDL], 1,
[Define to 1 if you have dlopen (with -ldl).])])
LSH_FUNC_ALLOCA
LSH_FUNC_STRERROR
...
...
@@ -818,9 +823,13 @@ else
IF_STATIC='#'
fi
IF_DLOPEN_TEST='#'
if test "x$enable_shared" = xyes ; then
IF_SHARED=''
IF_NOT_SHARED='#'
if "x$ac_cv_lib_dl_dlopen" = yes ; then
IF_DLOPEN_TEST=''
fi
else
IF_SHARED='#'
IF_NOT_SHARED=''
...
...
@@ -858,6 +867,7 @@ AC_SUBST(IF_HOGWEED)
AC_SUBST(IF_STATIC)
AC_SUBST(IF_SHARED)
AC_SUBST(IF_NOT_SHARED)
AC_SUBST(IF_DLOPEN_TEST)
AC_SUBST(IF_DOCUMENTATION)
AC_SUBST(IF_DLL)
AC_SUBST(IF_MINI_GMP)
...
...
testsuite/Makefile.in
View file @
7123800a
...
...
@@ -57,12 +57,13 @@ TS_C = $(TS_NETTLE) @IF_HOGWEED@ $(TS_HOGWEED)
TS_CXX
=
@IF_CXX@
$
(
CXX_SOURCES:.cxx
=
$(EXEEXT)
)
TARGETS
=
$(TS_C)
$(TS_CXX)
TS_SH
=
sexp-conv-test pkcs1-conv-test nettle-pbkdf2-test symbols-test
TS_ALL
=
$(TARGETS)
$(TS_SH)
TS_ALL
=
$(TARGETS)
$(TS_SH)
@IF_DLOPEN_TEST@ dlopen-test
$(EXEEXT)
EXTRA_SOURCES
=
sha1-huge-test.c
EXTRA_TARGETS
=
$
(
EXTRA_SOURCES:.c
=
$(EXEEXT)
)
# Includes all C source files, regardless of configuration
SOURCES
=
$(TS_SOURCES)
$(EXTRA_SOURCES)
testutils.c
SOURCES
=
$(TS_SOURCES)
$(EXTRA_SOURCES)
testutils.c
dlopen-test.c
DISTFILES
=
$(SOURCES)
$(CXX_SOURCES)
Makefile.in .test-rules.make
\
$(TS_SH)
setup-env teardown-env
\
...
...
@@ -89,6 +90,10 @@ TEST_OBJS = testutils.$(OBJEXT) ../nettle-internal.$(OBJEXT) \
../nettle-internal.$(OBJEXT)
:
(
cd
..
&&
$(MAKE)
nettle-internal.
$(OBJEXT)
)
# Special target, to omit linking with libnettle
dlopen-test$(EXEEXT)
:
dlopen-test.$(OBJEXT) testutils.$(OBJEXT)
$(LINK)
dlopen-test.
$(OBJEXT)
-ldl
-o
dlopen-test
$(EXEEXT)
.PHONY
:
test-rules
test-rules
:
(
for
f
in
$(TS_NETTLE)
$(TS_HOGWEED)
$(EXTRA_TARGETS)
;
do
\
...
...
testsuite/dlopen-test.c
0 → 100644
View file @
7123800a
#include "testutils.h"
#include "version.h"
#if HAVE_DLFCN_H
#include <dlfcn.h>
#endif
int
main
(
int
argc
,
char
**
argv
)
{
#if HAVE_LIBDL
void
*
handle
=
dlopen
(
"../libnettle.so"
,
RTLD_NOW
);
int
(
*
get_version
)(
void
);
if
(
!
handle
)
{
fprintf
(
stderr
,
"dlopen failed: %s
\n
"
,
dlerror
());
FAIL
();
}
get_version
=
(
int
(
*
)(
void
))
dlsym
(
handle
,
"nettle_version_minor"
);
if
(
!
get_version
)
{
fprintf
(
stderr
,
"dlsym failed: %s
\n
"
,
dlerror
());
FAIL
();
}
if
(
get_version
()
!=
NETTLE_VERSION_MINOR
)
{
fprintf
(
stderr
,
"unexpected nettle version
\n
"
);
FAIL
();
}
return
EXIT_SUCCESS
;
#else
SKIP
();
#endif
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment