Index: head/etc/mtree/BSD.tests.dist =================================================================== --- head/etc/mtree/BSD.tests.dist (revision 339907) +++ head/etc/mtree/BSD.tests.dist (revision 339908) @@ -1,1054 +1,1056 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin cat .. chflags .. chmod .. date .. dd .. echo .. expr .. ln .. ls .. mkdir .. mv .. pax .. pkill .. pwait .. rm .. rmdir .. sh builtins .. errors .. execution .. expansion .. invocation .. parameters .. parser .. set-e .. .. sleep .. test .. .. cddl lib .. sbin .. usr.bin ctfconvert .. ztest .. .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. env .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. lexer .. llquantize .. mdb .. mib .. misc .. multiaggs .. offsetof .. operators .. pid .. plockstat .. pointers .. pragma .. predicates .. preprocessor .. print .. printa .. printf .. privs .. probes .. proc .. profile-n .. providers .. raise .. rates .. safety .. scalars .. sched .. scripting .. sdt .. sizeof .. speculation .. stability .. stack .. stackdepth .. stop .. strlen .. strtoll .. struct .. sugar .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. .. zfsd .. .. .. etc rc.d .. .. games .. gnu lib .. usr.bin diff .. .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. csu dynamic .. + dynamiclib + .. static .. .. libarchive .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. iconv .. inet .. locale .. net getaddrinfo data .. .. .. nss .. regex data .. .. resolv .. rpc .. ssp .. setjmp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcam .. libcasper services cap_dns .. cap_grp .. cap_pwd .. cap_sysctl .. .. .. libcrypt .. libdevdctl .. libkvm .. libmp .. libnv .. libproc .. libregex data .. .. librt .. libsbuf .. libthr dlopen .. .. libutil .. libxo .. msun .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. tftpd .. .. sbin dhclient .. devd .. growfs .. ifconfig .. mdconfig .. pfctl files .. .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. tap .. .. .. zoneinfo .. .. sys acl .. aio .. audit .. auditpipe .. capsicum .. cddl zfs bin .. include .. tests acl cifs .. nontrivial .. trivial .. .. atime .. bootfs .. cache .. cachefile .. clean_mirror .. cli_root zfs_upgrade .. zfs_promote .. zfs_clone .. zfs_property .. zfs_destroy .. zpool_create .. zpool_history .. zpool_expand .. zpool_remove .. zfs_mount .. zfs_unshare .. zdb .. zpool_online .. zpool_get .. zpool_export .. zfs_copies .. zfs_get .. zfs .. zpool_clear .. zpool_import blockfiles .. .. zpool .. zpool_offline .. zpool_replace .. zfs_rollback .. zpool_set .. zfs_send .. zfs_set .. zpool_detach .. zfs_diff .. zpool_scrub .. zfs_inherit .. zfs_snapshot .. zfs_share .. zpool_destroy .. zpool_status .. zfs_unmount .. zfs_receive .. zfs_create .. zpool_upgrade blockfiles .. .. zpool_add .. zfs_rename .. zpool_attach .. zfs_reservation .. .. cli_user misc .. zfs_list .. zpool_iostat .. zpool_list .. .. compression .. ctime .. delegate .. devices .. exec .. grow_pool .. grow_replicas .. history .. hotplug .. hotspare .. inheritance .. interop .. inuse .. iscsi .. large_files .. largest_pool .. link_count .. migration .. mmap .. mount .. mv_files .. nestedfs .. no_space .. online_offline .. pool_names .. poolversion .. quota .. redundancy .. refquota .. refreserv .. rename_dirs .. replacement .. reservation .. rootpool .. rsend .. scrub_mirror .. slog .. snapshot .. snapused .. sparse .. threadsappend .. truncate .. txg_integrity .. userquota .. utils_test .. write_dirs .. xattr .. zfsd .. zil .. zinject .. zones .. zvol zvol_ENOSPC .. zvol_cli .. zvol_misc .. zvol_swap .. .. zvol_thrash .. .. .. .. dtrace .. fifo .. file .. fs tmpfs .. .. geom class concat .. eli .. gate .. gpt .. mirror .. nop .. part .. raid3 .. shsec .. stripe .. uzip etalon .. .. .. .. kern acct .. execve .. pipe .. .. kqueue libkqueue .. .. mac bsdextended .. portacl .. .. mqueue .. net .. netinet .. netipsec tunnel .. .. netpfil pf ioctl .. .. .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. utimensat .. .. posixshm .. sys .. vfs .. vm .. .. usr.bin apply .. awk .. basename .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. bsdcat .. calendar .. cmp .. compress .. cpio .. col .. comm .. csplit .. cut .. dc .. diff .. dirname .. du .. file2c .. find .. fold .. getconf .. grep .. gzip .. head .. hexdump .. ident .. indent .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. pr .. printf .. procstat .. rs .. sdiff .. sed regress.multitest.out .. .. seq .. soelim .. stat .. tail .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. uniq .. vmstat .. xargs .. xinstall .. xo .. yacc yacc .. .. .. usr.sbin chown .. etcupdate .. extattr .. fstyp .. makefs .. newsyslog .. nmtree .. praudit .. pw .. rpcbind .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: head/lib/csu/tests/Makefile =================================================================== --- head/lib/csu/tests/Makefile (revision 339907) +++ head/lib/csu/tests/Makefile (revision 339908) @@ -1,6 +1,8 @@ # $FreeBSD$ +SUBDIR= dso TESTS_SUBDIRS= dynamic +TESTS_SUBDIRS+= dynamiclib TESTS_SUBDIRS+= static .include Index: head/lib/csu/tests/cxx_constructors.cc =================================================================== --- head/lib/csu/tests/cxx_constructors.cc (revision 339907) +++ head/lib/csu/tests/cxx_constructors.cc (revision 339908) @@ -1,92 +1,105 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2018 Andrew Turner * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 * ("CTSRD"), as part of the DARPA CRASH research programme. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include +#ifndef DSO_LIB #include +#endif -static volatile int constructor_run; -static bool run_destructor_test = false; +extern volatile int constructor_run; +extern bool run_destructor_test; + +#ifndef DSO_BASE +volatile int constructor_run; +bool run_destructor_test = false; +#endif + struct Foo { Foo() { constructor_run = 1; } ~Foo() { if (run_destructor_test) _exit(1); } }; extern Foo foo; + +#ifndef DSO_BASE Foo foo; +#endif +#ifndef DSO_LIB ATF_TEST_CASE_WITHOUT_HEAD(cxx_constructor); ATF_TEST_CASE_BODY(cxx_constructor) { ATF_REQUIRE(constructor_run == 1); } ATF_TEST_CASE_WITHOUT_HEAD(cxx_destructor); ATF_TEST_CASE_BODY(cxx_destructor) { pid_t pid, wpid; int status; pid = fork(); switch(pid) { case -1: break; case 0: run_destructor_test = true; exit(0); default: while ((wpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR) ; ATF_REQUIRE(WEXITSTATUS(status) == 1); break; } } ATF_INIT_TEST_CASES(tcs) { ATF_ADD_TEST_CASE(tcs, cxx_constructor); ATF_ADD_TEST_CASE(tcs, cxx_destructor); } +#endif Index: head/lib/csu/tests/dso/Makefile =================================================================== --- head/lib/csu/tests/dso/Makefile (nonexistent) +++ head/lib/csu/tests/dso/Makefile (revision 339908) @@ -0,0 +1,25 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR:H} +SHLIB= h_csu +SHLIB_NAME= libh_csu.so +SHLIB_MAJOR= 1 + +WITHOUT_STATIC= +WITHOUT_PROFILE= +WITHOUT_PIC= + +CFLAGS+= -DDSO_LIB + +.include "../Makefile.tests" +SRCS= +.for src in ${ATF_TESTS_C} +SRCS+= ${src}.c +.endfor +.for src in ${ATF_TESTS_CXX} +SRCS+= ${src}.cc +.endfor + +LIBDIR= ${TESTSBASE}/lib/csu/dynamiclib/ + +.include Property changes on: head/lib/csu/tests/dso/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/tests/dynamiclib/Makefile =================================================================== --- head/lib/csu/tests/dynamiclib/Makefile (nonexistent) +++ head/lib/csu/tests/dynamiclib/Makefile (revision 339908) @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR:H} +CFLAGS+= -DDSO_BASE +DPADD+= ${.OBJDIR:H}/dso/libh_csu.so +LDFLAGS+= -Wl,-rpath,${TESTSDIR} -L${.OBJDIR:H}/dso +LDADD+= -lh_csu + +.include "../Makefile.tests" + +.for test in ${ATF_TESTS_C} +ATF_TESTS_CXX+= ${test} +SRCS.${test}= ${test}.c +.endfor +ATF_TESTS_C:= + +.include Property changes on: head/lib/csu/tests/dynamiclib/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/tests/fini_test.c =================================================================== --- head/lib/csu/tests/fini_test.c (revision 339907) +++ head/lib/csu/tests/fini_test.c (revision 339908) @@ -1,140 +1,171 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2018 Andrew Turner * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 * ("CTSRD"), as part of the DARPA CRASH research programme. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +extern bool run_dtors_test; +extern bool run_fini_array_test; +void dso_handle_check(void); + + +#ifndef DSO_BASE typedef void (*func_ptr)(void); -static bool run_dtors_test = false; -static bool run_fini_array_test = false; +bool run_dtors_test = false; +bool run_fini_array_test = false; static void dtors_handler(void) { if (run_dtors_test) _exit(1); } __section(".dtors") __used static func_ptr dtors_func = &dtors_handler; +#endif +#ifndef DSO_LIB ATF_TC_WITHOUT_HEAD(dtors_test); ATF_TC_BODY(dtors_test, tc) { pid_t pid, wpid; int status; pid = fork(); switch(pid) { case -1: break; case 0: run_dtors_test = true; exit(0); default: while ((wpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR) ; #ifdef HAVE_CTORS ATF_REQUIRE_MSG(WEXITSTATUS(status) == 1, ".dtors failed to run"); #else ATF_REQUIRE_MSG(WEXITSTATUS(status) == 0, ".dtors incorrectly ran"); #endif break; } } +#endif +#ifndef DSO_BASE static void fini_array_handler(void) { if (run_fini_array_test) _exit(1); } __section(".fini_array") __used static func_ptr fini_array_func = &fini_array_handler; +#endif +#ifndef DSO_LIB ATF_TC_WITHOUT_HEAD(fini_array_test); ATF_TC_BODY(fini_array_test, tc) { pid_t pid, wpid; int status; pid = fork(); switch(pid) { case -1: break; case 0: run_fini_array_test = true; exit(0); default: while ((wpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR) ; ATF_REQUIRE_MSG(WEXITSTATUS(status) == 1, ".fini_array failed to run"); break; } } +#endif +#ifndef DSO_BASE extern void *__dso_handle; +void +dso_handle_check(void) +{ + void *dso = __dso_handle; + +#ifdef DSO_LIB + ATF_REQUIRE_MSG(dso != NULL, + "Null __dso_handle in DSO"); +#else + ATF_REQUIRE_MSG(dso == NULL, + "Invalid __dso_handle in non-DSO"); +#endif +} +#endif + +#ifndef DSO_LIB ATF_TC_WITHOUT_HEAD(dso_handle_test); ATF_TC_BODY(dso_handle_test, tc) { - ATF_REQUIRE_MSG(__dso_handle == NULL, - "Invalid __dso_handle in non-DSO"); + dso_handle_check(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, dtors_test); ATF_TP_ADD_TC(tp, fini_array_test); ATF_TP_ADD_TC(tp, dso_handle_test); return (atf_no_error()); } +#endif Index: head/lib/csu/tests/init_test.c =================================================================== --- head/lib/csu/tests/init_test.c (revision 339907) +++ head/lib/csu/tests/init_test.c (revision 339908) @@ -1,137 +1,172 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2018 Andrew Turner * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 * ("CTSRD"), as part of the DARPA CRASH research programme. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); +#ifndef DSO_LIB #include +#endif #include typedef void (*func_ptr)(void); -static volatile int jcr_run; -static const func_ptr *jcr_ptr; -static volatile int ctors_run; -static volatile int preinit_array_run; -static volatile int preinit_array_state = -1; -static volatile int init_array_run; -static volatile int init_array_state = -1; +extern volatile int jcr_run; +extern const func_ptr *jcr_ptr; +extern const void *jcr_func_ptr; +extern volatile int ctors_run; +extern volatile int preinit_array_run; +extern volatile int preinit_array_state; +extern volatile int init_array_run; +extern volatile int init_array_state; +#ifndef DSO_BASE +volatile int jcr_run; +const func_ptr *jcr_ptr; +volatile int ctors_run; +volatile int preinit_array_run; +volatile int preinit_array_state = -1; +volatile int init_array_run; +volatile int init_array_state = -1; + void _Jv_RegisterClasses(const func_ptr *); -__section(".jcr") __used static func_ptr jcr_func = (func_ptr)1; +__section(".jcr") __used func_ptr static jcr_func = (func_ptr)1; +const void *jcr_func_ptr = &jcr_func; void _Jv_RegisterClasses(const func_ptr *jcr) { jcr_run = 1; jcr_ptr = jcr; } +#endif +#ifndef DSO_LIB ATF_TC_WITHOUT_HEAD(jcr_test); ATF_TC_BODY(jcr_test, tc) { ATF_REQUIRE_MSG(jcr_run == 1, ".jcr not run"); - ATF_REQUIRE_MSG(jcr_ptr == &jcr_func, + ATF_REQUIRE_MSG(jcr_ptr == jcr_func_ptr, "Incorrect pointer passed to _Jv_RegisterClasses"); } +#endif +#ifndef DSO_BASE static void ctors_handler(void) { ctors_run = 1; } __section(".ctors") __used static func_ptr ctors_func = &ctors_handler; +#endif +#ifndef DSO_LIB ATF_TC_WITHOUT_HEAD(ctors_test); ATF_TC_BODY(ctors_test, tc) { #ifdef HAVE_CTORS ATF_REQUIRE_MSG(ctors_run == 1, ".ctors not run"); #else ATF_REQUIRE_MSG(ctors_run == 0, ".ctors run"); #endif } +#endif +#ifndef DSO_BASE static void preinit_array_handler(void) { preinit_array_run = 1; preinit_array_state = init_array_run; } __section(".preinit_array") __used static func_ptr preinit_array_func = &preinit_array_handler; +#endif +#ifndef DSO_LIB ATF_TC_WITHOUT_HEAD(preinit_array_test); ATF_TC_BODY(preinit_array_test, tc) { +#ifdef DSO_BASE + /* Check .preinit_array wasn't run in a DSO */ + ATF_REQUIRE_MSG(preinit_array_run == 0, ".preinit_array run in DSO"); +#else ATF_REQUIRE_MSG(preinit_array_run == 1, ".preinit_array not run"); ATF_REQUIRE_MSG(preinit_array_state == 0, ".preinit_array was not run before .init_array"); +#endif } +#endif +#ifndef DSO_BASE static void init_array_handler(void) { init_array_run = 1; init_array_state = preinit_array_run; } __section(".init_array") __used static func_ptr init_array_func = &init_array_handler; +#endif +#ifndef DSO_LIB ATF_TC_WITHOUT_HEAD(init_array_test); ATF_TC_BODY(init_array_test, tc) { ATF_REQUIRE_MSG(init_array_run == 1, ".init_array not run"); +#ifndef DSO_BASE ATF_REQUIRE_MSG(init_array_state == 1, ".init_array was not run after .preinit_array"); +#endif } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, jcr_test); ATF_TP_ADD_TC(tp, ctors_test); ATF_TP_ADD_TC(tp, preinit_array_test); ATF_TP_ADD_TC(tp, init_array_test); return (atf_no_error()); } +#endif