diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2014-09-07 04:13:53 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2014-09-07 04:13:53 +0000 |
commit | 1ae3378b2c3b8d1cf09fae352b1c179518c7a7a8 (patch) | |
tree | 0061b9d84cda76259d895faae021d036dbfe69a5 | |
parent | c6907c0e0294433b91c760e5eb6f8d724e74dd98 (diff) |
Add dependency tests from Henri Kemppainen (duclare (at) guu.fi).
order1 demonstrates why the fix in ld.so/library_subr.c rev 1.34 is necessary
order2 demonstrates that that fix isn't completely correct
21 files changed, 208 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/dependencies/Makefile b/regress/libexec/ld.so/dependencies/Makefile new file mode 100644 index 00000000000..e8ece1a732b --- /dev/null +++ b/regress/libexec/ld.so/dependencies/Makefile @@ -0,0 +1,8 @@ +# $OpenBSD: Makefile,v 1.1 2014/09/07 04:13:52 guenther Exp $ + +SUBDIR+= order1 +#SUBDIR+= order2 + +install: + +.include <bsd.subdir.mk> diff --git a/regress/libexec/ld.so/dependencies/order1/Makefile b/regress/libexec/ld.so/dependencies/order1/Makefile new file mode 100644 index 00000000000..c10196f4e4d --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/Makefile @@ -0,0 +1,4 @@ +SUBDIR+= libbb libaa prog1 + +.include <bsd.subdir.mk> + diff --git a/regress/libexec/ld.so/dependencies/order1/Makefile.inc b/regress/libexec/ld.so/dependencies/order1/Makefile.inc new file mode 100644 index 00000000000..9519055ad36 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/Makefile.inc @@ -0,0 +1,18 @@ +.include <bsd.obj.mk> + +AA_DIR=${.CURDIR}/../libaa + +AA_OBJDIR!= if [ -d $(AA_DIR)/${__objdir} ]; then \ + echo "$(AA_DIR)/${__objdir}"; \ + else \ + echo "$(AA_DIR)"; \ + fi + +BB_DIR=${.CURDIR}/../libbb + +BB_OBJDIR!= if [ -d $(BB_DIR)/${__objdir} ]; then \ + echo "$(BB_DIR)/${__objdir}"; \ + else \ + echo "$(BB_DIR)"; \ + fi + diff --git a/regress/libexec/ld.so/dependencies/order1/libaa/Makefile b/regress/libexec/ld.so/dependencies/order1/libaa/Makefile new file mode 100644 index 00000000000..bec4feb9411 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/libaa/Makefile @@ -0,0 +1,10 @@ +LIB= aa +SRCS= aa.c +LDADD+= -Wl,-E +LDADD+= -Wl,-rpath,$(BB_OBJDIR) +LDADD+= -L$(BB_OBJDIR) -lbb + +regress: all + +.include <bsd.lib.mk> + diff --git a/regress/libexec/ld.so/dependencies/order1/libaa/aa.c b/regress/libexec/ld.so/dependencies/order1/libaa/aa.c new file mode 100644 index 00000000000..0440d470f3a --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/libaa/aa.c @@ -0,0 +1,7 @@ +extern int symbb; + +int funaa(void) +{ + return 1 + symbb; +} + diff --git a/regress/libexec/ld.so/dependencies/order1/libaa/shlib_version b/regress/libexec/ld.so/dependencies/order1/libaa/shlib_version new file mode 100644 index 00000000000..1edea46de91 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/libaa/shlib_version @@ -0,0 +1,2 @@ +major=1 +minor=0 diff --git a/regress/libexec/ld.so/dependencies/order1/libbb/Makefile b/regress/libexec/ld.so/dependencies/order1/libbb/Makefile new file mode 100644 index 00000000000..35ea6a3fa3f --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/libbb/Makefile @@ -0,0 +1,7 @@ +LIB= bb +SRCS= bb.c + +regress: all + +.include <bsd.lib.mk> + diff --git a/regress/libexec/ld.so/dependencies/order1/libbb/bb.c b/regress/libexec/ld.so/dependencies/order1/libbb/bb.c new file mode 100644 index 00000000000..73bc7c2e3d0 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/libbb/bb.c @@ -0,0 +1,2 @@ +int symbb; + diff --git a/regress/libexec/ld.so/dependencies/order1/libbb/shlib_version b/regress/libexec/ld.so/dependencies/order1/libbb/shlib_version new file mode 100644 index 00000000000..1edea46de91 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/libbb/shlib_version @@ -0,0 +1,2 @@ +major=1 +minor=0 diff --git a/regress/libexec/ld.so/dependencies/order1/prog1/Makefile b/regress/libexec/ld.so/dependencies/order1/prog1/Makefile new file mode 100644 index 00000000000..fad55f82d1a --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/prog1/Makefile @@ -0,0 +1,8 @@ +PROG= prog1 +SRCS= main.c +LDFLAGS+= -Wl,-E +LDFLAGS+= -Wl,-rpath,$(AA_OBJDIR) +LDFLAGS+= -Wl,-rpath,$(BB_OBJDIR) + +.include <bsd.regress.mk> + diff --git a/regress/libexec/ld.so/dependencies/order1/prog1/main.c b/regress/libexec/ld.so/dependencies/order1/prog1/main.c new file mode 100644 index 00000000000..860e1a39eae --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order1/prog1/main.c @@ -0,0 +1,42 @@ +#include <dlfcn.h> +#include <stdio.h> + +int +main() +{ + void *libaa, *libbb; + int flag = RTLD_NOW; + + if ((libaa = dlopen("libaa.so", flag)) == NULL) { + printf("dlopen(\"libaa.so\", %d) FAILED\n", flag); + return 1; + } + + if ((libbb = dlopen("libbb.so", flag)) == NULL) { + printf("dlopen(\"libbb.so\", %d) FAILED\n", flag); + return 1; + } + + if (dlclose(libbb)) { + printf("dlclose(libbb) FAILED\n%s\n", dlerror()); + return 1; + } + + if ((libbb = dlopen("libbb.so", flag)) == NULL) { + printf("dlopen(\"libbb.so\", %d) FAILED\n", flag); + return 1; + } + + if (dlclose(libbb)) { + printf("dlclose(libbb) FAILED\n%s\n", dlerror()); + return 1; + } + + if (dlclose(libaa)) { + printf("dlclose(libaa) FAILED\n%s\n", dlerror()); + return 1; + } + + return 0; +} + diff --git a/regress/libexec/ld.so/dependencies/order2/Makefile b/regress/libexec/ld.so/dependencies/order2/Makefile new file mode 100644 index 00000000000..c10196f4e4d --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/Makefile @@ -0,0 +1,4 @@ +SUBDIR+= libbb libaa prog1 + +.include <bsd.subdir.mk> + diff --git a/regress/libexec/ld.so/dependencies/order2/Makefile.inc b/regress/libexec/ld.so/dependencies/order2/Makefile.inc new file mode 100644 index 00000000000..9519055ad36 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/Makefile.inc @@ -0,0 +1,18 @@ +.include <bsd.obj.mk> + +AA_DIR=${.CURDIR}/../libaa + +AA_OBJDIR!= if [ -d $(AA_DIR)/${__objdir} ]; then \ + echo "$(AA_DIR)/${__objdir}"; \ + else \ + echo "$(AA_DIR)"; \ + fi + +BB_DIR=${.CURDIR}/../libbb + +BB_OBJDIR!= if [ -d $(BB_DIR)/${__objdir} ]; then \ + echo "$(BB_DIR)/${__objdir}"; \ + else \ + echo "$(BB_DIR)"; \ + fi + diff --git a/regress/libexec/ld.so/dependencies/order2/libaa/Makefile b/regress/libexec/ld.so/dependencies/order2/libaa/Makefile new file mode 100644 index 00000000000..bec4feb9411 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/libaa/Makefile @@ -0,0 +1,10 @@ +LIB= aa +SRCS= aa.c +LDADD+= -Wl,-E +LDADD+= -Wl,-rpath,$(BB_OBJDIR) +LDADD+= -L$(BB_OBJDIR) -lbb + +regress: all + +.include <bsd.lib.mk> + diff --git a/regress/libexec/ld.so/dependencies/order2/libaa/aa.c b/regress/libexec/ld.so/dependencies/order2/libaa/aa.c new file mode 100644 index 00000000000..0440d470f3a --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/libaa/aa.c @@ -0,0 +1,7 @@ +extern int symbb; + +int funaa(void) +{ + return 1 + symbb; +} + diff --git a/regress/libexec/ld.so/dependencies/order2/libaa/shlib_version b/regress/libexec/ld.so/dependencies/order2/libaa/shlib_version new file mode 100644 index 00000000000..1edea46de91 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/libaa/shlib_version @@ -0,0 +1,2 @@ +major=1 +minor=0 diff --git a/regress/libexec/ld.so/dependencies/order2/libbb/Makefile b/regress/libexec/ld.so/dependencies/order2/libbb/Makefile new file mode 100644 index 00000000000..35ea6a3fa3f --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/libbb/Makefile @@ -0,0 +1,7 @@ +LIB= bb +SRCS= bb.c + +regress: all + +.include <bsd.lib.mk> + diff --git a/regress/libexec/ld.so/dependencies/order2/libbb/bb.c b/regress/libexec/ld.so/dependencies/order2/libbb/bb.c new file mode 100644 index 00000000000..73bc7c2e3d0 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/libbb/bb.c @@ -0,0 +1,2 @@ +int symbb; + diff --git a/regress/libexec/ld.so/dependencies/order2/libbb/shlib_version b/regress/libexec/ld.so/dependencies/order2/libbb/shlib_version new file mode 100644 index 00000000000..1edea46de91 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/libbb/shlib_version @@ -0,0 +1,2 @@ +major=1 +minor=0 diff --git a/regress/libexec/ld.so/dependencies/order2/prog1/Makefile b/regress/libexec/ld.so/dependencies/order2/prog1/Makefile new file mode 100644 index 00000000000..fad55f82d1a --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/prog1/Makefile @@ -0,0 +1,8 @@ +PROG= prog1 +SRCS= main.c +LDFLAGS+= -Wl,-E +LDFLAGS+= -Wl,-rpath,$(AA_OBJDIR) +LDFLAGS+= -Wl,-rpath,$(BB_OBJDIR) + +.include <bsd.regress.mk> + diff --git a/regress/libexec/ld.so/dependencies/order2/prog1/main.c b/regress/libexec/ld.so/dependencies/order2/prog1/main.c new file mode 100644 index 00000000000..c21c4e10241 --- /dev/null +++ b/regress/libexec/ld.so/dependencies/order2/prog1/main.c @@ -0,0 +1,38 @@ +#include <dlfcn.h> +#include <stdio.h> + +int +main() +{ + void *libaa, *libbb; + int flag = RTLD_NOW; + + if ((libaa = dlopen("libaa.so", flag)) == NULL) { + printf("dlopen(\"libaa.so\", %d) FAILED\n", flag); + return 1; + } + + if ((libbb = dlopen("libbb.so", flag)) == NULL) { + printf("dlopen(\"libbb.so\", %d) FAILED\n", flag); + return 1; + } + + if (dlclose(libaa)) { + printf("dlclose(libaa) FAILED\n%s\n", dlerror()); + return 1; + } + + if (dlclose(libbb)) { + printf("dlclose(libbb) FAILED\n%s\n", dlerror()); + return 1; + } + + if ((libaa = dlopen("libaa.so", flag)) == NULL) { + printf("dlopen(\"libaa.so\", %d) FAILED\n", flag); + return 1; + } + + + return 0; +} + |