mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] arm: Fix _init/_fini alignment in crti.o.
@ 2024-10-10 20:50 Alex Rønne Petersen
  2024-10-10 20:57 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Rønne Petersen @ 2024-10-10 20:50 UTC (permalink / raw)
  To: musl; +Cc: Alex Rønne Petersen

This is just cbf59dd6 applied to arm. It manifested when compiling for thumb2
with zig cc (clang) + lld at -O1 or above, but not at -O0.
---
 crt/arm/crti.s | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/crt/arm/crti.s b/crt/arm/crti.s
index 18dc1e41..cccda3ea 100644
--- a/crt/arm/crti.s
+++ b/crt/arm/crti.s
@@ -3,11 +3,13 @@
 .section .init
 .global _init
 .type _init,%function
+.align 2
 _init:
 	push {r0,lr}
 
 .section .fini
 .global _fini
 .type _fini,%function
+.align 2
 _fini:
 	push {r0,lr}
-- 
2.40.1


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

* Re: [musl] [PATCH] arm: Fix _init/_fini alignment in crti.o.
  2024-10-10 20:50 [musl] [PATCH] arm: Fix _init/_fini alignment in crti.o Alex Rønne Petersen
@ 2024-10-10 20:57 ` Rich Felker
  2024-10-10 21:21   ` Alex Rønne Petersen
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2024-10-10 20:57 UTC (permalink / raw)
  To: Alex Rønne Petersen; +Cc: musl

On Thu, Oct 10, 2024 at 10:50:46PM +0200, Alex Rønne Petersen wrote:
> This is just cbf59dd6 applied to arm. It manifested when compiling for thumb2
> with zig cc (clang) + lld at -O1 or above, but not at -O0.
> ---
>  crt/arm/crti.s | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/crt/arm/crti.s b/crt/arm/crti.s
> index 18dc1e41..cccda3ea 100644
> --- a/crt/arm/crti.s
> +++ b/crt/arm/crti.s
> @@ -3,11 +3,13 @@
>  .section .init
>  .global _init
>  .type _init,%function
> +.align 2
>  _init:
>  	push {r0,lr}
>  
>  .section .fini
>  .global _fini
>  .type _fini,%function
> +.align 2
>  _fini:
>  	push {r0,lr}
> -- 
> 2.40.1

No objection to this fix, but I wonder if after applying it we should
just remove these files entirely. We have NO_LEGACY_INITFINI defined
on arm due to a historical mistake, so these will never be called in
dynamic-linked programs. I guess theoretically they could be used with
static linking, but all functional toolchains will be using init/fini
arrays instead or they would be incompatible with dynamic linking.

Rich

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

* Re: [musl] [PATCH] arm: Fix _init/_fini alignment in crti.o.
  2024-10-10 20:57 ` Rich Felker
@ 2024-10-10 21:21   ` Alex Rønne Petersen
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Rønne Petersen @ 2024-10-10 21:21 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

On Thu, Oct 10, 2024 at 10:57 PM Rich Felker <dalias@libc.org> wrote:
>
> On Thu, Oct 10, 2024 at 10:50:46PM +0200, Alex Rønne Petersen wrote:
> > This is just cbf59dd6 applied to arm. It manifested when compiling for thumb2
> > with zig cc (clang) + lld at -O1 or above, but not at -O0.
> > ---
> >  crt/arm/crti.s | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/crt/arm/crti.s b/crt/arm/crti.s
> > index 18dc1e41..cccda3ea 100644
> > --- a/crt/arm/crti.s
> > +++ b/crt/arm/crti.s
> > @@ -3,11 +3,13 @@
> >  .section .init
> >  .global _init
> >  .type _init,%function
> > +.align 2
> >  _init:
> >       push {r0,lr}
> >
> >  .section .fini
> >  .global _fini
> >  .type _fini,%function
> > +.align 2
> >  _fini:
> >       push {r0,lr}
> > --
> > 2.40.1
>
> No objection to this fix, but I wonder if after applying it we should
> just remove these files entirely. We have NO_LEGACY_INITFINI defined
> on arm due to a historical mistake, so these will never be called in
> dynamic-linked programs. I guess theoretically they could be used with
> static linking, but all functional toolchains will be using init/fini
> arrays instead or they would be incompatible with dynamic linking.

FWIW, most musl usage with Zig is statically linked, including the
conditions under which this issue occurred.

That said, we unconditionally use init/fini arrays for Zig code, and
it appears that clang, and by extension zig cc, uses them by default
as well (you *can* opt out... not sure why you would though).

>
> Rich

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

end of thread, other threads:[~2024-10-10 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10 20:50 [musl] [PATCH] arm: Fix _init/_fini alignment in crti.o Alex Rønne Petersen
2024-10-10 20:57 ` Rich Felker
2024-10-10 21:21   ` Alex Rønne Petersen

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).