From patchwork Fri Jan 26 05:44:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 25548 Received: (qmail 5299 invoked by alias); 26 Jan 2018 05:45:00 -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 5251 invoked by uid 89); 26 Jan 2018 05:44:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, 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.2 spammy= X-HELO: mail-pf0-f169.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :cc:from:to; bh=RBln6NqY8jdVqV8vP5Dy5lGRA3n0mOaVqk0+G302aA0=; b=RaRHALst4bJBjo+cOB1IGtn/EE0z7hKgTLtc0cjwRyIPlSvY8nnQdjmh0nPsnM2ScM Rf3HGNE8Jymfx8XD8E1sg72gFN7fJGbTSiqn6IEI01cSMzEJ0TrrFtfLKuJXtK6jpgY0 Tmtz7l9MFa/EThWuAi7EqVotAr/Sooa+zzWsT6iHvo/HEDTNDykMxrVv1uhA3eHIjKd1 BfUWtfzAa+gGe91UV8vPtfeuzOJhwuA5uhkr5ltBJ6gCWV2y29AB0xSgbHAnH8ExmiOY svxO3uOIE/P0UmZ+CJc2x18d1cGQx3WFsahj3AGndV5AFN9TGD4hc5QmwT8UABxJCgCa a6xA== X-Gm-Message-State: AKwxytcQShzmcf/CVoSdI0CS74uFfzCLRtjXEWvkWEgz2Cno6apcIwik EW5jKl4XeVSdy5R38GyN5YTUNQ== X-Google-Smtp-Source: AH8x224DDywH3QsRwFl5FVYHWIyEQqn+UkbEJMANTvdhSNsZRtaW8NNCCmYrLE7XViH3MlD2yr4yug== X-Received: by 2002:a17:902:548f:: with SMTP id e15-v6mr8827136pli.230.1516945495250; Thu, 25 Jan 2018 21:44:55 -0800 (PST) Subject: [PATCH v6 01/16] sysdeps/init_array: Add PREINIT_FUNCTION to crti.S Date: Thu, 25 Jan 2018 21:44:28 -0800 Message-Id: <20180126054443.22702-2-palmer@dabbelt.com> In-Reply-To: <20180126054443.22702-1-palmer@dabbelt.com> References: <20180126054443.22702-1-palmer@dabbelt.com> Cc: patches@groups.riscv.org, Andrew Waterman , dj@redhat.com, Darius Rad , Palmer Dabbelt From: Palmer Dabbelt To: libc-alpha@sourceware.org, joseph@codesourcery.com The RISC-V port contains a crti.S that simply contains a link to PREINIT_FUNCTION (when defined). As this should be entirely generic, Joseph Myers suggested that we update the generic init_array version to contain this. Since RISC-V is the only user of init_array this won't break any existing ports. This uses '.section .init_array,"aw"', while pt-crti.S contains '.section .init_array,"a",%init_array'. I think we should include the '%init_array' section type as well. Additionally, I'm not sure about the % vs @ distinction -- the gas documentation suggests that only ARM uses '%', so maybe this generic directory should use '@' instead? FWIW, the RISC-V assembler appears to accept '%init_array' and '@init_array'. 2018-01-25 Palmer Dabbelt * sysdeps/init_array/crti.S (.section .init_array): Add PREINIT_FUNCTION when defined. --- sysdeps/init_array/crti.S | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sysdeps/init_array/crti.S b/sysdeps/init_array/crti.S index 0a6e9fd95338..60ba071c1c6e 100644 --- a/sysdeps/init_array/crti.S +++ b/sysdeps/init_array/crti.S @@ -11,3 +11,19 @@ But new configurations without compatibility concerns for toolchains without .init_array support can use this to avoid the superfluous .init and .fini boilerplate code. */ + +#include + +#ifdef PREINIT_FUNCTION + +#if PREINIT_FUNCTION_WEAK +# error PREINIT_FUNCTION_WEAK is unsupported +#endif + +/* This arranges for PREINIT_FUNCTION to be called upon loading a library that + contains crti.o. */ + + .section .init_array, "aw" + .dc.a PREINIT_FUNCTION + +#endif