mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] A question about if crti.s and crtn.s is not necessary?
@ 2022-11-09  2:51 王洪亮
  2022-11-09 11:48 ` Szabolcs Nagy
  0 siblings, 1 reply; 3+ messages in thread
From: 王洪亮 @ 2022-11-09  2:51 UTC (permalink / raw)
  To: musl

Hi,

In LoongArch port, I found build musl and libc-test is OK without 
crt/loongarch64/crti.s and crt/loongarch64/crtn.s,

so I want to ask if crti.s and crtn.s is not necessary in architecture?


 > diff --git a/crt/loongarch64/crti.s b/crt/loongarch64/crti.s
 > new file mode 100644
 > index 00000000..81c43e6e
 > --- /dev/null
 > +++ b/crt/loongarch64/crti.s
 > @@ -0,0 +1,15 @@
 > +.section .init
 > +.global _init
 > +_init:
 > +    addi.d $sp,$sp,-16
 > +    st.d $fp,$sp,0
 > +    st.d $ra,$sp,8
 > +    addi.d $fp,$sp,16
 > +
 > +.section .fini
 > +.global _fini
 > +_fini:
 > +    addi.d $sp,$sp,-16
 > +    st.d $fp,$sp,0
 > +    st.d $ra,$sp,8
 > +    addi.d $fp,$sp,16
 > diff --git a/crt/loongarch64/crtn.s b/crt/loongarch64/crtn.s
 > new file mode 100644
 > index 00000000..ca3fe80e
 > --- /dev/null
 > +++ b/crt/loongarch64/crtn.s
 > @@ -0,0 +1,12 @@
 > +.section .init
 > +    ld.d $fp,$sp,0
 > +    ld.d $ra,$sp,8
 > +    addi.d $sp,$sp,16
 > +    jr $ra
 > +
 > +
 > +.section .fini
 > +    ld.d $fp,$sp,0
 > +    ld.d $ra,$sp,8
 > +    addi.d $sp,$sp,16
 > +    jr $ra

The crt changes shouldn't be necessary at all huh? I didn't see any 
custom asm
for riscv, for example.



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

* Re: [musl] A question about if crti.s and crtn.s is not necessary?
  2022-11-09  2:51 [musl] A question about if crti.s and crtn.s is not necessary? 王洪亮
@ 2022-11-09 11:48 ` Szabolcs Nagy
  2022-11-09 12:13   ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Szabolcs Nagy @ 2022-11-09 11:48 UTC (permalink / raw)
  To: 王洪亮; +Cc: musl

* 王洪亮 <wanghongliang@loongson.cn> [2022-11-09 10:51:37 +0800]:
> In LoongArch port, I found build musl and libc-test is OK without
> crt/loongarch64/crti.s and crt/loongarch64/crtn.s,
> 
> so I want to ask if crti.s and crtn.s is not necessary in architecture?

in musl the generic crti/crtn.o is empty.
which works if no user code uses .init or .fini sections.

the old way of doing ctors/dtors used .init/.fini but new targets use
.init_array/.fini_array for a while now.

if no language feature uses .init/.fini, should we support this?
well if they are still part of the elf abi and somebody writes code
manually for .init/.fini then yes. however it's not clear to me that
default linker scripts that still treat these sections specially on
new targets do so as old habit i.e. they have no abi relevance, or
if this is still something that's supposed to work.

i think they can be empty on new targets, but it does not hurt to have
support in case somebody needs the .init/.fini behaviour (which has
static and dynamic linker support already anyway).

libc-test does not test for it, and would be tricky to do so portably.

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

* Re: [musl] A question about if crti.s and crtn.s is not necessary?
  2022-11-09 11:48 ` Szabolcs Nagy
@ 2022-11-09 12:13   ` Florian Weimer
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2022-11-09 12:13 UTC (permalink / raw)
  To: 王洪亮; +Cc: musl

* Szabolcs Nagy:

> * 王洪亮 <wanghongliang@loongson.cn> [2022-11-09 10:51:37 +0800]:
>> In LoongArch port, I found build musl and libc-test is OK without
>> crt/loongarch64/crti.s and crt/loongarch64/crtn.s,
>> 
>> so I want to ask if crti.s and crtn.s is not necessary in architecture?
>
> in musl the generic crti/crtn.o is empty.
> which works if no user code uses .init or .fini sections.
>
> the old way of doing ctors/dtors used .init/.fini but new targets use
> .init_array/.fini_array for a while now.
>
> if no language feature uses .init/.fini, should we support this?

New architectures are supposed to not use DT_INIT/DT_FINI (in glibc
terms, ELF_INITFINI is defined as 0) because they have been deprecated
in the toolchain for a long, long time.

Thanks,
Florian


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

end of thread, other threads:[~2022-11-09 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09  2:51 [musl] A question about if crti.s and crtn.s is not necessary? 王洪亮
2022-11-09 11:48 ` Szabolcs Nagy
2022-11-09 12:13   ` Florian Weimer

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