add ld.so RTLD_NOLOAD regress tests, ok jca@ guenther@
authorsthen <sthen@openbsd.org>
Sat, 20 Aug 2022 14:13:48 +0000 (14:13 +0000)
committersthen <sthen@openbsd.org>
Sat, 20 Aug 2022 14:13:48 +0000 (14:13 +0000)
regress/libexec/ld.so/Makefile
regress/libexec/ld.so/noload/Makefile [new file with mode: 0644]
regress/libexec/ld.so/noload/liba/Makefile [new file with mode: 0644]
regress/libexec/ld.so/noload/liba/liba.c [new file with mode: 0644]
regress/libexec/ld.so/noload/liba/shlib_version [new file with mode: 0644]
regress/libexec/ld.so/noload/libb/Makefile [new file with mode: 0644]
regress/libexec/ld.so/noload/libb/libb.c [new file with mode: 0644]
regress/libexec/ld.so/noload/libb/shlib_version [new file with mode: 0644]
regress/libexec/ld.so/noload/test1/Makefile [new file with mode: 0644]
regress/libexec/ld.so/noload/test1/test1.c [new file with mode: 0644]

index 1b169b5..e4c908d 100644 (file)
@@ -1,10 +1,10 @@
-#      $OpenBSD: Makefile,v 1.18 2021/06/02 07:32:34 semarie Exp $
+#      $OpenBSD: Makefile,v 1.19 2022/08/20 14:13:48 sthen Exp $
 
 SUBDIR+= elf hidden weak dlsym dlopen dlclose lazy
 SUBDIR+= constructor 
 SUBDIR+= link-order edgecases initfirst
 SUBDIR+= df_1_noopen randomdata subst dependencies
-SUBDIR+= init-env nodelete
+SUBDIR+= init-env nodelete noload
 
 install:
 
diff --git a/regress/libexec/ld.so/noload/Makefile b/regress/libexec/ld.so/noload/Makefile
new file mode 100644 (file)
index 0000000..913ea61
--- /dev/null
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2022/08/20 14:13:48 sthen Exp $
+
+SUBDIR +=      liba libb test1
+
+.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/noload/liba/Makefile b/regress/libexec/ld.so/noload/liba/Makefile
new file mode 100644 (file)
index 0000000..2329888
--- /dev/null
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2022/08/20 14:13:48 sthen Exp $
+
+LIB =  a
+SRCS = liba.c
+
+regress: all
+
+.include <bsd.lib.mk>
+
diff --git a/regress/libexec/ld.so/noload/liba/liba.c b/regress/libexec/ld.so/noload/liba/liba.c
new file mode 100644 (file)
index 0000000..bfe6c30
--- /dev/null
@@ -0,0 +1,4 @@
+void
+functiona(void)
+{
+}
diff --git a/regress/libexec/ld.so/noload/liba/shlib_version b/regress/libexec/ld.so/noload/liba/shlib_version
new file mode 100644 (file)
index 0000000..97c9f92
--- /dev/null
@@ -0,0 +1,2 @@
+major=0
+minor=0
diff --git a/regress/libexec/ld.so/noload/libb/Makefile b/regress/libexec/ld.so/noload/libb/Makefile
new file mode 100644 (file)
index 0000000..5933e46
--- /dev/null
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2022/08/20 14:13:48 sthen Exp $
+
+LIB =  b
+SRCS = libb.c
+
+regress: all
+
+.include <bsd.lib.mk>
+
diff --git a/regress/libexec/ld.so/noload/libb/libb.c b/regress/libexec/ld.so/noload/libb/libb.c
new file mode 100644 (file)
index 0000000..959caed
--- /dev/null
@@ -0,0 +1,4 @@
+void
+functionb(void)
+{
+}
diff --git a/regress/libexec/ld.so/noload/libb/shlib_version b/regress/libexec/ld.so/noload/libb/shlib_version
new file mode 100644 (file)
index 0000000..97c9f92
--- /dev/null
@@ -0,0 +1,2 @@
+major=0
+minor=0
diff --git a/regress/libexec/ld.so/noload/test1/Makefile b/regress/libexec/ld.so/noload/test1/Makefile
new file mode 100644 (file)
index 0000000..321c141
--- /dev/null
@@ -0,0 +1,32 @@
+# $OpenBSD: Makefile,v 1.1 2022/08/20 14:13:48 sthen Exp $
+
+.include <bsd.obj.mk>
+
+PROG = test1
+
+LIBADIR !=     if test -d ${.CURDIR}/../liba/${__objdir}; then \
+                       echo "${.CURDIR}/../liba/${__objdir}";  \
+               else                                            \
+                       echo "${.CURDIR}/../liba";              \
+               fi
+
+LIBBDIR !=     if test -d ${.CURDIR}/../libb/${__objdir}; then \
+                       echo "${.CURDIR}/../libb/${__objdir}";  \
+               else                                            \
+                       echo "${.CURDIR}/../libb";              \
+               fi
+
+LIBANAME =     ${LIBADIR}/liba.so.0.0
+LIBBNAME =     ${LIBBDIR}/libb.so.0.0
+
+CFLAGS +=      -DLIBANAME=\"${LIBANAME}\" \
+               -DLIBBNAME=\"${LIBBNAME}\"
+
+REGRESS_TARGETS += run-regress
+
+run-regress: ${PROG}
+       if ./${PROG} | grep found; then echo failed; exit 1; fi
+       LD_PRELOAD=${LIBANAME} ./${PROG} | grep ${LIBANAME}.found
+       LD_PRELOAD=${LIBBNAME} ./${PROG} | grep ${LIBBNAME}.found
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/noload/test1/test1.c b/regress/libexec/ld.so/noload/test1/test1.c
new file mode 100644 (file)
index 0000000..869b9e3
--- /dev/null
@@ -0,0 +1,26 @@
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef LIBANAME
+#error "LIBANAME undefined"
+#endif
+
+#ifndef LIBBNAME
+#error "LIBBNAME undefined"
+#endif
+
+int
+main(int argc, char *argv[])
+{
+       void *handle;
+
+       printf("opening\n");
+       if ((handle = dlopen(LIBANAME, RTLD_NOW|RTLD_NOLOAD)))
+               printf("%s found\n", LIBANAME);
+       else if ((handle = dlopen(LIBBNAME, RTLD_NOW|RTLD_NOLOAD)))
+               printf("%s found\n", LIBBNAME);
+
+       return 0;
+}