From patchwork Tue Oct 8 15:15:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 34873 Received: (qmail 92392 invoked by alias); 8 Oct 2019 15:15:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 92304 invoked by uid 89); 8 Oct 2019 15:15:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=nf X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] Remove support for NO_CTORS_DTORS_SECTIONS Date: Tue, 08 Oct 2019 17:15:01 +0200 Message-ID: <877e5fb762.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 As far as I can tell, no architecture currently needs this. The build-many-glibcs.py logs I have show that the configure check for .ctors/.dtors sections always fails. This is part of my efforts to rework the early initialization code in preparation for rseq support. Tested on x86_64-linux-gnu, i686-linux-gnu, s390x-linux-gnu, powerpc64le-linux-gnu, aarch64-linux-gnu. Built with build-many-glibcs.py (compilers followed by glibcs). 2019-10-08 Florian Weimer Remove support for NO_CTORS_DTORS_SECTIONS. * Makerules (libc.so): Do not link with soinit.os. (linkobj/libc.so): Likewise. * config.h.in (NO_CTORS_DTORS_SECTIONS): Remove definition. * configure.ac: Remove check for NO_CTORS_DTORS_SECTIONS. * configure: Regenerate. * csu/init-first.c (_init): Remove call to __libc_global_ctors. * elf/Makefile (extra-objs): Remove soinit.os. * elf/sofini.c (__CTOR_END__, __DTOR_END__): Remove definitions. * elf/sonit.c: Remove file. * include/libc-internal.h (__libc_global_ctors): Remove declaration. * sysdeps/mach/hurd/i386/init-first.c (__libc_global_ctors): Remove declaration. (posixland_init): Remove call to __libc_global_ctors. diff --git a/Makerules b/Makerules index f5134586fa..102504004e 100644 --- a/Makerules +++ b/Makerules @@ -690,8 +690,7 @@ $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty # Use our own special initializer and finalizer files for the libc.so # libraries. -$(common-objpfx)libc.so: $(elf-objpfx)soinit.os \ - $(common-objpfx)libc_pic.os$(libc_pic_clean) \ +$(common-objpfx)libc.so: $(common-objpfx)libc_pic.os$(libc_pic_clean) \ $(elf-objpfx)sofini.os \ $(elf-objpfx)interp.os \ $(elf-objpfx)ld.so \ @@ -699,8 +698,7 @@ $(common-objpfx)libc.so: $(elf-objpfx)soinit.os \ $(build-shlib) $(call after-link,$@) -$(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \ - $(common-objpfx)linkobj/libc_pic.a \ +$(common-objpfx)linkobj/libc.so: $(common-objpfx)linkobj/libc_pic.a \ $(elf-objpfx)sofini.os \ $(elf-objpfx)interp.os \ $(elf-objpfx)ld.so \ diff --git a/config.h.in b/config.h.in index 824dfe8d8c..e483e47274 100644 --- a/config.h.in +++ b/config.h.in @@ -160,9 +160,6 @@ /* Define if multi-arch DSOs should be generated. */ #undef USE_MULTIARCH -/* Define if `.ctors' and `.dtors' sections shouldn't be used. */ -#undef NO_CTORS_DTORS_SECTIONS - /* Define if obsolete RPC code should be made available for user-level code to link against. */ #undef LINK_OBSOLETE_RPC diff --git a/configure b/configure index 2f44b66656..9112fd3285 100755 --- a/configure +++ b/configure @@ -5731,59 +5731,6 @@ if test $libc_cv_have_sdata_section = yes; then fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use .ctors/.dtors header and trailer" >&5 -$as_echo_n "checking whether to use .ctors/.dtors header and trailer... " >&6; } -if ${libc_cv_ctors_header+:} false; then : - $as_echo_n "(cached) " >&6 -else - libc_cv_ctors_header=yes - cat > conftest.c <&5 - (eval $ac_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - if $READELF -WS conftest$ac_exeext | $AWK ' - { gsub(/\[ */, "[") } - $2 == ".ctors" || $2 == ".dtors" { - size = strtonum("0x" $6) - align = strtonum("0x" $NF) - seen[$2] = 1 - stub[$2] = size == align * 2 - } - END { - ctors_ok = !seen[".ctors"] || stub[".ctors"] - dtors_ok = !seen[".dtors"] || stub[".dtors"] - exit ((ctors_ok && dtors_ok) ? 0 : 1) - } - '; then : - libc_cv_ctors_header=no -fi - -else - as_fn_error $? "missing __attribute__ ((constructor)) support??" "$LINENO" 5 - -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ctors_header" >&5 -$as_echo "$libc_cv_ctors_header" >&6; } -if test $libc_cv_ctors_header = no; then - $as_echo "#define NO_CTORS_DTORS_SECTIONS 1" >>confdefs.h - -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libunwind-support in compiler" >&5 $as_echo_n "checking for libunwind-support in compiler... " >&6; } if ${libc_cv_cc_with_libunwind+:} false; then : diff --git a/configure.ac b/configure.ac index e69c88c543..c3f8b16909 100644 --- a/configure.ac +++ b/configure.ac @@ -1243,36 +1243,6 @@ if test $libc_cv_have_sdata_section = yes; then AC_DEFINE(HAVE_SDATA_SECTION) fi -AC_CACHE_CHECK(whether to use .ctors/.dtors header and trailer, - libc_cv_ctors_header, [dnl - libc_cv_ctors_header=yes - LIBC_TRY_LINK_STATIC([ -__attribute__ ((constructor)) void ctor (void) { asm (""); } -__attribute__ ((destructor)) void dtor (void) { asm (""); } -], - [dnl - AS_IF([$READELF -WS conftest$ac_exeext | $AWK ' - { gsub(/\@<:@ */, "@<:@") } - $2 == ".ctors" || $2 == ".dtors" { - size = strtonum("0x" $6) - align = strtonum("0x" $NF) - seen@<:@$2@:>@ = 1 - stub@<:@$2@:>@ = size == align * 2 - } - END { - ctors_ok = !seen@<:@".ctors"@:>@ || stub@<:@".ctors"@:>@ - dtors_ok = !seen@<:@".dtors"@:>@ || stub@<:@".dtors"@:>@ - exit ((ctors_ok && dtors_ok) ? 0 : 1) - } - '], [libc_cv_ctors_header=no]) - ], [dnl - AC_MSG_ERROR([missing __attribute__ ((constructor)) support??]) - ]) -]) -if test $libc_cv_ctors_header = no; then - AC_DEFINE(NO_CTORS_DTORS_SECTIONS) -fi - AC_CACHE_CHECK(for libunwind-support in compiler, libc_cv_cc_with_libunwind, [ cat > conftest.c < - -static void (*const __CTOR_LIST__[1]) (void) - __attribute__ ((used, section (".ctors"))) - = { (void (*) (void)) -1 }; -static void (*const __DTOR_LIST__[1]) (void) - __attribute__ ((used, section (".dtors"))) - = { (void (*) (void)) -1 }; - -static inline void -run_hooks (void (*const list[]) (void)) -{ - while (*++list) - (**list) (); -} - -/* This function will be called from _init in init-first.c. */ -void -__libc_global_ctors (void) -{ - /* Call constructor functions. */ - run_hooks (__CTOR_LIST__); -} - - -/* This function becomes the DT_FINI termination function - for the C library. */ -void -__libc_fini (void) -{ - /* Call destructor functions. */ - run_hooks (__DTOR_LIST__); -} - -void (*_fini_ptr) (void) __attribute__ ((section (".fini_array"))) - = &__libc_fini; -#endif diff --git a/include/libc-internal.h b/include/libc-internal.h index 05b6b66830..6b48265752 100644 --- a/include/libc-internal.h +++ b/include/libc-internal.h @@ -24,9 +24,6 @@ /* Initialize the `__libc_enable_secure' flag. */ extern void __libc_init_secure (void); -/* This function will be called from _init in init-first.c. */ -extern void __libc_global_ctors (void); - /* Discover the tick frequency of the machine if something goes wrong, we return 0, an impossible hertz. */ extern int __profile_frequency (void); diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index f1f1c40389..fa939f7b73 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -33,7 +33,6 @@ extern void __mach_init (void); extern void __init_misc (int, char **, char **); -extern void __libc_global_ctors (void); unsigned long int __hurd_threadvar_stack_offset; unsigned long int __hurd_threadvar_stack_mask; @@ -86,10 +85,6 @@ posixland_init (int argc, char **argv, char **envp) /* Initialize ctype data. */ __ctype_init (); - -#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS - __libc_global_ctors (); -#endif }