diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2012-06-15 20:50:07 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2012-06-15 20:50:07 +0000 |
commit | 2523715546eebb7c25cd1d9e2271a41b60a7e69e (patch) | |
tree | b353d7c4ac7217e60e0e0da465046a81a1fe8a5f /regress/libexec/ld.so | |
parent | 9325fa5fcb7abe157ee7dcf0bdd7dc39c30b4093 (diff) |
Add a regress test for ld.so's DF_1_NOOPEN support.
Diffstat (limited to 'regress/libexec/ld.so')
-rw-r--r-- | regress/libexec/ld.so/Makefile | 3 | ||||
-rw-r--r-- | regress/libexec/ld.so/df_1_noopen/Makefile | 30 | ||||
-rw-r--r-- | regress/libexec/ld.so/df_1_noopen/dlopen.c | 19 | ||||
-rwxr-xr-x | regress/libexec/ld.so/df_1_noopen/test.sh | 29 |
4 files changed, 80 insertions, 1 deletions
diff --git a/regress/libexec/ld.so/Makefile b/regress/libexec/ld.so/Makefile index 71639d2ca31..bb574889776 100644 --- a/regress/libexec/ld.so/Makefile +++ b/regress/libexec/ld.so/Makefile @@ -1,8 +1,9 @@ -# $OpenBSD: Makefile,v 1.11 2011/11/29 04:38:37 kurt Exp $ +# $OpenBSD: Makefile,v 1.12 2012/06/15 20:50:06 matthew Exp $ SUBDIR+= elf hidden weak dlsym dlopen dlclose lazy #SUBDIR+= constructor SUBDIR+= link-order edgecases initfirst +SUBDIR+= df_1_noopen install: diff --git a/regress/libexec/ld.so/df_1_noopen/Makefile b/regress/libexec/ld.so/df_1_noopen/Makefile new file mode 100644 index 00000000000..8bdaa45f49a --- /dev/null +++ b/regress/libexec/ld.so/df_1_noopen/Makefile @@ -0,0 +1,30 @@ +# $OpenBSD: Makefile,v 1.1 2012/06/15 20:50:06 matthew Exp $ + +REGRESS_TARGETS = test + +.PHONY: test +test: lib1.so lib2.so lib3.so dlopen dlopen1 dlopen2 dlopen3 + ./test.sh + +lib1.so: + cc -o lib1.so /dev/null -fPIC -shared -Wl,-znodlopen + +lib2.so: + cc -o lib2.so /dev/null -fPIC -shared -L. -l1 + +lib3.so: + cc -o lib3.so /dev/null -fPIC -shared -L. -l2 + +dlopen: dlopen.c + cc -o dlopen dlopen.c + +dlopen1: dlopen.c + cc -o dlopen1 dlopen.c -L. -l1 + +dlopen2: dlopen.c + cc -o dlopen2 dlopen.c -L. -l2 + +dlopen3: dlopen.c + cc -o dlopen3 dlopen.c -L. -l3 + +.include <bsd.regress.mk> diff --git a/regress/libexec/ld.so/df_1_noopen/dlopen.c b/regress/libexec/ld.so/df_1_noopen/dlopen.c new file mode 100644 index 00000000000..12645cb22e0 --- /dev/null +++ b/regress/libexec/ld.so/df_1_noopen/dlopen.c @@ -0,0 +1,19 @@ +/* $OpenBSD: dlopen.c,v 1.1 2012/06/15 20:50:06 matthew Exp $ */ + +#include <stdio.h> +#include <dlfcn.h> + +int +main(int argc, char *argv[]) +{ + int i; + void *p; + + for (i = 1; i < argc; i++) { + p = dlopen(argv[i] + 1, RTLD_LAZY|RTLD_LOCAL); + if ((p != NULL) != (argv[i][0] == '+')) + return (1); + } + + return (0); +} diff --git a/regress/libexec/ld.so/df_1_noopen/test.sh b/regress/libexec/ld.so/df_1_noopen/test.sh new file mode 100755 index 00000000000..f007777432b --- /dev/null +++ b/regress/libexec/ld.so/df_1_noopen/test.sh @@ -0,0 +1,29 @@ +#!/bin/sh -ex +# $OpenBSD: test.sh,v 1.1 2012/06/15 20:50:06 matthew Exp $ + +export LD_LIBRARY_PATH=. +export LD_TRACE_LOADED_OBJECTS_FMT1='lib%o.so\n' +export LD_TRACE_LOADED_OBJECTS_FMT2='%o\n' + +res=0 + +test() { + if "$@"; then + echo "passed" + else + echo "FAILED" + res=1 + fi +} + +for i in 1 2 3; do + test ldd lib${i}.so + test ./dlopen -lib${i}.so + + for j in 1 2 3; do + test env LD_PRELOAD=lib${j}.so ./dlopen +lib${i}.so + test ./dlopen${j} +lib${i}.so + done +done + +exit $res |