From patchwork Wed Nov 6 16:16:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 1190537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512623-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="imsMoJio"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mittosystems.com header.i=@mittosystems.com header.b="IYQcevPM"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 477WrG0lkSz9sP6 for ; Thu, 7 Nov 2019 03:16:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:in-reply-to:references:mime-version :content-type; q=dns; s=default; b=t366R366Isxz00amv/+PeHtdaZA5T jwTwMQuQDc1lZ9q+l6eZ5ocnC8mE4TiWAbn4FWUftFGPy8CxX+K3QHZv8qyvUh3G Cw+co2gVdy7R1Z2A5QTkHaInraVO3OyqM9YA97czoqQq52VOgf4iS1dLDyL30b8P 8wzkTIDd09Llqk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:in-reply-to:references:mime-version :content-type; s=default; bh=jNVv2cyGc5FcwvnzxhZcTkxR1iI=; b=ims MoJioI3C2QONRpDIRTwbtuWYnmZH6bDhCwncXIEvNsUqYNqZ9Cs+eewDOtshz+ld M4/VL9RKnix129TrFAzP6Wxq/NOtN0oThwqLGZ2P2eCFfsqvCnWNU1zy+Y45GV4q xk5TZ7HCGH4NmmuUZR/jRNJ5NwAC2jZCX/aj5mWw= Received: (qmail 65286 invoked by alias); 6 Nov 2019 16:16:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 65227 invoked by uid 89); 6 Nov 2019 16:16:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=thereby, 3037 X-HELO: mail-wm1-f53.google.com Received: from mail-wm1-f53.google.com (HELO mail-wm1-f53.google.com) (209.85.128.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Nov 2019 16:16:31 +0000 Received: by mail-wm1-f53.google.com with SMTP id c17so4220113wmk.2 for ; Wed, 06 Nov 2019 08:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=date:from:to:subject:message-id:in-reply-to:references:mime-version; bh=uEPYrSHOwQkGFCqGmI+oKkwRcg6jMPkf5so25DVr4KQ=; b=IYQcevPMU0ooK3AxaCQbhVjUgsAUpSSH1fsmVSNMa/d+zmTqpZjtYT/hmwm3+QCycm vxl7YlfxV//7SV8OXgFMVHu1grcAqPIeGhpvIjVlUBdHjbLvnsYiruLuPaD5IVjxHVm/ SR1qbDfvIUSCsdvZGuve26Z1fsryFAzwKRu6QRF4L8/t+09q2WwfFDS4ANWDlhGQMAm6 1cDmx4rYeMH5fVrdRXli1L5j107lL+RxVZBNIwY0OzOCrLcnPGR8ADUDVJTSANz9PRL8 X/aMa0/NUx6DZTpYgP3gdX99ESJZls0dZ6CEqwxMgSRo6e+6F/VZMiPAZ0Pl7YJQI5wm fTkg== Received: from jozef-kubuntu ([2a01:4b00:87fd:900:e1ba:1c62:d07d:e2d4]) by smtp.gmail.com with ESMTPSA id l2sm23340513wrt.15.2019.11.06.08.16.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Nov 2019 08:16:28 -0800 (PST) Date: Wed, 6 Nov 2019 16:16:27 +0000 From: Jozef Lawrynowicz To: "gcc-patches@gcc.gnu.org" Subject: [PATCH 1/3] libgcc: Add --disable-eh-frame-registry configure option Message-ID: <20191106161627.0cd62fdf@jozef-kubuntu> In-Reply-To: <20191106161420.2e16dba9@jozef-kubuntu> References: <20191106161420.2e16dba9@jozef-kubuntu> MIME-Version: 1.0 X-IsSubscribed: yes The attached patch enables the EH Frame Registry to be explicitly disabled with a configure option "-disable-eh-frame-registry", thereby removing code to support it in crtstuff.c Default behaviour is unchanged since USE_EH_FRAME_REGISTRY was previously referenced only internally in crtstuff.c, and now is only defined to 0 when it would previously have not been defined at all. From 31fdea3564fd0a9a25547df0d5052133d7bdc8a6 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Tue, 29 Oct 2019 12:55:11 +0000 Subject: [PATCH 1/3] libgcc: Add --disable-eh-frame-registry configure option gcc/ChangeLog: 2019-11-06 Jozef Lawrynowicz * doc/install.texi: Document --disable-eh-frame-registry. libgcc/ChangeLog: 2019-11-06 Jozef Lawrynowicz * Makefile.in: Add USE_EH_FRAME_REGISTRY variable. Use USE_EH_FRAME_REGISTRY variable in CRTSTUFF_CFLAGS. * configure: Regenerate. * configure.ac: Support --disable-eh-frame-registry. * crtstuff.c [!USE_EH_FRAME_REGISTRY]: Define USE_EH_FRAME_REGISTRY. s/#ifdef USE_EH_FRAME_REGISTRY/#if USE_EH_FRAME_REGISTRY/. s/#if defined(USE_EH_FRAME_REGISTRY)/#if USE_EH_FRAME_REGISTRY/. --- gcc/doc/install.texi | 11 +++++++++++ libgcc/Makefile.in | 4 +++- libgcc/configure | 22 ++++++++++++++++++++++ libgcc/configure.ac | 17 +++++++++++++++++ libgcc/crtstuff.c | 22 +++++++++++++--------- 5 files changed, 66 insertions(+), 10 deletions(-) diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 563de705881..af61a34a477 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1314,6 +1314,17 @@ Disable TM clone registry in libgcc. It is enabled in libgcc by default. This option helps to reduce code size for embedded targets which do not use transactional memory. +@item --disable-eh-frame-registry +Disable the EH frame registry in libgcc. It is enabled in libgcc by default +for most ELF targets. + +This should not be used unless exceptions have been disabled for the target +configuration. + +This option reduces code size by removing functionality to register the +exception handling frame information that would normally run before +@samp{main()}. + @item --with-cpu=@var{cpu} @itemx --with-cpu-32=@var{cpu} @itemx --with-cpu-64=@var{cpu} diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 5608352a900..59f7f3cc381 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -261,6 +261,8 @@ CET_FLAGS = @CET_FLAGS@ USE_TM_CLONE_REGISTRY = @use_tm_clone_registry@ +USE_EH_FRAME_REGISTRY = @use_eh_frame_registry@ + # Defined in libgcc2.c, included only in the static library. LIB2FUNCS_ST = _eprintf __gcc_bcmp @@ -301,7 +303,7 @@ CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \ -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \ -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \ - $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY) + $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY) $(USE_EH_FRAME_REGSITRY) # Extra flags to use when compiling crt{begin,end}.o. CRTSTUFF_T_CFLAGS = diff --git a/libgcc/configure b/libgcc/configure index 117e9c97e57..341c609252e 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -605,6 +605,7 @@ solaris_ld_v2_maps real_host_noncanonical accel_dir_suffix use_tm_clone_registry +use_eh_frame_registry force_explicit_eh_registry CET_FLAGS fixed_point @@ -713,6 +714,7 @@ enable_decimal_float with_system_libunwind enable_cet enable_explicit_exception_frame_registration +enable_eh_frame_registry enable_tm_clone_registry with_glibc_version enable_tls @@ -1357,6 +1359,7 @@ Optional Features: register exception tables explicitly at module start, for use e.g. for compatibility with installations without PT_GNU_EH_FRAME support + --disable-eh-frame-registry disable EH frame registry --disable-tm-clone-registry disable TM clone registry --enable-tls Use thread-local storage [default=yes] @@ -4956,6 +4959,25 @@ fi +# EH Frame Registry is implicitly enabled by default (although it is not +# "forced"), and libgcc/crtstuff.c will setup the support for it if it is +# supported by the target. So we don't handle --enable-eh-frame-registry. +# Check whether --enable-eh-frame-registry was given. +if test "${enable_eh_frame_registry+set}" = set; then : + enableval=$enable_eh_frame_registry; +use_eh_frame_registry= +if test "$enable_eh_frame_registry" = no; then + if test "$enable_explicit_exception_frame_registration" = yes; then + as_fn_error $? "Can't --disable-eh-frame-registry with + with --enable-explicit-exception-frame-registration" "$LINENO" 5 + fi + use_eh_frame_registry=-DUSE_EH_FRAME_REGISTRY=0 +fi + +fi + + + # Check whether --enable-tm-clone-registry was given. if test "${enable_tm_clone_registry+set}" = set; then : enableval=$enable_tm_clone_registry; diff --git a/libgcc/configure.ac b/libgcc/configure.ac index f63c5e736e5..cf2eb9c984a 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -261,6 +261,23 @@ fi ]) AC_SUBST([force_explicit_eh_registry]) +# EH Frame Registry is implicitly enabled by default (although it is not +# "forced"), and libgcc/crtstuff.c will setup the support for it if it is +# supported by the target. So we don't handle --enable-eh-frame-registry. +AC_ARG_ENABLE([eh-frame-registry], +[ --disable-eh-frame-registry disable EH frame registry], +[ +use_eh_frame_registry= +if test "$enable_eh_frame_registry" = no; then + if test "$enable_explicit_exception_frame_registration" = yes; then + AC_MSG_ERROR([Can't --disable-eh-frame-registry with + with --enable-explicit-exception-frame-registration]) + fi + use_eh_frame_registry=-DUSE_EH_FRAME_REGISTRY=0 +fi +]) +AC_SUBST([use_eh_frame_registry]) + AC_ARG_ENABLE([tm-clone-registry], [ --disable-tm-clone-registry disable TM clone registry], [ diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c index ae6328d317d..9a3247b7848 100644 --- a/libgcc/crtstuff.c +++ b/libgcc/crtstuff.c @@ -136,9 +136,13 @@ call_ ## FUNC (void) \ # error "Can't use explicit exception-frame-registration without __LIBGCC_EH_FRAME_SECTION_NAME__" # endif #endif +#ifndef USE_EH_FRAME_REGISTRY #if defined(__LIBGCC_EH_FRAME_SECTION_NAME__) && (!defined(USE_PT_GNU_EH_FRAME) || defined(USE_EH_FRAME_REGISTRY_ALWAYS)) -# define USE_EH_FRAME_REGISTRY +# define USE_EH_FRAME_REGISTRY 1 +#else +# define USE_EH_FRAME_REGISTRY 0 #endif +#endif /* USE_EH_FRAME_REGISTRY */ #if defined(__LIBGCC_EH_FRAME_SECTION_NAME__) \ && __LIBGCC_EH_TABLES_CAN_BE_READ_ONLY__ # define EH_FRAME_SECTION_CONST const @@ -257,7 +261,7 @@ STATIC func_ptr __DTOR_LIST__[1] #endif /* __DTOR_LIST__ alternatives */ #endif /* USE_INITFINI_ARRAY */ -#ifdef USE_EH_FRAME_REGISTRY +#if USE_EH_FRAME_REGISTRY /* Stick a label at the beginning of the frame unwind info so we can register and deregister it with the exception handling library code. */ STATIC EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[] @@ -412,7 +416,7 @@ __do_global_dtors_aux (void) deregister_tm_clones (); #endif /* USE_TM_CLONE_REGISTRY */ -#ifdef USE_EH_FRAME_REGISTRY +#if USE_EH_FRAME_REGISTRY #ifdef CRT_GET_RFIB_DATA /* If we used the new __register_frame_info_bases interface, make sure that we deregister from the same place. */ @@ -452,7 +456,7 @@ CRT_CALL_STATIC_FUNCTION (__LIBGCC_INIT_SECTION_ASM_OP__, __do_global_dtors_aux_1) #endif -#if defined(USE_EH_FRAME_REGISTRY) || USE_TM_CLONE_REGISTRY +#if USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY /* Stick a call to __register_frame_info into the .init section. For some reason calls with no arguments work more reliably in .init, so stick the call in another function. */ @@ -460,7 +464,7 @@ CRT_CALL_STATIC_FUNCTION (__LIBGCC_INIT_SECTION_ASM_OP__, static void __attribute__((used)) frame_dummy (void) { -#ifdef USE_EH_FRAME_REGISTRY +#if USE_EH_FRAME_REGISTRY static struct object object; #ifdef CRT_GET_RFIB_DATA void *tbase, *dbase; @@ -555,13 +559,13 @@ __do_global_dtors (void) deregister_tm_clones (); #endif /* USE_TM_CLONE_REGISTRY */ -#ifdef USE_EH_FRAME_REGISTRY +#if USE_EH_FRAME_REGISTRY if (__deregister_frame_info) __deregister_frame_info (__EH_FRAME_BEGIN__); #endif } -#if defined(USE_EH_FRAME_REGISTRY) || USE_TM_CLONE_REGISTRY +#if USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY /* A helper function for __do_global_ctors, which is in crtend.o. Here in crtbegin.o, we can reference a couple of symbols not visible there. Plus, since we're before libgcc.a, we have no problems referencing @@ -569,7 +573,7 @@ __do_global_dtors (void) void __do_global_ctors_1(void) { -#ifdef USE_EH_FRAME_REGISTRY +#if USE_EH_FRAME_REGISTRY static struct object object; if (__register_frame_info) __register_frame_info (__EH_FRAME_BEGIN__, &object); @@ -733,7 +737,7 @@ void __do_global_ctors (void) { func_ptr *p; -#if defined(USE_EH_FRAME_REGISTRY) || USE_TM_CLONE_REGISTRY +#if USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY __do_global_ctors_1(); #endif for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--) -- 2.17.1