This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
ELF_INITFINI for ARC (was Re: [PATCH] Introduce <elf-initfini.h> and ELF_INITFINI for all architectures)
- From: Vineet Gupta <Vineet dot Gupta1 at synopsys dot com>
- To: Florian Weimer <fweimer at redhat dot com>, Andreas Schwab <schwab at suse dot de>
- Cc: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, arcml <linux-snps-arc at lists dot infradead dot org>, Alistair Francis <alistair dot francis at wdc dot com>
- Date: Wed, 26 Feb 2020 19:10:16 +0000
- Subject: ELF_INITFINI for ARC (was Re: [PATCH] Introduce <elf-initfini.h> and ELF_INITFINI for all architectures)
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synopsys.com; dmarc=pass action=none header.from=synopsys.com; dkim=pass header.d=synopsys.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gqYDKKRD46cfP7iH2Ovf6lFSWDMRmymntWukbM7OaVI=; b=ljKWjoKBbpnGBt648q1c/2KM7mYFweQPKBQ96KZy+729kcBJtgYyaL29fC48wDT4m5nx5k6972Xd1y/VhqdpWBYNaXum4j8LdcDVmoECiWq9OZWBqv5mxEjUUMjRI3j28c+6Ah4dNeDgJnYb8O+FR4gjyc5LVjyVBDn3jVpaJGvljfq6FxFX/bNwRjCs+SlgIt1JFg6diTQv/s6lc3Zk0fHIRTQoXHUyHUfx2pgWzWUCL3WaI/HhQ5ttnLk61ZaGql4QHlMtZwWAOq1zwrYKhJ7iqmK6X9jaUJWlw/V+yDhcbMHdB/a/5k39cZSeskeT0koTdPmG4ITFKDJu0TQ+uw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cuwp5fuYgPF7mwUVbwcHWpPfF6MPAeT3NA1DsBjOOcXssrZyElvY9kChfg+/aVO7Rq9OyRVVPI6eyAOB3u0/x1p4tbP5Npt916TJ6dQCZZkDO39DcJxa0z6TvkrM4rOWu6T2QoCTPMIq5e/8sI2/RQ+ACPJo5iYNYg/TfJ/FzaPlGJXXk1beKVWo55tcGEpkGdr4kzD6AU4ms5DVBbLj9Jnnm/tl+1KcdVoOlKFFR8fv/SfCaOeJNpd7wtMjqK5LcJ50lYgx1lIDiCOrJmroSb90rwwoliA86jgU9b6jA7s3cAhgZQwq0OdzMkYm/RaDpdq/IXM2+XkKdqWnnaYSWA==
- References: <87zhfngjot.fsf@oldenburg2.str.redhat.com> <mvm36b51ahf.fsf@suse.de> <871rqpfc07.fsf@oldenburg2.str.redhat.com> <mvmmu9dyyi8.fsf@suse.de> <87r1ypdrhj.fsf@oldenburg2.str.redhat.com>
Hi Florian,
On 2/20/20 10:48 AM, Florian Weimer wrote:
> * 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.)
>
> 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
>
This (or lack thereof) turned out to be the nasty busbox sh crash (and kernel init
panic) on ARC based off rebased upstream (latest RV32 from Alistair) containing
the original patch f4349837d93b4df. I tried this fixup and it seems to work. The
DT_INIT entry goes away and init does run as part of init_array.
It seems that commit also removed init_array from sysdeps/{riscv,csky}/Implies -
so newer arches. I suppose I need to do that for ARC as well - but could you
please explain (or point to documentation) which explains how this the Implies
stuff works.
> But I'm no longer sure if RISC-V is actually an !ELF_INITFINI
> architecture.
And an arch is !ELF_INITFINI if it supports initarray ?
I did switch ARC gcc [1] / binutils [2]to initarray last year
[1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-January/005318.html
[2] http://lists.infradead.org/pipermail/linux-snps-arc/2019-February/005388.html
Thx,
-Vineet