diff options
| author | Enji Cooper <ngie@FreeBSD.org> | 2026-02-15 01:57:42 +0000 |
|---|---|---|
| committer | Enji Cooper <ngie@FreeBSD.org> | 2026-02-15 02:12:44 +0000 |
| commit | e8dbf2b6df199526a660f81de07d17925cfd8518 (patch) | |
| tree | cd0c09449bea5df56ef67059e797737d70587070 /lib/csu | |
| parent | 56a7ce8416d181a2060d7a428aed9c3c6a431e6d (diff) | |
Add files missed in 56a7ce8416d181a2060d7a42vendor/NetBSD/tests/2026.02.14_2vendor/NetBSD/tests
Skip usr.bin/diff3 tests as these contain text that gets misinterpreted
as merge conflict markers and blocks push with the relevant pre-receive
hook.
PR: 293186
Diffstat (limited to 'lib/csu')
| -rw-r--r-- | lib/csu/h_hello.c | 48 | ||||
| -rw-r--r-- | lib/csu/h_preinit_array.c | 16 | ||||
| -rw-r--r-- | lib/csu/t_hello.sh | 150 |
3 files changed, 214 insertions, 0 deletions
diff --git a/lib/csu/h_hello.c b/lib/csu/h_hello.c new file mode 100644 index 000000000000..e39284c2f5c9 --- /dev/null +++ b/lib/csu/h_hello.c @@ -0,0 +1,48 @@ +/* $NetBSD: h_hello.c,v 1.1 2025/04/27 04:09:35 riastradh Exp $ */ + +/*- + * Copyright (c) 2025 The NetBSD Foundation, Inc. + * All rights reserved. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h> +__RCSID("$NetBSD: h_hello.c,v 1.1 2025/04/27 04:09:35 riastradh Exp $"); + +#include <stdio.h> +#include <stdlib.h> + +/* + * Force some R_*_RELATIVE-type relocations. + */ +static int foo = 42; +static int *volatile foop = &foo; + +int +main(void) +{ + + printf("%s: Hello, world! %d\n", getprogname(), *foop); + fflush(stdout); + return ferror(stdout); +} diff --git a/lib/csu/h_preinit_array.c b/lib/csu/h_preinit_array.c new file mode 100644 index 000000000000..36fa37ff340b --- /dev/null +++ b/lib/csu/h_preinit_array.c @@ -0,0 +1,16 @@ +static int x = 1; + +static void +foo(void) +{ + x--; +} + +static void (*fp) (void) __attribute__((__section__(".preinit_array"), __used__)) = + foo; + +int +main(void) +{ + return x; +} diff --git a/lib/csu/t_hello.sh b/lib/csu/t_hello.sh new file mode 100644 index 000000000000..b72f62885476 --- /dev/null +++ b/lib/csu/t_hello.sh @@ -0,0 +1,150 @@ +# $NetBSD: t_hello.sh,v 1.3 2025/05/02 23:04:06 riastradh Exp $ +# +# Copyright (c) 2025 The NetBSD Foundation, Inc. +# All rights reserved. +# +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +checksupport() +{ + local prog + + prog=$1 + test -f "$(atf_get_srcdir)/${prog}" || atf_skip "not supported" +} + +checkrun() +{ + local prog + + prog=$1 + atf_check -o inline:"${prog}: Hello, world! 42\n" \ + "$(atf_get_srcdir)/${prog}" +} + +cleanup() +{ + local prog + + prog=$1 + test -f "${prog}.core" || return 0 + readelf -rs "$(atf_get_srcdir)/${prog}" + gdb -batch -ex bt -ex 'info registers' -ex disas \ + "$(atf_get_srcdir)/${prog}" "${prog}.core" +} + +atf_test_case dynamic cleanup +dynamic_head() +{ + atf_set "descr" "Test a dynamic executable" +} +dynamic_body() +{ + checksupport h_hello_dyn + checkrun h_hello_dyn +} +dynamic_cleanup() +{ + cleanup h_hello_dyn +} + +atf_test_case dynamicpie cleanup +dynamicpie_head() +{ + atf_set "descr" "Test a dynamic position-independent executable" +} +dynamicpie_body() +{ + checksupport h_hello_dynpie + checkrun h_hello_dynpie +} +dynamicpie_cleanup() +{ + cleanup h_hello_dynpie +} + +atf_test_case relr cleanup +relr_head() +{ + atf_set "descr" "Test a static PIE executable with RELR relocations" +} +relr_body() +{ + checksupport h_hello_relr + case `uname -p` in + i386|x86_64) + ;; + *) atf_expect_fail "PR lib/59359: static pies are broken" + ;; + esac + checkrun h_hello_relr +} +relr_cleanup() +{ + cleanup h_hello_relr +} + +atf_test_case static cleanup +static_head() +{ + atf_set "descr" "Test a static executable" +} +static_body() +{ + checksupport h_hello_sta + checkrun h_hello_sta +} +static_cleanup() +{ + cleanup h_hello_sta +} + +atf_test_case staticpie cleanup +staticpie_head() +{ + atf_set "descr" "Test a static position-independent executable" +} +staticpie_body() +{ + checksupport h_hello_stapie + case `uname -p` in + i386|x86_64) + ;; + *) atf_expect_fail "PR lib/59359: static pies are broken" + ;; + esac + checkrun h_hello_stapie +} +staticpie_cleanup() +{ + cleanup h_hello_stapie +} + +atf_init_test_cases() +{ + atf_add_test_case dynamic + atf_add_test_case dynamicpie + atf_add_test_case relr + atf_add_test_case static + atf_add_test_case staticpie +} |
