diff options
author | Kurt Miller <kurt@cvs.openbsd.org> | 2005-09-19 03:23:52 +0000 |
---|---|---|
committer | Kurt Miller <kurt@cvs.openbsd.org> | 2005-09-19 03:23:52 +0000 |
commit | adcc7f994570510e8a127c4a52aff90faaef3dbe (patch) | |
tree | 3339e00dee65b49f5dc3102965cbdf1303845324 | |
parent | 2cc6b9365ba69f6e7a786a57d0b5cdc3a2d5b6df (diff) |
confirm DT_NEEDED libs gets promoted to RTLD_GLOBAL when parent gets
dlopened with RTLD_GLOBAL
-rw-r--r-- | regress/libexec/ld.so/dlsym/test2/prog5/Makefile | 12 | ||||
-rw-r--r-- | regress/libexec/ld.so/dlsym/test2/prog5/main.c | 55 |
2 files changed, 67 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/dlsym/test2/prog5/Makefile b/regress/libexec/ld.so/dlsym/test2/prog5/Makefile new file mode 100644 index 00000000000..d57037b5098 --- /dev/null +++ b/regress/libexec/ld.so/dlsym/test2/prog5/Makefile @@ -0,0 +1,12 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2005/09/19 03:23:51 kurt Exp $ + +PROG= prog5 +SRCS= main.c +LDADD+= -laa +LDFLAGS+= -Wl,-E +LDFLAGS+= -Wl,-rpath,$(AA_OBJDIR) +LDFLAGS+= -Wl,-rpath,$(BB_OBJDIR) +LDFLAGS+= -Wl,-rpath,$(CC_OBJDIR) +LDFLAGS+= -L$(AA_OBJDIR) + +.include <bsd.regress.mk> diff --git a/regress/libexec/ld.so/dlsym/test2/prog5/main.c b/regress/libexec/ld.so/dlsym/test2/prog5/main.c new file mode 100644 index 00000000000..eb0836fbaa3 --- /dev/null +++ b/regress/libexec/ld.so/dlsym/test2/prog5/main.c @@ -0,0 +1,55 @@ +/* $OpenBSD: main.c,v 1.1.1.1 2005/09/19 03:23:51 kurt Exp $ */ + +/* + * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <dlfcn.h> +#include <stdio.h> + +int mainSymbol; + +/* + * confirm that libcc gets promoted to RTLD_GLOBAL when opened as part of + * libbb with RTLD_GLOBAL + */ +int +main() +{ + int ret = 0; + void *libcc = dlopen("libcc.so", RTLD_LAZY); + void *libbb = dlopen("libbb.so", RTLD_LAZY|RTLD_GLOBAL); + + if (libbb == NULL) { + printf("dlopen(\"libbb.so\", RTLD_LAZY) FAILED\n"); + return (1); + } + + if (libcc == NULL) { + printf("dlopen(\"libcc.so\", RTLD_LAZY) FAILED\n"); + return (1); + } + + /* RTLD_DEFAULT should see ccSymbol */ + if (dlsym(RTLD_DEFAULT, "ccSymbol") == NULL) { + printf("dlsym(RTLD_DEFAULT, \"ccSymbol\") == NULL\n"); + ret = 1; + } + + dlclose(libbb); + dlclose(libcc); + + return (ret); +} |