From patchwork Mon May 18 12:56:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39292 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D0F80388A83A; Mon, 18 May 2020 12:56:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0F80388A83A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589806613; bh=WyfIRj1tREA5XXjd6sTMnLQitXH5OJlFO7hmaBFalH8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lPfTddKOMK36zBzenvN6KW0dF+vOl7Vj0hMrbq0QyhagwByVG1czQYGiCwDFMr3r0 x9ySqbIYH140lar1kH5Do67926gAdePYzvR2ycSMnT1Qg4GFdFUdzCpbuW52vs+WyV fz54lGQMQPu/ZclEKZ+IjL4hoAZDay+f6EkB2A2g= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id F3794388A816 for ; Mon, 18 May 2020 12:56:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F3794388A816 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-80-UrtyQ-c1Pm-4nO5ShPwYKw-1; Mon, 18 May 2020 08:56:27 -0400 X-MC-Unique: UrtyQ-c1Pm-4nO5ShPwYKw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9592E1009441 for ; Mon, 18 May 2020 12:56:26 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-142.ams2.redhat.com [10.36.112.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC5031C953 for ; Mon, 18 May 2020 12:56:25 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v2] Remove NO_CTORS_DTORS_SECTIONS macro Date: Mon, 18 May 2020 14:56:24 +0200 Message-ID: <87lflpcsg7.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This was originally added to support binutils older than version 2.22: Since 2.22 is older than the minimum required binutils version for building glibc, we no longer need this. (The changes do not impact the statically linked startup code.) --- Changes since v1: Rebased on top of current master. Retested on x86_64-linux-gnu and i686-linux-gnu, built with build-many-glibcs.py. Makerules | 6 ++--- config.h.in | 3 --- configure | 53 ------------------------------------- configure.ac | 30 --------------------- csu/init-first.c | 4 --- elf/Makefile | 2 +- elf/sofini.c | 12 --------- elf/soinit.c | 43 ------------------------------ include/libc-internal.h | 3 --- sysdeps/mach/hurd/i386/init-first.c | 5 ---- 10 files changed, 3 insertions(+), 158 deletions(-) diff --git a/Makerules b/Makerules index 1e9c18f0d8..341db86c7e 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 dea43df438..cd7d4df3ed 100644 --- a/config.h.in +++ b/config.h.in @@ -157,9 +157,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 8df47d61f8..b8ef8c7a51 100755 --- a/configure +++ b/configure @@ -5753,59 +5753,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 5f229679a9..ff00591fd4 100644 --- a/configure.ac +++ b/configure.ac @@ -1251,36 +1251,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_first 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 4c74f6ba60..729db7918e 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_first 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 a7dd4895d9..5e66602d4b 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; @@ -83,10 +82,6 @@ posixland_init (int argc, char **argv, char **envp) _dl_non_dynamic_init (); #endif __init_misc (argc, argv, envp); - -#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS - __libc_global_ctors (); -#endif }