All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: Florian Weimer <fweimer@redhat.com>, Andreas Schwab <schwab@suse.de>
Cc: Alistair Francis <alistair.francis@wdc.com>,
	arcml <linux-snps-arc@lists.infradead.org>,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Subject: ELF_INITFINI for ARC (was Re: [PATCH] Introduce <elf-initfini.h> and ELF_INITFINI for all architectures)
Date: Wed, 26 Feb 2020 19:10:16 +0000	[thread overview]
Message-ID: <cc69bcb6-526a-469d-f78a-035208645ae9@synopsys.com> (raw)
In-Reply-To: <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
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

       reply	other threads:[~2020-02-26 19:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87zhfngjot.fsf@oldenburg2.str.redhat.com>
     [not found] ` <mvm36b51ahf.fsf@suse.de>
     [not found]   ` <871rqpfc07.fsf@oldenburg2.str.redhat.com>
     [not found]     ` <mvmmu9dyyi8.fsf@suse.de>
     [not found]       ` <87r1ypdrhj.fsf@oldenburg2.str.redhat.com>
2020-02-26 19:10         ` Vineet Gupta [this message]
2020-02-26 19:27           ` ELF_INITFINI for ARC (was Re: [PATCH] Introduce <elf-initfini.h> and ELF_INITFINI for all architectures) Florian Weimer
2020-02-26 20:02             ` Vineet Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc69bcb6-526a-469d-f78a-035208645ae9@synopsys.com \
    --to=vineet.gupta1@synopsys.com \
    --cc=alistair.francis@wdc.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.