From 20cb0deaa2db72f198b0574dc22401a548d6c56b Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 8 Nov 2019 14:28:39 +0000 Subject: [PATCH] csu: Fix dynamiclib/init_test:jcr_test on !HAVE_CTORS archs .jcr still needs a 0-entry added in crtend, even on !HAVE_CTORS archs, as we're still getting .jcr sections added -- presumably due to the reference in crtbegin. Without this terminal, the .jcr section (without data) overlaps with the next section and register_classes in crtbegin will be examining the wrong item. PR: 241439 Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D22132 --- lib/csu/common/crtend.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/csu/common/crtend.c b/lib/csu/common/crtend.c index 6e83354614d9..19fe5eb8780b 100644 --- a/lib/csu/common/crtend.c +++ b/lib/csu/common/crtend.c @@ -26,9 +26,14 @@ __FBSDID("$FreeBSD$"); #include "crt.h" -#ifdef HAVE_CTORS typedef void (*crt_func)(void); +static crt_func __JCR_LIST__[] __section(".jcr") __used = { + (crt_func)0 +}; + +#ifdef HAVE_CTORS + /* * On some architectures and toolchains we may need to call the .ctors. * These are called in the reverse order they are in the ELF file. @@ -41,9 +46,6 @@ static crt_func __CTOR_END__[] __section(".ctors") __used = { static crt_func __DTOR_END__[] __section(".dtors") __used = { (crt_func)0 }; -static crt_func __JCR_LIST__[] __section(".jcr") __used = { - (crt_func)0 -}; static void __do_global_ctors_aux(void)