mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
regression test for lazy binding.
"people need never hold off on adding stuff to regress" deraadt@
This commit is contained in:
parent
f1a76e771b
commit
20dfae2598
7
regress/libexec/ld.so/lazy/Makefile
Normal file
7
regress/libexec/ld.so/lazy/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2008/01/02 18:36:59 matthieu Exp $
|
||||
|
||||
SUBDIR += libfoo libbar prog
|
||||
|
||||
install:
|
||||
|
||||
.include <bsd.subdir.mk>
|
8
regress/libexec/ld.so/lazy/libbar/Makefile
Normal file
8
regress/libexec/ld.so/lazy/libbar/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2008/01/02 18:36:59 matthieu Exp $
|
||||
|
||||
LIB= bar
|
||||
SRCS= bar.c
|
||||
|
||||
regress: all
|
||||
|
||||
.include <bsd.lib.mk>
|
11
regress/libexec/ld.so/lazy/libbar/bar.c
Normal file
11
regress/libexec/ld.so/lazy/libbar/bar.c
Normal file
@ -0,0 +1,11 @@
|
||||
/* $OpenBSD: bar.c,v 1.1.1.1 2008/01/02 18:36:59 matthieu Exp $ */
|
||||
/* Public Domain, 2008, Matthieu Herrb */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
bar(void)
|
||||
{
|
||||
printf("bar\n");
|
||||
return 0;
|
||||
}
|
2
regress/libexec/ld.so/lazy/libbar/shlib_version
Normal file
2
regress/libexec/ld.so/lazy/libbar/shlib_version
Normal file
@ -0,0 +1,2 @@
|
||||
major=0
|
||||
minor=0
|
18
regress/libexec/ld.so/lazy/libfoo/Makefile
Normal file
18
regress/libexec/ld.so/lazy/libfoo/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2008/01/02 18:36:59 matthieu Exp $
|
||||
|
||||
.include <bsd.obj.mk>
|
||||
|
||||
LIB= foo
|
||||
SRCS= foo.c
|
||||
|
||||
BARDIR!= if test -d ${.CURDIR}/../libbar/${__objdir}; then \
|
||||
echo "${.CURDIR}/../libbar/${__objdir}"; \
|
||||
else \
|
||||
echo "${.CURDIR}/../libbar"; \
|
||||
fi
|
||||
|
||||
CPPFLAGS= -DBAR=\"${BARDIR}/libbar.so\"
|
||||
|
||||
regress: all
|
||||
|
||||
.include <bsd.lib.mk>
|
26
regress/libexec/ld.so/lazy/libfoo/foo.c
Normal file
26
regress/libexec/ld.so/lazy/libfoo/foo.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* $OpenBSD: foo.c,v 1.1.1.1 2008/01/02 18:36:59 matthieu Exp $ */
|
||||
/* Public domain. 2008, Matthieu Herrb */
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void *h = NULL;
|
||||
|
||||
void
|
||||
foo_init(void)
|
||||
{
|
||||
printf("loading %s\n", BAR);
|
||||
h = dlopen(BAR, RTLD_LAZY|RTLD_GLOBAL);
|
||||
if (h == NULL)
|
||||
errx(1, "dlopen %s: %s\n", BAR, dlerror());
|
||||
printf("loaded: %s\n", BAR);
|
||||
}
|
||||
|
||||
int
|
||||
foo(void)
|
||||
{
|
||||
if (h == NULL)
|
||||
foo_init();
|
||||
|
||||
return bar();
|
||||
}
|
2
regress/libexec/ld.so/lazy/libfoo/shlib_version
Normal file
2
regress/libexec/ld.so/lazy/libfoo/shlib_version
Normal file
@ -0,0 +1,2 @@
|
||||
major=0
|
||||
minor=0
|
15
regress/libexec/ld.so/lazy/prog/Makefile
Normal file
15
regress/libexec/ld.so/lazy/prog/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2008/01/02 18:36:59 matthieu Exp $
|
||||
|
||||
.include <bsd.obj.mk>
|
||||
|
||||
PROG= prog
|
||||
|
||||
FOODIR!= if test -d ${.CURDIR}/../libfoo/${__objdir}; then \
|
||||
echo "${.CURDIR}/../libfoo/${__objdir}"; \
|
||||
else \
|
||||
echo "${.CURDIR}/../libfoo"; \
|
||||
fi
|
||||
|
||||
CPPFLAGS= -DFOO=\"${FOODIR}/libfoo.so\"
|
||||
|
||||
.include <bsd.regress.mk>
|
29
regress/libexec/ld.so/lazy/prog/prog.c
Normal file
29
regress/libexec/ld.so/lazy/prog/prog.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* $OpenBSD: prog.c,v 1.1.1.1 2008/01/02 18:36:59 matthieu Exp $ */
|
||||
/* Public Domain, 2008, Matthieu Herrb */
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void *handle = NULL;
|
||||
|
||||
typedef int (*foofunc)(void);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
foofunc foo;
|
||||
int i;
|
||||
|
||||
printf("loading: %s\n", FOO);
|
||||
handle = dlopen(FOO, RTLD_LAZY|RTLD_GLOBAL);
|
||||
if (handle == NULL) {
|
||||
errx(1, "dlopen: %s: %s\n", FOO, dlerror());
|
||||
}
|
||||
printf("loaded: %s\n", FOO);
|
||||
printf("looking up foo\n");
|
||||
foo = (foofunc)dlsym(handle, "foo");
|
||||
printf("found %p - calling it\n", foo);
|
||||
i = foo();
|
||||
printf("done.\n");
|
||||
exit(i);
|
||||
}
|
Loading…
Reference in New Issue
Block a user