From patchwork Thu Feb 20 18:48:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 38262 Received: (qmail 17451 invoked by alias); 20 Feb 2020 18:53:05 -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 17433 invoked by uid 89); 20 Feb 2020 18:53:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 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.1 spammy=H*i:sk:mvmmu9d, H*f:sk:mvmmu9d, csu X-HELO: us-smtp-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582224782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kLI3TdAbubIhr2zFoMdG6Erl0khXquGCjCqX5U/V8HE=; b=c71tML/kndxEyLOeuewTMkjjLF15C6oBW3CRCwklVUYDNun85RswdshGdmLaOPiAN9xfu6 MwLCLvwoBPdNAp+DthJAqzWr7SqSHIfg0gRGPHcJU6VCBamKboDg8nLoVniw6N+gf9u4na Iff02jxl0Dw6KoFQlvO12o0UWZH20bE= From: Florian Weimer To: Andreas Schwab Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] Introduce and ELF_INITFINI for all architectures References: <87zhfngjot.fsf@oldenburg2.str.redhat.com> <871rqpfc07.fsf@oldenburg2.str.redhat.com> Date: Thu, 20 Feb 2020 19:48:56 +0100 In-Reply-To: (Andreas Schwab's message of "Thu, 20 Feb 2020 18:11:43 +0100") Message-ID: <87r1ypdrhj.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com * Andreas Schwab: > environ is empty. That's because libc.so.6 still has DT_INIT, from which _environ and other variables are set up. I assumed binutils would convert that into DT_INITARRAY because the architecture is not supposed to have DT_INIT. Without that, it's hard to declare that there is no DT_INIT, and the patch essentially breaks ABI (because DT_INIT processing is gone). This should fix the breakage: Subject: Use ELF constructor instead of _init in libc.so On !ELF_INITFINI architectures, _init is no longer called by the dynamic linker. We can use an ELF constructor instead because the constructor order does not matter. (The other constructors are used to set up libio vtable bypasses and do not depend on this initialization routine.) But I'm no longer sure if RISC-V is actually an !ELF_INITFINI architecture. Thanks, Florian diff --git a/csu/init-first.c b/csu/init-first.c index 1cd8a75098..1fa1633657 100644 --- a/csu/init-first.c +++ b/csu/init-first.c @@ -46,9 +46,8 @@ __libc_init_first (int argc, char **argv, char **envp) /* For DSOs we do not need __libc_init_first but instead _init. */ } -void -attribute_hidden -_init (int argc, char **argv, char **envp) +static void __attribute__ ((constructor)) +init (int argc, char **argv, char **envp) { #endif