aboutsummaryrefslogtreecommitdiff
path: root/lib/csu
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csu')
-rw-r--r--lib/csu/common/crtbegin.c33
-rw-r--r--lib/csu/common/crtend.c4
-rw-r--r--lib/csu/tests/Makefile1
-rw-r--r--lib/csu/tests/dso/Makefile2
-rw-r--r--lib/csu/tests/errno/Makefile18
-rw-r--r--lib/csu/tests/errno/errno_test.c23
-rw-r--r--lib/csu/tests/init_test.c30
7 files changed, 44 insertions, 67 deletions
diff --git a/lib/csu/common/crtbegin.c b/lib/csu/common/crtbegin.c
index 06fe990052f7..8ef9b8923c21 100644
--- a/lib/csu/common/crtbegin.c
+++ b/lib/csu/common/crtbegin.c
@@ -98,36 +98,3 @@ asm (
".popsection \n"
);
#endif
-
-/*
- * Handler for gcj. These provide a _Jv_RegisterClasses function and fill
- * out the .jcr section. We just need to call this function with a pointer
- * to the appropriate section.
- */
-extern void _Jv_RegisterClasses(void *) __weak_symbol;
-static void register_classes(void) __used;
-
-static crt_func __JCR_LIST__[] __section(".jcr") __used = { };
-
-#ifndef CTORS_CONSTRUCTORS
-__attribute__((constructor))
-#endif
-static void
-register_classes(void)
-{
-
- if (_Jv_RegisterClasses != NULL && __JCR_LIST__[0] != 0)
- _Jv_RegisterClasses(__JCR_LIST__);
-}
-
-/*
- * We can't use constructors when they use the .ctors section as they may be
- * placed before __CTOR_LIST__.
- */
-#ifdef CTORS_CONSTRUCTORS
-asm (
- ".pushsection .init \n"
- "\t" INIT_CALL_SEQ(register_classes) "\n"
- ".popsection \n"
-);
-#endif
diff --git a/lib/csu/common/crtend.c b/lib/csu/common/crtend.c
index bf25c1d836a9..9eb75de2ef60 100644
--- a/lib/csu/common/crtend.c
+++ b/lib/csu/common/crtend.c
@@ -26,10 +26,6 @@
typedef void (*crt_func)(void);
-static crt_func __JCR_END__[] __section(".jcr") __used = {
- (crt_func)0
-};
-
#ifdef HAVE_CTORS
/*
diff --git a/lib/csu/tests/Makefile b/lib/csu/tests/Makefile
index c9a0e6eff5da..b76ef590c88f 100644
--- a/lib/csu/tests/Makefile
+++ b/lib/csu/tests/Makefile
@@ -4,6 +4,7 @@ SUBDIR= dso
TESTS_SUBDIRS= dynamic
TESTS_SUBDIRS+= dynamiclib
TESTS_SUBDIRS+= dynamicpie
+TESTS_SUBDIRS+= errno
TESTS_SUBDIRS+= static
SUBDIR_DEPEND_dynamiclib=dso
diff --git a/lib/csu/tests/dso/Makefile b/lib/csu/tests/dso/Makefile
index 6c1d00e9fb58..431168de0328 100644
--- a/lib/csu/tests/dso/Makefile
+++ b/lib/csu/tests/dso/Makefile
@@ -1,4 +1,6 @@
.PATH: ${.CURDIR:H}
+
+PACKAGE= tests
SHLIB= h_csu
SHLIB_NAME= libh_csu.so
SHLIB_MAJOR= 1
diff --git a/lib/csu/tests/errno/Makefile b/lib/csu/tests/errno/Makefile
new file mode 100644
index 000000000000..eae54a936294
--- /dev/null
+++ b/lib/csu/tests/errno/Makefile
@@ -0,0 +1,18 @@
+PLAIN_TESTS_C= errno_test \
+ errno_static_test \
+ errno_thr_test \
+ errno_thr_static_test
+
+SRCS.errno_static_test= errno_test.c
+LDFLAGS.errno_static_test= -static
+
+SRCS.errno_thr_test= errno_test.c
+LIBADD.errno_thr_test= pthread
+
+SRCS.errno_thr_static_test= errno_test.c
+LDFLAGS.errno_thr_static_test= -static
+LIBADD.errno_thr_static_test= pthread
+
+MK_PIE:= no
+
+.include <bsd.test.mk>
diff --git a/lib/csu/tests/errno/errno_test.c b/lib/csu/tests/errno/errno_test.c
new file mode 100644
index 000000000000..d190c7fd2959
--- /dev/null
+++ b/lib/csu/tests/errno/errno_test.c
@@ -0,0 +1,23 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Mark Johnston <markj@FreeBSD.org>
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+
+static void __attribute__((constructor))
+f(void)
+{
+ errno = 42;
+}
+
+int
+main(void)
+{
+ /* errno must be zero upon program startup. */
+ if (errno != 0)
+ exit(1);
+ exit(0);
+}
diff --git a/lib/csu/tests/init_test.c b/lib/csu/tests/init_test.c
index 47bd9b7e64d7..2d4484735f76 100644
--- a/lib/csu/tests/init_test.c
+++ b/lib/csu/tests/init_test.c
@@ -38,9 +38,6 @@
typedef void (*func_ptr)(void);
-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;
@@ -48,37 +45,11 @@ 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;
-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_ptr,
- "Incorrect pointer passed to _Jv_RegisterClasses");
-}
#endif
#ifndef DSO_BASE
@@ -160,7 +131,6 @@ ATF_TC_BODY(init_array_test, tc)
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);