unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] csu: Use ELF constructor instead of _init in libc.so
@ 2020-02-24 11:09 Florian Weimer
  2020-02-24 11:13 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Florian Weimer @ 2020-02-24 11:09 UTC (permalink / raw)
  To: libc-alpha; +Cc: DJ Delorie, Jim Wilson, Andreas Schwab

Tested on aarch64-linux-gnu, i386-linux-gnu, powerpc64le-linux-gnu,
x86_64-linux-gnu.  Also built on i686-gnu,
riscv64-linux-gnu-rv64imac-lp64, and s390x-linux-gnu.

Would someone with access to RISC-V hardware please test this patch?
Thanks.

Florian
8<------------------------------------------------------------------8<
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.)

-----
 csu/init-first.c        | 12 ++++++------
 elf/soinit.c            |  2 +-
 include/libc-internal.h |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/csu/init-first.c b/csu/init-first.c
index 1cd8a75098..264e6f348d 100644
--- a/csu/init-first.c
+++ b/csu/init-first.c
@@ -43,12 +43,11 @@ void
 __libc_init_first (int argc, char **argv, char **envp)
 {
 #ifdef SHARED
-  /* For DSOs we do not need __libc_init_first but instead _init.  */
+  /* For DSOs we do not need __libc_init_first but an ELF constructor.  */
 }
 
-void
-attribute_hidden
-_init (int argc, char **argv, char **envp)
+static void __attribute__ ((constructor))
+_init_first (int argc, char **argv, char **envp)
 {
 #endif
 
@@ -86,8 +85,9 @@ _init (int argc, char **argv, char **envp)
 
 /* This function is defined here so that if this file ever gets into
    ld.so we will get a link error.  Having this file silently included
-   in ld.so causes disaster, because the _init definition above will
-   cause ld.so to gain an init function, which is not a cool thing. */
+   in ld.so causes disaster, because the _init_first definition above
+   will cause ld.so to gain an ELF constructor, which is not a cool
+   thing. */
 
 extern void _dl_start (void) __attribute__ ((noreturn));
 
diff --git a/elf/soinit.c b/elf/soinit.c
index fe9935732b..538eb68186 100644
--- a/elf/soinit.c
+++ b/elf/soinit.c
@@ -20,7 +20,7 @@ run_hooks (void (*const list[]) (void))
     (**list) ();
 }
 
-/* This function will be called from _init in init-first.c.  */
+/* This function will be called from _init_first in init-first.c.  */
 void
 __libc_global_ctors (void)
 {
diff --git a/include/libc-internal.h b/include/libc-internal.h
index fcd21468c0..4c74f6ba60 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -24,7 +24,7 @@
 /* Initialize the `__libc_enable_secure' flag.  */
 extern void __libc_init_secure (void);
 
-/* This function will be called from _init in init-first.c.  */
+/* This function will be called from _init_first in init-first.c.  */
 extern void __libc_global_ctors (void);
 
 /* Discover the tick frequency of the machine if something goes wrong,


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-24 11:09 [PATCH] csu: Use ELF constructor instead of _init in libc.so Florian Weimer
@ 2020-02-24 11:13 ` Andreas Schwab
  2020-02-24 12:02 ` Andreas Schwab
  2020-02-24 22:38 ` Jim Wilson
  2 siblings, 0 replies; 11+ messages in thread
From: Andreas Schwab @ 2020-02-24 11:13 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, DJ Delorie, Jim Wilson

On Feb 24 2020, Florian Weimer wrote:

> Would someone with access to RISC-V hardware please test this patch?

You can use one of the images in
<https://download.opensuse.org/ports/riscv/tumbleweed/images/> and use
it under qemu-linux-user.  See <https://en.opensuse.org/openSUSE:RISC-V>
for details.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-24 11:09 [PATCH] csu: Use ELF constructor instead of _init in libc.so Florian Weimer
  2020-02-24 11:13 ` Andreas Schwab
@ 2020-02-24 12:02 ` Andreas Schwab
  2020-02-25 12:34   ` Florian Weimer
  2020-02-24 22:38 ` Jim Wilson
  2 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2020-02-24 12:02 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, DJ Delorie, Jim Wilson

On Feb 24 2020, Florian Weimer wrote:

> Tested on aarch64-linux-gnu, i386-linux-gnu, powerpc64le-linux-gnu,
> x86_64-linux-gnu.  Also built on i686-gnu,
> riscv64-linux-gnu-rv64imac-lp64, and s390x-linux-gnu.
>
> Would someone with access to RISC-V hardware please test this patch?

I have thrown your patch into a test build
<https://build.opensuse.org/project/show/home:Andreas_Schwab:glibc:test>.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-24 11:09 [PATCH] csu: Use ELF constructor instead of _init in libc.so Florian Weimer
  2020-02-24 11:13 ` Andreas Schwab
  2020-02-24 12:02 ` Andreas Schwab
@ 2020-02-24 22:38 ` Jim Wilson
  2 siblings, 0 replies; 11+ messages in thread
From: Jim Wilson @ 2020-02-24 22:38 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library, DJ Delorie, Andreas Schwab

On Mon, Feb 24, 2020 at 3:09 AM Florian Weimer <fweimer@redhat.com> wrote:
> Would someone with access to RISC-V hardware please test this patch?

Friday, I tested the previous version of this patch on a RISC-V Fedora
rawhide system with a glibc build and check.  The check failed badly
without the patch, it didn't even make it far enough to report
results.  It did succeed with the patch, giving the expected result of
about 17 failures.  It looks like the only changes since the previous
version are to comments.  I can try another check if necessary but I
think the testing Andreas is doing is probably better than my testing.

Jim

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-24 12:02 ` Andreas Schwab
@ 2020-02-25 12:34   ` Florian Weimer
  2020-02-25 12:57     ` Andreas Schwab
  0 siblings, 1 reply; 11+ messages in thread
From: Florian Weimer @ 2020-02-25 12:34 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha, DJ Delorie, Jim Wilson

* Andreas Schwab:

> On Feb 24 2020, Florian Weimer wrote:
>
>> Tested on aarch64-linux-gnu, i386-linux-gnu, powerpc64le-linux-gnu,
>> x86_64-linux-gnu.  Also built on i686-gnu,
>> riscv64-linux-gnu-rv64imac-lp64, and s390x-linux-gnu.
>>
>> Would someone with access to RISC-V hardware please test this patch?
>
> I have thrown your patch into a test build
> <https://build.opensuse.org/project/show/home:Andreas_Schwab:glibc:test>.

Would you please help me to interpret the results?  Is the ppc64le
failure spurious?  I can't see any details on the public view.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-25 12:34   ` Florian Weimer
@ 2020-02-25 12:57     ` Andreas Schwab
  2020-02-25 12:58       ` Florian Weimer
  0 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2020-02-25 12:57 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, DJ Delorie, Jim Wilson

On Feb 25 2020, Florian Weimer wrote:

> Would you please help me to interpret the results?  Is the ppc64le
> failure spurious?  I can't see any details on the public view.

[ 3013s] /.build/build: line 437: echo: write error: No space left on device

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-25 12:57     ` Andreas Schwab
@ 2020-02-25 12:58       ` Florian Weimer
  2020-02-25 13:18         ` Andreas Schwab
  0 siblings, 1 reply; 11+ messages in thread
From: Florian Weimer @ 2020-02-25 12:58 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha, DJ Delorie, Jim Wilson

* Andreas Schwab:

> On Feb 25 2020, Florian Weimer wrote:
>
>> Would you please help me to interpret the results?  Is the ppc64le
>> failure spurious?  I can't see any details on the public view.
>
> [ 3013s] /.build/build: line 437: echo: write error: No space left on device

Okay, so I guess that's something we can ignore.

Has the riscv64 build proceeded past the critical point yet?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-25 12:58       ` Florian Weimer
@ 2020-02-25 13:18         ` Andreas Schwab
  2020-02-25 13:44           ` Florian Weimer
  0 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2020-02-25 13:18 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, DJ Delorie, Jim Wilson

On Feb 25 2020, Florian Weimer wrote:

> Has the riscv64 build proceeded past the critical point yet?

Yes.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-25 13:18         ` Andreas Schwab
@ 2020-02-25 13:44           ` Florian Weimer
  2020-02-25 13:53             ` Andreas Schwab
  0 siblings, 1 reply; 11+ messages in thread
From: Florian Weimer @ 2020-02-25 13:44 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha, DJ Delorie, Jim Wilson

* Andreas Schwab:

> On Feb 25 2020, Florian Weimer wrote:
>
>> Has the riscv64 build proceeded past the critical point yet?
>
> Yes.

Should I commit my patch then?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-25 13:44           ` Florian Weimer
@ 2020-02-25 13:53             ` Andreas Schwab
  2020-02-25 22:46               ` Alistair Francis
  0 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2020-02-25 13:53 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, DJ Delorie, Jim Wilson

On Feb 25 2020, Florian Weimer wrote:

> Should I commit my patch then?

Please do.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] csu: Use ELF constructor instead of _init in libc.so
  2020-02-25 13:53             ` Andreas Schwab
@ 2020-02-25 22:46               ` Alistair Francis
  0 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2020-02-25 22:46 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Florian Weimer, GNU C Library, DJ Delorie, Jim Wilson

On Tue, Feb 25, 2020 at 5:53 AM Andreas Schwab <schwab@suse.de> wrote:
>
> On Feb 25 2020, Florian Weimer wrote:
>
> > Should I commit my patch then?
>
> Please do.

I'm a little late (I missed the original conversation) but this patch
fixes RV32 errors as well.

Alistair

>
> Andreas.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-02-25 22:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 11:09 [PATCH] csu: Use ELF constructor instead of _init in libc.so Florian Weimer
2020-02-24 11:13 ` Andreas Schwab
2020-02-24 12:02 ` Andreas Schwab
2020-02-25 12:34   ` Florian Weimer
2020-02-25 12:57     ` Andreas Schwab
2020-02-25 12:58       ` Florian Weimer
2020-02-25 13:18         ` Andreas Schwab
2020-02-25 13:44           ` Florian Weimer
2020-02-25 13:53             ` Andreas Schwab
2020-02-25 22:46               ` Alistair Francis
2020-02-24 22:38 ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).